Class: OpenID::Yadis::XRI::ProxyResolver

### Home Classes Methods

### In Files

- lib/openid/yadis/xrires.rb

### Parent

Object

### Methods

- ::new
- #query
- #query_url

### 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::Yadis::XRI::ProxyResolver

### Constants

DEFAULT_PROXY

### Public Class Methods

new(proxy_url=nil) click to toggle source

    # File lib/openid/yadis/xrires.rb, line 18
    def initialize(proxy_url=nil)
      if proxy_url
        @proxy_url = proxy_url
      else
        @proxy_url = DEFAULT_PROXY
      end

      @proxy_url += '/' unless @proxy_url.match('/$')
    end

### Public Instance Methods

query(xri) click to toggle source

    # File lib/openid/yadis/xrires.rb, line 45
    def query(xri)
      # these can be query args or http headers, needn't be both.
      # headers = {'Accept' => 'application/xrds+xml;sep=true'}
      canonicalID = nil

      url = self.query_url(xri)
        begin
          response = OpenID.fetch(url)
        rescue
          raise XRIHTTPError, "Could not fetch #{xri}, #{$!}"
        end
        raise XRIHTTPError, "Could not fetch #{xri}" if response.nil?

        xrds = Yadis::parseXRDS(response.body)
        canonicalID = Yadis::get_canonical_id(xri, xrds)

      return canonicalID, Yadis::services(xrds)
      # TODO:
      #  * If we do get hits for multiple service_types, we're almost
      #    certainly going to have duplicated service entries and
      #    broken priority ordering.
    end

query_url(xri, service_type=nil) click to toggle source

    # File lib/openid/yadis/xrires.rb, line 28
    def query_url(xri, service_type=nil)
      # URI normal form has a leading xri://, but we need to strip
      # that off again for the QXRI.  This is under discussion for
      # XRI Resolution WD 11.
      qxri = XRI.to_uri_normal(xri)[6..-1]
      hxri = @proxy_url + qxri
      args = {'_xrd_r' => 'application/xrds+xml'}
      if service_type
        args['_xrd_t'] = service_type
      else
        # don't perform service endpoint selection
        args['_xrd_r'] += ';sep=false'
      end

      return XRI.append_args(hxri, args)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.