Class: OpenID::AssociationNegotiator
- Inherits:
-
Object
- Object
- OpenID::AssociationNegotiator
- Defined in:
- lib/openid/association.rb
Instance Attribute Summary collapse
-
#allowed_types ⇒ Object
Returns the value of attribute allowed_types.
Class Method Summary collapse
Instance Method Summary collapse
- #add_allowed_type(assoc_type, session_type = nil) ⇒ Object
- #allowed?(assoc_type, session_type) ⇒ Boolean
- #copy ⇒ Object
- #get_allowed_type ⇒ Object
-
#initialize(allowed_types) ⇒ AssociationNegotiator
constructor
A new instance of AssociationNegotiator.
Constructor Details
#initialize(allowed_types) ⇒ AssociationNegotiator
Returns a new instance of AssociationNegotiator.
197 198 199 |
# File 'lib/openid/association.rb', line 197 def initialize(allowed_types) self.allowed_types = (allowed_types) end |
Instance Attribute Details
#allowed_types ⇒ Object
Returns the value of attribute allowed_types.
177 178 179 |
# File 'lib/openid/association.rb', line 177 def allowed_types @allowed_types end |
Class Method Details
.check_session_type(assoc_type, session_type) ⇒ Object
190 191 192 193 194 195 |
# File 'lib/openid/association.rb', line 190 def self.check_session_type(assoc_type, session_type) return if get_session_types(assoc_type).include?(session_type) raise ProtocolError, "Session type #{session_type.inspect} not " \ "valid for association type #{assoc_type.inspect}" end |
.get_session_types(assoc_type) ⇒ Object
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/openid/association.rb', line 179 def self.get_session_types(assoc_type) case assoc_type when "HMAC-SHA1" %w[DH-SHA1 no-encryption] when "HMAC-SHA256" %w[DH-SHA256 no-encryption] else raise ProtocolError, "Unknown association type #{assoc_type.inspect}" end end |
Instance Method Details
#add_allowed_type(assoc_type, session_type = nil) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/openid/association.rb', line 212 def add_allowed_type(assoc_type, session_type = nil) if session_type.nil? session_types = self.class.get_session_types(assoc_type) else self.class.check_session_type(assoc_type, session_type) session_types = [session_type] end for session_type in session_types do @allowed_types << [assoc_type, session_type] end end |
#allowed?(assoc_type, session_type) ⇒ Boolean
224 225 226 |
# File 'lib/openid/association.rb', line 224 def allowed?(assoc_type, session_type) @allowed_types.include?([assoc_type, session_type]) end |
#copy ⇒ Object
201 202 203 |
# File 'lib/openid/association.rb', line 201 def copy Marshal.load(Marshal.dump(self)) end |
#get_allowed_type ⇒ Object
228 229 230 |
# File 'lib/openid/association.rb', line 228 def get_allowed_type @allowed_types.empty? ? nil : @allowed_types[0] end |