Class: OpenID::Consumer::DiscoveryManager

### Home Classes Methods

### In Files

- lib/openid/consumer/discovery_manager.rb

### Parent

Object

### Methods

- ::new
- #cleanup
- #create_manager
- #destroy!
- #destroy_manager
- #get_manager
- #get_next_service
- #load
- #session_key
- #store

### 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::Consumer::DiscoveryManager

Manages calling discovery and tracking which endpoints have already been attempted.

### Public Class Methods

new(session, url, session_key_suffix=nil) click to toggle source

    # File lib/openid/consumer/discovery_manager.rb, line 63
    def initialize(session, url, session_key_suffix=nil)
      @url = url

      @session = OpenID::Consumer::Session.new(session, DiscoveredServices)
      @session_key_suffix = session_key_suffix || 'auth'
    end

### Public Instance Methods

cleanup(force=false) click to toggle source

    # File lib/openid/consumer/discovery_manager.rb, line 92
    def cleanup(force=false)
      manager = get_manager(force)
      if !manager.nil?
        service = manager.current
        destroy_manager(force)
      else
        service = nil
      end
      return service
    end

get_next_service() click to toggle source

    # File lib/openid/consumer/discovery_manager.rb, line 70
    def get_next_service
      manager = get_manager
      if !manager.nil? && manager.empty?
        destroy_manager
        manager = nil
      end

      if manager.nil?
        yadis_url, services = yield @url
        manager = create_manager(yadis_url, services)
      end

      if !manager.nil?
        service = manager.next
        store(manager)
      else
        service = nil
      end

      return service
    end

### Protected Instance Methods

create_manager(yadis_url, services) click to toggle source

    # File lib/openid/consumer/discovery_manager.rb, line 114
    def create_manager(yadis_url, services)
      manager = get_manager
      if !manager.nil?
        raise StandardError, "There is already a manager for #{yadis_url}"
      end
      if services.empty?
        return nil
      end
      manager = DiscoveredServices.new(@url, yadis_url, services)
      store(manager)
      return manager
    end

destroy!() click to toggle source

    # File lib/openid/consumer/discovery_manager.rb, line 145
    def destroy!
      @session[session_key] = nil
    end

destroy_manager(force=false) click to toggle source

    # File lib/openid/consumer/discovery_manager.rb, line 127
    def destroy_manager(force=false)
      if !get_manager(force).nil?
        destroy!
      end
    end

get_manager(force=false) click to toggle source

    # File lib/openid/consumer/discovery_manager.rb, line 105
    def get_manager(force=false)
      manager = load
      if force || manager.nil? || manager.for_url?(@url)
        return manager
      else
        return nil
      end
    end

load() click to toggle source

    # File lib/openid/consumer/discovery_manager.rb, line 141
    def load
      @session[session_key]
    end

session_key() click to toggle source

    # File lib/openid/consumer/discovery_manager.rb, line 133
    def session_key
      'OpenID::Consumer::DiscoveredServices::' + @session_key_suffix
    end

store(manager) click to toggle source

    # File lib/openid/consumer/discovery_manager.rb, line 137
    def store(manager)
      @session[session_key] = manager
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.