Class: Saml2::Type4Artifact

Inherits:
Object
  • Object
show all
Defined in:
lib/saml2/type4_artifact.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint_index, source_id, message_handle) ⇒ Type4Artifact

Returns a new instance of Type4Artifact.



25
26
27
28
29
# File 'lib/saml2/type4_artifact.rb', line 25

def initialize(endpoint_index, source_id, message_handle)
  @endpoint_index = endpoint_index
  @source_id = source_id
  @message_handle = message_handle
end

Instance Attribute Details

#endpoint_indexObject (readonly)

Returns the value of attribute endpoint_index.



6
7
8
# File 'lib/saml2/type4_artifact.rb', line 6

def endpoint_index
  @endpoint_index
end

#message_handleObject (readonly)

Returns the value of attribute message_handle.



6
7
8
# File 'lib/saml2/type4_artifact.rb', line 6

def message_handle
  @message_handle
end

#source_idObject (readonly)

Returns the value of attribute source_id.



6
7
8
# File 'lib/saml2/type4_artifact.rb', line 6

def source_id
  @source_id
end

Class Method Details

.new_from_string(artifact_string) ⇒ Saml2::Type4Artifact

Parse an type 4 SAML 2.0 artifact such as one received in a ‘SAMLart` HTTP request parameter as part of a HTTP artifact binding SSO handshake.

Parameters:

  • artifact_string (String)

    a base64 encoded SAML 2.0 artifact

Returns:

Raises:



15
16
17
18
19
20
21
22
23
# File 'lib/saml2/type4_artifact.rb', line 15

def self.new_from_string(artifact_string)
  unencoded_artifact = Base64.decode64 artifact_string

  type_code, *rest = unencoded_artifact.unpack('nna20a20')

  raise UnexpectedTypeCodeError.new("Incorrect artifact type (expected type code 4 but found #{type_code}") unless type_code == 4

  new *rest
end

Instance Method Details

#resolveSaml2::Assertion

Resolve the artifact into an Assertion

Returns:



45
46
47
# File 'lib/saml2/type4_artifact.rb', line 45

def resolve
  Saml2::ArtifactResolver(source_id).resolve(self)
end

#to_sString

Returns base64 encoded version of self.

Returns:

  • (String)

    base64 encoded version of self



37
38
39
# File 'lib/saml2/type4_artifact.rb', line 37

def to_s
  Base64.encode64([4, endpoint_index, source_id, message_handle].pack('nna20a20')).strip
end

#type_codeObject

The type code of this artifact



32
33
34
# File 'lib/saml2/type4_artifact.rb', line 32

def type_code 
  4
end