class OpenID::AssociationNegotiator

Attributes

allowed_types[R]

Public Class Methods

check_session_type(assoc_type, session_type) click to toggle source
# File lib/openid/association.rb, line 197
def self.check_session_type(assoc_type, session_type)
  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
end
get_session_types(assoc_type) click to toggle source
# File lib/openid/association.rb, line 186
def self.get_session_types(assoc_type)
  case assoc_type
  when 'HMAC-SHA1'
    ['DH-SHA1', 'no-encryption']
  when 'HMAC-SHA256'
    ['DH-SHA256', 'no-encryption']
  else
    raise ProtocolError, "Unknown association type #{assoc_type.inspect}"
  end
end
new(allowed_types) click to toggle source
# File lib/openid/association.rb, line 204
def initialize(allowed_types)
  self.allowed_types=(allowed_types)
end

Public Instance Methods

add_allowed_type(assoc_type, session_type=nil) click to toggle source
# File lib/openid/association.rb, line 219
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) click to toggle source
# File lib/openid/association.rb, line 231
def allowed?(assoc_type, session_type)
  @allowed_types.include?([assoc_type, session_type])
end
allowed_types=(allowed_types) click to toggle source
# File lib/openid/association.rb, line 212
def allowed_types=(allowed_types)
  allowed_types.each do |assoc_type, session_type|
    self.class.check_session_type(assoc_type, session_type)
  end
  @allowed_types = allowed_types
end
copy() click to toggle source
# File lib/openid/association.rb, line 208
def copy
  Marshal.load(Marshal.dump(self))
end
get_allowed_type() click to toggle source
# File lib/openid/association.rb, line 235
def get_allowed_type
  @allowed_types.empty? ? nil : @allowed_types[0]
end