class OpenID::Server::OpenIDResponse
I am a response to an OpenID request.
Attributes:
- signed
-
A list of the names of the fields which should be signed.
Implementer's note: In a more symmetric client/server implementation, there would be more types of #OpenIDResponse object and they would have validated attributes according to the type of response. But as it is, Response objects in a server are basically write-only, their only job is to go out over the wire, so this is just a loose wrapper around #OpenIDResponse.fields.
Attributes
An #OpenID::Message with the data to be returned. Keys are parameter names with no leading openid. e.g. identity and mac_key never openid.identity.
The #OpenIDRequest I respond to.
Public Class Methods
# File lib/openid/server.rb, line 860 def initialize(request) # Make a response to an OpenIDRequest. @request = request @fields = Message.new(request.namespace) end
Public Instance Methods
# File lib/openid/server.rb, line 922 def add_extension(extension_response) # Add an extension response to this response message. # # extension_response:: An object that implements the # #OpenID::Extension interface for adding arguments to an OpenID # message. extension_response.to_message(@fields) end
# File lib/openid/server.rb, line 943 def copy return Marshal.load(Marshal.dump(self)) end
# File lib/openid/server.rb, line 931 def encode_to_kvform # Encode a response in key-value colon/newline format. # # This is a machine-readable format used to respond to # messages which came directly from the consumer and not # through the user agent. # # see: OpenID Specs, # <a href="http://openid.net/specs.bml#keyvalue">Key-Value Colon/Newline format</a> return @fields.to_kvform end
# File lib/openid/server.rb, line 916 def encode_to_url # Encode a response as a URL for the user agent to GET. # You will generally use this URL with a HTTP redirect. return @fields.to_url(@request.return_to) end
# File lib/openid/server.rb, line 894 def needs_signing # Does this response require signing? return @fields.get_arg(OPENID_NS, 'mode') == 'id_res' end
# File lib/openid/server.rb, line 888 def render_as_form # Returns true if this response's encoding is # ENCODE_HTML_FORM. Convenience method for server authors. return self.which_encoding == ENCODE_HTML_FORM end
form_tag_attrs is a hash of attributes to be added to the form tag. 'accept-charset' and 'enctype' have defaults that can be overridden. If a value is supplied for 'action' or 'method', it will be replaced.
Returns the form markup for this response.
# File lib/openid/server.rb, line 878 def to_form_markup(form_tag_attrs=nil) return @fields.to_form_markup(@request.return_to, form_tag_attrs) end
Wraps the form tag from #to_form_markup in a complete HTML document that uses javascript to autosubmit the form.
# File lib/openid/server.rb, line 884 def to_html(form_tag_attrs=nil) return Util.auto_submit_html(to_form_markup(form_tag_attrs)) end
# File lib/openid/server.rb, line 866 def to_s return sprintf("%s for %s: %s", self.class, @request.class, @fields) end
implements IEncodable
# File lib/openid/server.rb, line 901 def which_encoding # How should I be encoded? # returns one of ENCODE_URL or ENCODE_KVFORM. if BROWSER_REQUEST_MODES.member?(@request.mode) if @fields.is_openid2 and encode_to_url.length > OPENID1_URL_LIMIT return ENCODE_HTML_FORM else return ENCODE_URL end else return ENCODE_KVFORM end end