class Saml::Artifact

Constants

ENDPOINT_INDEX
TYPE_CODE

Public Class Methods

new(artifact = nil, endpoint_index = ENDPOINT_INDEX) click to toggle source
# File lib/saml/artifact.rb, line 13
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 = 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

Public Instance Methods

endpoint_index() click to toggle source
# File lib/saml/artifact.rb, line 29
def endpoint_index
  decoded_value[2, 2]
end
message_handle() click to toggle source
# File lib/saml/artifact.rb, line 37
def message_handle
  decoded_value[24, 20]
end
source_id() click to toggle source
# File lib/saml/artifact.rb, line 33
def source_id
  decoded_value[4, 20]
end
to_s() click to toggle source
# File lib/saml/artifact.rb, line 41
def to_s
  artifact
end
type_code() click to toggle source
# File lib/saml/artifact.rb, line 25
def type_code
  decoded_value[0, 2]
end

Private Instance Methods

decoded_value() click to toggle source
# File lib/saml/artifact.rb, line 47
def decoded_value
  ::Base64.decode64(artifact)
end