Sha256: 879e38c26c586caa14cc97830a3a8764acb21cae04cce9956495605dcaf59c51

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

module Saml
  class Response
    include Saml::ComplexTypes::StatusResponseType

    tag "Response"
    has_many :assertions, Saml::Assertion
    has_many :encrypted_assertions, Saml::Elements::EncryptedAssertion

    def authn_failed?
      !success? && status.status_code.authn_failed?
    end

    def request_denied?
      !success? && status.status_code.request_denied?
    end

    def no_authn_context?
      !success? && status.status_code.no_authn_context?
    end

    def unknown_principal?
      !success? && status.status_code.unknown_principal?
    end

    def encrypt_assertions(certificate)
      @encrypted_assertions = []
      assertions.each do |assertion|
        @encrypted_assertions << Saml::Util.encrypt_assertion(assertion, certificate)
      end
      assertions.clear
    end

    def decrypt_assertions(private_key)
      @assertions ||= []
      encrypted_assertions.each do |encrypted_assertion|
        @assertions << Saml::Util.decrypt_assertion(encrypted_assertion, private_key)
      end
      encrypted_assertions.clear
    end

    def assertion
      assertions.first
    end

    def assertion=(assertion)
      (self.assertions ||= []) << assertion
    end

    def encrypted_assertion
      encrypted_assertions.first
    end

    def encrypted_assertion=(encrypted_assertion)
      (self.encrypted_assertions ||= []) << encrypted_assertion
     end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
libsaml-2.11.2 lib/saml/response.rb
libsaml-2.11.1 lib/saml/response.rb