Class: OpenID::Server::Server

### Home Classes Methods

### In Files

- lib/openid/server.rb

### Parent

Object

### Methods

- ::new
- #decode_request
- #encode_response
- #handle_request
- #openid_associate
- #openid_check_authentication

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

I handle requests for an OpenID server.

Some types of requests (those which are not checkid requests) may be handed to my handleRequest method, and I will take care of it and return a response.

For your convenience, I also provide an interface to Decoder.decode and SigningEncoder.encode through my methods decodeRequest and encodeResponse.

All my state is encapsulated in an store, which means I'm not generally pickleable but I am easy to reconstruct.

### Attributes

decoder[RW]

I'm using this to decode things.

encoder[RW]

I'm using this to encode things.

negotiator[RW]

I use this instance of OpenID::AssociationNegotiator to determine which kinds of associations I can make and how.

op_endpoint[RW]

My URL.

signatory[RW]

I'm using this for associate requests and to sign things.

store[RW]

The back-end where my associations and nonces are stored.

### Public Class Methods

new(store, op_endpoint) click to toggle source

op_endpoint is new in library version 2.0.

    # File lib/openid/server.rb, line 1314
    def initialize(store, op_endpoint)
      @store = store
      @signatory = @@signatoryClass.new(@store)
      @encoder = @@encoderClass.new(@signatory)
      @decoder = @@decoderClass.new(self)
      @negotiator = DefaultNegotiator.copy()
      @op_endpoint = op_endpoint
    end

### Public Instance Methods

decode_request(query) click to toggle source

Transform query parameters into an OpenIDRequest. query should contain the query parameters as a Hash with each key mapping to one value.

If the query does not seem to be an OpenID request at all, I return nil.

    # File lib/openid/server.rb, line 1370
    def decode_request(query)
      return @decoder.decode(query)
    end

encode_response(response) click to toggle source

Encode a response to a WebResponse, signing it first if appropriate.

Raises EncodingError when I can't figure out how to encode this message.

Raises AlreadySigned When this response is already signed.

    # File lib/openid/server.rb, line 1381
    def encode_response(response)
      return @encoder.encode(response)
    end

handle_request(request) click to toggle source

Handle a request.

Give me a request, I will give you a response. Unless it's a type of request I cannot handle myself, in which case I will raise RuntimeError. In that case, you can handle it yourself, or add a method to me for handling that request type.

    # File lib/openid/server.rb, line 1329
    def handle_request(request)
      begin
        handler = self.method('openid_' + request.mode)
      rescue NameError
        raise RuntimeError.new(
          sprintf("%s has no handler for a request of mode %s.",
                  self, request.mode))
      end

      return handler.call(request)
    end

openid_associate(request) click to toggle source

Handle and respond to associate requests.

    # File lib/openid/server.rb, line 1347
    def openid_associate(request)
      assoc_type = request.assoc_type
      session_type = request.session.session_type
      if @negotiator.allowed?(assoc_type, session_type)
        assoc = @signatory.create_association(false,
                                              assoc_type)
        return request.answer(assoc)
      else
        message = sprintf('Association type %s is not supported with ' +
                          'session type %s', assoc_type, session_type)
        preferred_assoc_type, preferred_session_type = @negotiator.get_allowed_type()
        return request.answer_unsupported(message,
                                          preferred_assoc_type,
                                          preferred_session_type)
      end
    end

openid_check_authentication(request) click to toggle source

Handle and respond to check_authentication requests.

    # File lib/openid/server.rb, line 1342
    def openid_check_authentication(request)
      return request.answer(@signatory)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.