class OpenID::PAPE::Request

A Provider Authentication Policy request, sent from a relying party to a provider

Attributes

max_auth_age[RW]
ns_alias[RW]
ns_uri[RW]
preferred_auth_policies[RW]

Public Class Methods

from_openid_request(oid_req) click to toggle source

Instantiate a Request object from the arguments in a checkid_* OpenID message return nil if the extension was not requested.

# File lib/openid/extensions/pape.rb, line 49
def self.from_openid_request(oid_req)
  pape_req = new
  args = oid_req.message.get_args(NS_URI)
  if args == {}
    return nil
  end
  pape_req.parse_extension_args(args)
  return pape_req
end
new(preferred_auth_policies=[], max_auth_age=nil) click to toggle source
# File lib/openid/extensions/pape.rb, line 22
def initialize(preferred_auth_policies=[], max_auth_age=nil)
  @ns_alias = 'pape'
  @ns_uri = NS_URI
  @preferred_auth_policies = preferred_auth_policies
  @max_auth_age = max_auth_age
end

Public Instance Methods

add_policy_uri(policy_uri) click to toggle source

Add an acceptable authentication policy URI to this request This method is intended to be used by the relying party to add acceptable authentication types to the request.

# File lib/openid/extensions/pape.rb, line 32
def add_policy_uri(policy_uri)
  unless @preferred_auth_policies.member? policy_uri
    @preferred_auth_policies << policy_uri
  end
end
get_extension_args() click to toggle source
# File lib/openid/extensions/pape.rb, line 38
def get_extension_args
  ns_args = {
    'preferred_auth_policies' => @preferred_auth_policies.join(' ')
  }
  ns_args['max_auth_age'] = @max_auth_age.to_s if @max_auth_age
  return ns_args
end
parse_extension_args(args) click to toggle source

Set the state of this request to be that expressed in these PAPE arguments

# File lib/openid/extensions/pape.rb, line 61
def parse_extension_args(args)
  @preferred_auth_policies = []
  policies_str = args['preferred_auth_policies']
  if policies_str
    policies_str.split(' ').each{|uri|
      add_policy_uri(uri)
    }
  end

  max_auth_age_str = args['max_auth_age']
  if max_auth_age_str
    @max_auth_age = max_auth_age_str.to_i
  else
    @max_auth_age = nil
  end
end
preferred_types(supported_types) click to toggle source

Given a list of authentication policy URIs that a provider supports, this method returns the subset of those types that are preferred by the relying party.

# File lib/openid/extensions/pape.rb, line 81
def preferred_types(supported_types)
  @preferred_auth_policies.select{|uri| supported_types.member? uri}
end