Class: OpenID::PAPE::Request
- Defined in:
- lib/openid/extensions/pape.rb
Overview
A Provider Authentication Policy request, sent from a relying party to a provider
Instance Attribute Summary collapse
-
#max_auth_age ⇒ Object
Returns the value of attribute max_auth_age.
-
#ns_alias ⇒ Object
Returns the value of attribute ns_alias.
-
#ns_uri ⇒ Object
Returns the value of attribute ns_uri.
-
#preferred_auth_policies ⇒ Object
Returns the value of attribute preferred_auth_policies.
Class Method Summary collapse
-
.from_openid_request(oid_req) ⇒ Object
Instantiate a Request object from the arguments in a checkid_* OpenID message return nil if the extension was not requested.
Instance Method Summary collapse
-
#add_policy_uri(policy_uri) ⇒ Object
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.
- #get_extension_args ⇒ Object
-
#initialize(preferred_auth_policies = [], max_auth_age = nil) ⇒ Request
constructor
A new instance of Request.
-
#parse_extension_args(args) ⇒ Object
Set the state of this request to be that expressed in these PAPE arguments.
-
#preferred_types(supported_types) ⇒ Object
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.
Methods inherited from Extension
Constructor Details
#initialize(preferred_auth_policies = [], max_auth_age = nil) ⇒ Request
Returns a new instance of Request.
22 23 24 25 26 27 |
# 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 |
Instance Attribute Details
#max_auth_age ⇒ Object
Returns the value of attribute max_auth_age.
21 22 23 |
# File 'lib/openid/extensions/pape.rb', line 21 def max_auth_age @max_auth_age end |
#ns_alias ⇒ Object
Returns the value of attribute ns_alias.
21 22 23 |
# File 'lib/openid/extensions/pape.rb', line 21 def ns_alias @ns_alias end |
#ns_uri ⇒ Object
Returns the value of attribute ns_uri.
21 22 23 |
# File 'lib/openid/extensions/pape.rb', line 21 def ns_uri @ns_uri end |
#preferred_auth_policies ⇒ Object
Returns the value of attribute preferred_auth_policies.
21 22 23 |
# File 'lib/openid/extensions/pape.rb', line 21 def preferred_auth_policies @preferred_auth_policies end |
Class Method Details
.from_openid_request(oid_req) ⇒ Object
Instantiate a Request object from the arguments in a checkid_* OpenID message return nil if the extension was not requested.
49 50 51 52 53 54 55 56 57 |
# File 'lib/openid/extensions/pape.rb', line 49 def self.from_openid_request(oid_req) pape_req = new args = oid_req..get_args(NS_URI) if args == {} return nil end pape_req.parse_extension_args(args) return pape_req end |
Instance Method Details
#add_policy_uri(policy_uri) ⇒ Object
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.
32 33 34 35 36 |
# 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 ⇒ Object
38 39 40 41 42 43 44 |
# 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) ⇒ Object
Set the state of this request to be that expressed in these PAPE arguments
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# 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) ⇒ Object
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.
81 82 83 |
# File 'lib/openid/extensions/pape.rb', line 81 def preferred_types(supported_types) @preferred_auth_policies.select{|uri| supported_types.member? uri} end |