Module: OpenID::Yadis::XRI

### Home Classes Methods

### In Files

- lib/openid/yadis/xri.rb
- lib/openid/yadis/xrires.rb

### Namespace

- CLASS OpenID::Yadis::XRI::ProxyResolver
- CLASS OpenID::Yadis::XRI::XRIHTTPError

### Methods

- ::append_args
- ::escape_for_iri
- ::identifier_scheme
- ::iri_to_uri
- ::make_xri
- ::provider_is_authoritative
- ::root_authority
- ::to_iri_normal
- ::to_uri_normal
- ::urlencode

### 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

### Constants

XRI_AUTHORITIES

  The '(' is for cross-reference authorities, and hopefully has a matching ')' somewhere.

### Public Class Methods

append_args(url, args) click to toggle source

    # File lib/openid/yadis/xrires.rb, line 77
    def self.append_args(url, args)
      return url if args.length == 0

      # rstrip question marks
      rstripped = url.dup
      while rstripped[-1].chr == '?'
        rstripped = rstripped[0...rstripped.length-1]
      end

      if rstripped.index('?')
        sep = '&'
      else
        sep = '?'
      end

      return url + sep + XRI.urlencode(args)
    end

escape_for_iri(xri) click to toggle source

Note this is not not idempotent, so do not apply this more than once. XRI Syntax section 2.3.2

    # File lib/openid/yadis/xri.rb, line 34
    def self.escape_for_iri(xri)
      esc = xri.dup
      # encode all %
      esc.gsub!(/%/, '%25')
      esc.gsub!(/\((.*?)\)/) { |xref_match|
        xref_match.gsub(/[\/\?\#]/) { |char_match|
          CGI::escape(char_match)
        }
      }
      return esc
    end

identifier_scheme(identifier) click to toggle source

    # File lib/openid/yadis/xri.rb, line 12
    def self.identifier_scheme(identifier)
      if (!identifier.nil? and
          identifier.length > 0 and
          (identifier.match('^xri://') or
           XRI_AUTHORITIES.member?(identifier[0].chr)))
        return :xri
      else
        return :uri
      end
    end

iri_to_uri(iri) click to toggle source

RFC 3987 section 3.1

    # File lib/openid/yadis/xri.rb, line 54
    def self.iri_to_uri(iri)
      uri = iri.dup
      # for char in ucschar or iprivate
      # convert each char to %HH%HH%HH (as many %HH as octets)
      return uri
    end

make_xri(xri) click to toggle source

    # File lib/openid/yadis/xri.rb, line 82
    def self.make_xri(xri)
      if xri.index('xri://') != 0
        xri = 'xri://' + xri
      end
      return xri
    end

provider_is_authoritative(provider_id, canonical_id) click to toggle source

    # File lib/openid/yadis/xri.rb, line 61
    def self.provider_is_authoritative(provider_id, canonical_id)
      lastbang = canonical_id.rindex('!')
      return false unless lastbang
      parent = canonical_id[0...lastbang]
      return parent == provider_id
    end

root_authority(xri) click to toggle source

    # File lib/openid/yadis/xri.rb, line 68
    def self.root_authority(xri)
      xri = xri[6..-1] if xri.index('xri://') == 0
      authority = xri.split('/', 2)[0]
      if authority[0].chr == '('
        root = authority[0...authority.index(')')+1]
      elsif XRI_AUTHORITIES.member?(authority[0].chr)
        root = authority[0].chr
      else
        root = authority.split(/[!*]/)[0]
      end

      self.make_xri(root)
    end

to_iri_normal(xri) click to toggle source

Transform an XRI reference to an IRI reference. Note this is not not idempotent, so do not apply this to an identifier more than once. XRI Syntax section 2.3.1

    # File lib/openid/yadis/xri.rb, line 26
    def self.to_iri_normal(xri)
      iri = xri.dup
      iri.insert(0, 'xri://') if not iri.match('^xri://')
      return escape_for_iri(iri)
    end

to_uri_normal(xri) click to toggle source

Transform an XRI reference to a URI reference. Note this is not not idempotent, so do not apply this to an identifier more than once. XRI Syntax section 2.3.1

    # File lib/openid/yadis/xri.rb, line 49
    def self.to_uri_normal(xri)
      return iri_to_uri(to_iri_normal(xri))
    end

urlencode(args) click to toggle source

    # File lib/openid/yadis/xrires.rb, line 69
    def self.urlencode(args)
      a = []
      args.each do |key, val|
        a << (CGI::escape(key) + "=" + CGI::escape(val))
      end
      a.join("&")
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.