Sha256: ef0ffe6e1e909f89aaac363758bd5bcf7e579acd24ec144095e70c268d6fa338

Contents?: true

Size: 1.06 KB

Versions: 21

Compression:

Stored size: 1.06 KB

Contents

module Saml
  class Artifact
    include ::HappyMapper

    TYPE_CODE      = "\000\004"
    ENDPOINT_INDEX = "\000\000"

    tag "Artifact"
    namespace 'samlp'

    content :artifact, String

    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

    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

21 entries across 21 versions & 1 rubygems

Version Path
libsaml-2.14.0 lib/saml/artifact.rb
libsaml-2.13.1 lib/saml/artifact.rb
libsaml-2.12.1 lib/saml/artifact.rb
libsaml-2.12.0 lib/saml/artifact.rb
libsaml-2.11.2 lib/saml/artifact.rb
libsaml-2.11.1 lib/saml/artifact.rb
libsaml-2.11.0 lib/saml/artifact.rb
libsaml-2.10.7 lib/saml/artifact.rb
libsaml-2.10.6 lib/saml/artifact.rb
libsaml-2.10.5 lib/saml/artifact.rb
libsaml-2.10.4 lib/saml/artifact.rb
libsaml-2.10.3 lib/saml/artifact.rb
libsaml-2.10.2 lib/saml/artifact.rb
libsaml-2.10.1 lib/saml/artifact.rb
libsaml-2.10.0 lib/saml/artifact.rb
libsaml-2.9.0 lib/saml/artifact.rb
libsaml-2.8.1 lib/saml/artifact.rb
libsaml-2.8.0 lib/saml/artifact.rb
libsaml-2.7.0 lib/saml/artifact.rb
libsaml-2.6.9 lib/saml/artifact.rb