Sha256: 39412fdf081df5fb16003593ae284f05b6e8d43a061471930fc5d43e73fe3405

Contents?: true

Size: 988 Bytes

Versions: 29

Compression:

Stored size: 988 Bytes

Contents

module Saml
  class Artifact
    include ::HappyMapper

    TYPE_CODE       = "\000\004"
    END_POINT_INDEX = "\000\000"

    tag "Artifact"
    namespace 'samlp'

    content :artifact, String

    def initialize(artifact = nil)
      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
      end
    end

    def type_code
      decoded_value[0, 2]
    end

    def endpoint_index
      decoded_value[2, 2]
    end

    def source_id
      decoded_value[4, 20]
    end

    def message_handle
      decoded_value[24, 20]
    end

    def to_s
      artifact
    end

    private

    def decoded_value
      ::Base64.decode64(artifact)
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
libsaml-2.6.7 lib/saml/artifact.rb
libsaml-2.6.6 lib/saml/artifact.rb
libsaml-2.6.4 lib/saml/artifact.rb
libsaml-2.6.2 lib/saml/artifact.rb
libsaml-2.6.1 lib/saml/artifact.rb
libsaml-2.6.0 lib/saml/artifact.rb
libsaml-2.5.2 lib/saml/artifact.rb
libsaml-2.5.1 lib/saml/artifact.rb
libsaml-2.5.0 lib/saml/artifact.rb
libsaml-2.4.7 lib/saml/artifact.rb
libsaml-2.4.6 lib/saml/artifact.rb
libsaml-2.4.5 lib/saml/artifact.rb
libsaml-2.4.4 lib/saml/artifact.rb
libsaml-2.4.3 lib/saml/artifact.rb
libsaml-2.4.2 lib/saml/artifact.rb
libsaml-2.4.1 lib/saml/artifact.rb
libsaml-2.3.2 lib/saml/artifact.rb
libsaml-2.3.1 lib/saml/artifact.rb
libsaml-2.2.3 lib/saml/artifact.rb
libsaml-2.2.2 lib/saml/artifact.rb