Class: OpenID::Consumer::AssociationManager
- Inherits:
-
Object
- Object
- OpenID::Consumer::AssociationManager
- Defined in:
- lib/openid/consumer/associationmanager.rb
Overview
An object that manages creating and storing associations for an OpenID provider endpoint
Class Method Summary collapse
Instance Method Summary collapse
- #get_association ⇒ Object
-
#initialize(store, server_url, compatibility_mode = false, negotiator = nil) ⇒ AssociationManager
constructor
A new instance of AssociationManager.
- #negotiate_association ⇒ Object
Constructor Details
#initialize(store, server_url, compatibility_mode = false, negotiator = nil) ⇒ AssociationManager
Returns a new instance of AssociationManager.
108 109 110 111 112 113 114 |
# File 'lib/openid/consumer/associationmanager.rb', line 108 def initialize(store, server_url, compatibility_mode = false, negotiator = nil) @store = store @server_url = server_url @compatibility_mode = compatibility_mode @negotiator = negotiator || DefaultNegotiator end |
Class Method Details
.create_session(session_type) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/openid/consumer/associationmanager.rb', line 94 def self.create_session(session_type) case session_type when "no-encryption" NoEncryptionSession.new when "DH-SHA1" DiffieHellmanSHA1Session.new when "DH-SHA256" DiffieHellmanSHA256Session.new else raise ArgumentError, "Unknown association session type: " \ "#{session_type.inspect}" end end |
Instance Method Details
#get_association ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/openid/consumer/associationmanager.rb', line 116 def get_association return if @store.nil? assoc = @store.get_association(@server_url) if assoc.nil? || assoc.expires_in <= 0 assoc = negotiate_association @store.store_association(@server_url, assoc) unless assoc.nil? end assoc end |
#negotiate_association ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/openid/consumer/associationmanager.rb', line 128 def negotiate_association assoc_type, session_type = @negotiator.get_allowed_type begin request_association(assoc_type, session_type) rescue ServerError => e supported_types = extract_supported_association_type(e, assoc_type) unless supported_types.nil? # Attempt to create an association from the assoc_type and # session_type that the server told us it supported. assoc_type, session_type = supported_types begin request_association(assoc_type, session_type) rescue ServerError Util.log("Server #{@server_url} refused its suggested " \ "association type: session_type=#{session_type}, " \ "assoc_type=#{assoc_type}") nil end end rescue InvalidOpenIDNamespace Util.log("Server #{@server_url} returned a malformed association " \ "response. Falling back to check_id mode for this request.") nil end end |