Sha256: 343e76143a8de21b9cca546ac833e1f99764b5ec3a3411c5bb440d3a6df74c62

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

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

    attr_accessor :xml_value

    tag "Response"
    has_many :assertions, Saml::Assertion, xpath: './'
    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 request_unsupported?
      !success? && status.status_code.request_unsupported?
    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, include_certificate: false)
      @encrypted_assertions = []
      assertions.each do |assertion|
        @encrypted_assertions << Saml::Util.encrypt_assertion(assertion, certificate, include_certificate: include_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

5 entries across 5 versions & 1 rubygems

Version Path
libsaml-3.9.1 lib/saml/response.rb
libsaml-3.9.0 lib/saml/response.rb
libsaml-3.8.0 lib/saml/response.rb
libsaml-3.7.0 lib/saml/response.rb
libsaml-3.6.0 lib/saml/response.rb