Class: Saml2::ArtifactResolver
- Inherits:
-
Object
- Object
- Saml2::ArtifactResolver
- Defined in:
- lib/saml2/artifact_resolver.rb
Instance Attribute Summary collapse
-
#basic_auth_password ⇒ Object
readonly
Returns the value of attribute basic_auth_password.
-
#basic_auth_realm ⇒ Object
readonly
Returns the value of attribute basic_auth_realm.
-
#basic_auth_user_id ⇒ Object
readonly
Returns the value of attribute basic_auth_user_id.
-
#idp_id ⇒ Object
readonly
Returns the value of attribute idp_id.
-
#resolution_service_uri ⇒ Object
readonly
Returns the value of attribute resolution_service_uri.
-
#source_id ⇒ Object
readonly
Returns the value of attribute source_id.
-
#sp_id ⇒ Object
readonly
Returns the value of attribute sp_id.
Instance Method Summary collapse
- #authenticator ⇒ Object
-
#basic_auth_credentials(user_id, password, realm = nil) ⇒ Object
Set HTTP basic authentication credentials.
- #http ⇒ Object
-
#initialize(source_id, resolution_service_uri, idp_id, sp_id) ⇒ ArtifactResolver
constructor
Initialize and register a new artifact resolver.
- #logger ⇒ Object
-
#resolve(artifact) ⇒ Saml2::Assertion
Resolve ‘artifact` into an Assertion.
- #to_s ⇒ Object
Constructor Details
#initialize(source_id, resolution_service_uri, idp_id, sp_id) ⇒ ArtifactResolver
Initialize and register a new artifact resolver.
37 38 39 40 41 42 43 |
# File 'lib/saml2/artifact_resolver.rb', line 37 def initialize(source_id, resolution_service_uri, idp_id, sp_id) @source_id = source_id @resolution_service_uri = Addressable::URI.parse(resolution_service_uri) @idp_id = idp_id @sp_id = sp_id ArtifactResolverRegistry.register self end |
Instance Attribute Details
#basic_auth_password ⇒ Object (readonly)
Returns the value of attribute basic_auth_password.
22 23 24 |
# File 'lib/saml2/artifact_resolver.rb', line 22 def basic_auth_password @basic_auth_password end |
#basic_auth_realm ⇒ Object (readonly)
Returns the value of attribute basic_auth_realm.
22 23 24 |
# File 'lib/saml2/artifact_resolver.rb', line 22 def basic_auth_realm @basic_auth_realm end |
#basic_auth_user_id ⇒ Object (readonly)
Returns the value of attribute basic_auth_user_id.
22 23 24 |
# File 'lib/saml2/artifact_resolver.rb', line 22 def basic_auth_user_id @basic_auth_user_id end |
#idp_id ⇒ Object (readonly)
Returns the value of attribute idp_id.
21 22 23 |
# File 'lib/saml2/artifact_resolver.rb', line 21 def idp_id @idp_id end |
#resolution_service_uri ⇒ Object (readonly)
Returns the value of attribute resolution_service_uri.
21 22 23 |
# File 'lib/saml2/artifact_resolver.rb', line 21 def resolution_service_uri @resolution_service_uri end |
#source_id ⇒ Object (readonly)
Returns the value of attribute source_id.
21 22 23 |
# File 'lib/saml2/artifact_resolver.rb', line 21 def source_id @source_id end |
#sp_id ⇒ Object (readonly)
Returns the value of attribute sp_id.
21 22 23 |
# File 'lib/saml2/artifact_resolver.rb', line 21 def sp_id @sp_id end |
Instance Method Details
#authenticator ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/saml2/artifact_resolver.rb', line 60 def authenticator return nil unless basic_auth_user_id if basic_auth_realm Resourceful::BasicAuthenticator.new(basic_auth_realm, basic_auth_user_id, basic_auth_password) else Resourceful::PromiscuousBasicAuthenticator.new(basic_auth_user_id, basic_auth_password) end end |
#basic_auth_credentials(user_id, password, realm = nil) ⇒ Object
Set HTTP basic authentication credentials
46 47 48 49 50 |
# File 'lib/saml2/artifact_resolver.rb', line 46 def basic_auth_credentials(user_id, password, realm = nil) @basic_auth_realm = realm @basic_auth_user_id = user_id @basic_auth_password = password end |
#http ⇒ Object
56 57 58 |
# File 'lib/saml2/artifact_resolver.rb', line 56 def http @http ||= Resourceful::HttpAccessor.new(:authenticators => authenticator, :logger => logger) end |
#logger ⇒ Object
52 53 54 |
# File 'lib/saml2/artifact_resolver.rb', line 52 def logger SamlSp.logger end |
#resolve(artifact) ⇒ Saml2::Assertion
Resolve ‘artifact` into an Assertion.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/saml2/artifact_resolver.rb', line 81 def resolve(artifact) soap_body = request_document_for(artifact) logger.debug{"ArtifactResolve request body:\n#{soap_body.gsub(/^/, "\t")}"} resp = http.resource(resolution_service_uri).post(soap_body, 'Accept' => 'application/soap+xml', 'Content-Type' => 'application/soap+xml') doc = Nokogiri::XML.parse(resp.body) assert_successful_response(doc) assertion = Assertion.new_from_xml(doc) raise AnomalousResponseIssuerError.new_from_issuers(idp_id, assertion.issuer) unless assertion.issuer == idp_id assertion rescue Resourceful::UnsuccessfulHttpRequestError => e logger.debug { body = e.http_request.body body.rewind "Artifact resolution request:\n" + body.read.gsub(/^/, ' ')} logger.debug {"Artifact resolution response:\n" + e.http_response.body.gsub(/^/, ' ')} raise end |
#to_s ⇒ Object
108 109 110 |
# File 'lib/saml2/artifact_resolver.rb', line 108 def to_s "Resolver for <#{idp_id}> (#{Base64.encode64(source_id).strip})" end |