class 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 OpenID::Server::Decoder#decode and OpenID::Server::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
I'm using this to decode things.
I'm using this to encode things.
I use this instance of OpenID::AssociationNegotiator to determine which kinds of associations I can make and how.
My URL.
I'm using this for associate requests and to sign things.
The back-end where my associations and nonces are stored.
Public Class Methods
#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
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 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 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
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
Handle and respond to check_authentication requests.
# File lib/openid/server.rb, line 1342 def openid_check_authentication(request) return request.answer(@signatory) end