Class: OpenID::AX::FetchResponse
- Inherits:
-
KeyValueMessage
- Object
- Extension
- AXMessage
- KeyValueMessage
- OpenID::AX::FetchResponse
- Defined in:
- lib/openid/extensions/ax.rb
Overview
A fetch_response attribute exchange message
Constant Summary
Constants inherited from AXMessage
Instance Attribute Summary collapse
-
#aliases ⇒ Object
Use the aliases variable to manually add alias names in the response.
-
#update_url ⇒ Object
readonly
Returns the value of attribute update_url.
Attributes inherited from KeyValueMessage
Attributes inherited from AXMessage
Class Method Summary collapse
-
.from_success_response(success_response, signed = true) ⇒ Object
Construct a FetchResponse object from an OpenID library SuccessResponse object.
Instance Method Summary collapse
-
#get_extension_args(request = nil) ⇒ Object
Serialize this object into arguments in the attribute exchange namespace Takes an optional FetchRequest.
-
#initialize(update_url = nil) ⇒ FetchResponse
constructor
A new instance of FetchResponse.
- #parse_extension_args(ax_args) ⇒ Object
Methods inherited from KeyValueMessage
#[], #_get_extension_kv_args, #add_value, #count, #get, #get_single, #set_values
Methods inherited from Extension
Constructor Details
#initialize(update_url = nil) ⇒ FetchResponse
Returns a new instance of FetchResponse.
405 406 407 408 409 410 |
# File 'lib/openid/extensions/ax.rb', line 405 def initialize(update_url = nil) super() @mode = 'fetch_response' @update_url = update_url @aliases = NamespaceMap.new end |
Instance Attribute Details
#aliases ⇒ Object
Use the aliases variable to manually add alias names in the response. They’ll be returned to the client in the format:
openid.ax.type.email=http://openid.net/schema/contact/internet/email
openid.ax.value.email=guy@example.com
403 404 405 |
# File 'lib/openid/extensions/ax.rb', line 403 def aliases @aliases end |
#update_url ⇒ Object (readonly)
Returns the value of attribute update_url.
398 399 400 |
# File 'lib/openid/extensions/ax.rb', line 398 def update_url @update_url end |
Class Method Details
.from_success_response(success_response, signed = true) ⇒ Object
Construct a FetchResponse object from an OpenID library SuccessResponse object.
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
# File 'lib/openid/extensions/ax.rb', line 474 def self.from_success_response(success_response, signed=true) obj = self.new if signed ax_args = success_response.get_signed_ns(obj.ns_uri) else ax_args = success_response..get_args(obj.ns_uri) end begin obj.parse_extension_args(ax_args) return obj rescue Error return nil end end |
Instance Method Details
#get_extension_args(request = nil) ⇒ Object
Serialize this object into arguments in the attribute exchange namespace Takes an optional FetchRequest. If specified, the response will be validated against this request, and empty responses for requested fields with no data will be sent.
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
# File 'lib/openid/extensions/ax.rb', line 417 def get_extension_args(request = nil) zero_value_types = [] if request # Validate the data in the context of the request (the # same attributes should be present in each, and the # counts in the response must be no more than the counts # in the request) @data.keys.each{|type_uri| unless request.member? type_uri raise IndexError, "Response attribute not present in request: #{type_uri.inspect}" end } request.attributes.each{|attr_info| # Copy the aliases from the request so that reading # the response in light of the request is easier if attr_info.ns_alias.nil? @aliases.add(attr_info.type_uri) else @aliases.add_alias(attr_info.type_uri, attr_info.ns_alias) end values = @data[attr_info.type_uri] if values.empty? # @data defaults to [] zero_value_types << attr_info end if attr_info.count != UNLIMITED_VALUES and attr_info.count < values.size raise Error, "More than the number of requested values were specified for #{attr_info.type_uri.inspect}" end } end kv_args = _get_extension_kv_args(@aliases) # Add the KV args into the response with the args that are # unique to the fetch_response ax_args = new_args zero_value_types.each{|attr_info| name = @aliases.get_alias(attr_info.type_uri) kv_args['type.' + name] = attr_info.type_uri kv_args['count.' + name] = '0' } update_url = (request and request.update_url or @update_url) ax_args['update_url'] = update_url unless update_url.nil? ax_args.update(kv_args) return ax_args end |
#parse_extension_args(ax_args) ⇒ Object
467 468 469 470 |
# File 'lib/openid/extensions/ax.rb', line 467 def parse_extension_args(ax_args) super @update_url = ax_args['update_url'] end |