lib/saml/artifact.rb in libsaml-2.6.7 vs lib/saml/artifact.rb in libsaml-2.6.8

- old
+ new

@@ -1,25 +1,25 @@ module Saml class Artifact include ::HappyMapper - TYPE_CODE = "\000\004" - END_POINT_INDEX = "\000\000" + TYPE_CODE = "\000\004" + ENDPOINT_INDEX = "\000\000" tag "Artifact" namespace 'samlp' content :artifact, String - def initialize(artifact = nil) + def initialize(artifact = nil, endpoint_index = ENDPOINT_INDEX) if artifact @artifact = artifact else source_id = ::Digest::SHA1.digest(Saml.current_provider.entity_id.to_s) message_handle = ::SecureRandom.random_bytes(20) @type_code = TYPE_CODE - @endpoint_index = END_POINT_INDEX - @artifact = Saml::Encoding.encode_64 [@type_code, @endpoint_index, source_id, message_handle].join + @endpoint_index = endpoint_index.is_a?(Numeric) ? [endpoint_index].pack("n") : endpoint_index + @artifact = Saml::Encoding.encode_64 [@type_code, @endpoint_index, source_id, message_handle].join end end def type_code decoded_value[0, 2]