Class: OpenID::AX::FetchResponse

### Home Classes Methods

### In Files

- lib/openid/extensions/ax.rb

### Parent

OpenID::AX::KeyValueMessage

### Methods

- ::from_success_response
- ::new
- #get_extension_args
- #parse_extension_args

### Files

- LICENSE

### Class/Module Index

Quicksearch

- OpenID
- OpenID::AX
- OpenID::AX::AXMessage
- OpenID::AX::AttrInfo
- OpenID::AX::Error
- OpenID::AX::FetchRequest
- OpenID::AX::FetchResponse
- OpenID::AX::KeyValueMessage
- OpenID::AX::StoreRequest
- OpenID::AX::StoreResponse
- OpenID::AssertionError
- OpenID::Association
- OpenID::AssociationNegotiator
- OpenID::Consumer
- OpenID::Consumer::AssociationManager
- OpenID::Consumer::CancelResponse
- OpenID::Consumer::CheckIDRequest
- OpenID::Consumer::DiffieHellmanSHA1Session
- OpenID::Consumer::DiffieHellmanSHA256Session
- OpenID::Consumer::DiffieHellmanSession
- OpenID::Consumer::DiscoveredServices
- OpenID::Consumer::DiscoveryManager
- OpenID::Consumer::FailureResponse
- OpenID::Consumer::IdResHandler
- OpenID::Consumer::NoEncryptionSession
- OpenID::Consumer::Response
- OpenID::Consumer::Session
- OpenID::Consumer::SetupNeededResponse
- OpenID::Consumer::SuccessResponse
- OpenID::CryptUtil
- OpenID::DiffieHellman
- OpenID::DiscoveryFailure
- OpenID::Extension
- OpenID::FetchingError
- OpenID::HTTPRedirectLimitReached
- OpenID::HTTPResponse
- OpenID::HTTPStatusError
- OpenID::InvalidOpenIDNamespace
- OpenID::KVFormError
- OpenID::KVPostNetworkError
- OpenID::Message
- OpenID::Message::KeyNotFound
- OpenID::NamespaceAliasRegistrationError
- OpenID::NamespaceMap
- OpenID::Nonce
- OpenID::OAuth
- OpenID::OAuth::Request
- OpenID::OAuth::Response
- OpenID::OpenIDError
- OpenID::OpenIDServiceEndpoint
- OpenID::PAPE
- OpenID::PAPE::Request
- OpenID::PAPE::Response
- OpenID::ProtocolError
- OpenID::RealmVerificationRedirected
- OpenID::SReg
- OpenID::SReg::NamespaceError
- OpenID::SReg::Request
- OpenID::SReg::Response
- OpenID::SSLFetchingError
- OpenID::Server
- OpenID::Server::AlreadySigned
- OpenID::Server::AssociateRequest
- OpenID::Server::BaseServerSession
- OpenID::Server::CheckAuthRequest
- OpenID::Server::CheckIDRequest
- OpenID::Server::Decoder
- OpenID::Server::DiffieHellmanSHA1ServerSession
- OpenID::Server::DiffieHellmanSHA256ServerSession
- OpenID::Server::Encoder
- OpenID::Server::EncodingError
- OpenID::Server::MalformedReturnURL
- OpenID::Server::MalformedTrustRoot
- OpenID::Server::NoReturnToError
- OpenID::Server::OpenIDRequest
- OpenID::Server::OpenIDResponse
- OpenID::Server::PlainTextServerSession
- OpenID::Server::ProtocolError
- OpenID::Server::Server
- OpenID::Server::Signatory
- OpenID::Server::SigningEncoder
- OpenID::Server::UntrustedReturnURL
- OpenID::Server::VersionError
- OpenID::Server::WebResponse
- OpenID::ServerError
- OpenID::StandardFetcher
- OpenID::Store
- OpenID::Store::Filesystem
- OpenID::Store::Interface
- OpenID::Store::Memcache
- OpenID::Store::Memory
- OpenID::TrustRoot
- OpenID::TrustRoot::TrustRoot
- OpenID::TypeURIMismatch
- OpenID::UI
- OpenID::UI::Request
- OpenID::URINorm
- OpenID::UndefinedOpenIDNamespace
- OpenID::Util
- OpenID::Yadis
- OpenID::Yadis::BasicServiceEndpoint
- OpenID::Yadis::CompoundFilter
- OpenID::Yadis::DiscoveryResult
- OpenID::Yadis::TransformFilterMaker
- OpenID::Yadis::XRDSError
- OpenID::Yadis::XRDSFraud
- OpenID::Yadis::XRI
- OpenID::Yadis::XRI::ProxyResolver
- OpenID::Yadis::XRI::XRIHTTPError
- HMAC
- HMAC::Base
- HMAC::SHA1
- HMAC::SHA256
- HMAC::SHA384
- HMAC::SHA512
- Net
- Net::HTTP
- HTMLComment
- HTMLTag
- HTMLText
- HTMLToken
- HTMLTokenizer
- HTMLTokenizerError
- Object

No matching classes.

# OpenID::AX::FetchResponse

A fetch_response attribute exchange message

### Attributes

aliases[RW]

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

update_url[R]

### Public Class Methods

from_success_response(success_response, signed=true) click to toggle source

Construct a FetchResponse object from an OpenID library SuccessResponse object.

    # 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.message.get_args(obj.ns_uri)
      end

      begin
        obj.parse_extension_args(ax_args)
        return obj
      rescue Error
        return nil
      end
    end

new(update_url = nil) click to toggle source

    # 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

### Public Instance Methods

get_extension_args(request = nil) click to toggle source

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.

    # 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) click to toggle source

    # File lib/openid/extensions/ax.rb, line 467
    def parse_extension_args(ax_args)
      super
      @update_url = ax_args['update_url']
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.