Class: OpenID::Server::OpenIDResponse
- Inherits:
-
Object
- Object
- OpenID::Server::OpenIDResponse
- Defined in:
- lib/openid/server.rb
Overview
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.
Instance Attribute Summary collapse
-
#fields ⇒ Object
An #OpenID::Message with the data to be returned.
-
#request ⇒ Object
The #OpenIDRequest I respond to.
Instance Method Summary collapse
- #add_extension(extension_response) ⇒ Object
- #copy ⇒ Object
- #encode_to_kvform ⇒ Object
- #encode_to_url ⇒ Object
-
#initialize(request) ⇒ OpenIDResponse
constructor
A new instance of OpenIDResponse.
- #needs_signing ⇒ Object
- #render_as_form ⇒ Object
-
#to_form_markup(form_tag_attrs = nil) ⇒ Object
form_tag_attrs is a hash of attributes to be added to the form tag.
-
#to_html(form_tag_attrs = nil) ⇒ Object
Wraps the form tag from to_form_markup in a complete HTML document that uses javascript to autosubmit the form.
- #to_s ⇒ Object
-
#which_encoding ⇒ Object
implements IEncodable.
Constructor Details
#initialize(request) ⇒ OpenIDResponse
Returns a new instance of OpenIDResponse.
878 879 880 881 882 |
# File 'lib/openid/server.rb', line 878 def initialize(request) # Make a response to an OpenIDRequest. @request = request @fields = Message.new(request.namespace) end |
Instance Attribute Details
#fields ⇒ Object
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.
876 877 878 |
# File 'lib/openid/server.rb', line 876 def fields @fields end |
#request ⇒ Object
The #OpenIDRequest I respond to.
870 871 872 |
# File 'lib/openid/server.rb', line 870 def request @request end |
Instance Method Details
#add_extension(extension_response) ⇒ Object
940 941 942 943 944 945 946 947 |
# File 'lib/openid/server.rb', line 940 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.(@fields) end |
#copy ⇒ Object
961 962 963 |
# File 'lib/openid/server.rb', line 961 def copy Marshal.load(Marshal.dump(self)) end |
#encode_to_kvform ⇒ Object
949 950 951 952 953 954 955 956 957 958 959 |
# File 'lib/openid/server.rb', line 949 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> @fields.to_kvform end |
#encode_to_url ⇒ Object
934 935 936 937 938 |
# File 'lib/openid/server.rb', line 934 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. @fields.to_url(@request.return_to) end |
#needs_signing ⇒ Object
914 915 916 917 |
# File 'lib/openid/server.rb', line 914 def needs_signing # Does this response require signing? @fields.get_arg(OPENID_NS, "mode") == "id_res" end |
#render_as_form ⇒ Object
908 909 910 911 912 |
# File 'lib/openid/server.rb', line 908 def render_as_form # Returns true if this response's encoding is # ENCODE_HTML_FORM. Convenience method for server authors. which_encoding == ENCODE_HTML_FORM end |
#to_form_markup(form_tag_attrs = nil) ⇒ Object
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.
898 899 900 |
# File 'lib/openid/server.rb', line 898 def to_form_markup(form_tag_attrs = nil) @fields.to_form_markup(@request.return_to, form_tag_attrs) end |
#to_html(form_tag_attrs = nil) ⇒ Object
Wraps the form tag from to_form_markup in a complete HTML document that uses javascript to autosubmit the form.
904 905 906 |
# File 'lib/openid/server.rb', line 904 def to_html(form_tag_attrs = nil) Util.auto_submit_html(to_form_markup(form_tag_attrs)) end |
#to_s ⇒ Object
884 885 886 887 888 889 890 891 |
# File 'lib/openid/server.rb', line 884 def to_s format( "%s for %s: %s", self.class, @request.class, @fields, ) end |
#which_encoding ⇒ Object
implements IEncodable
921 922 923 924 925 926 927 928 929 930 931 932 |
# File 'lib/openid/server.rb', line 921 def which_encoding # How should I be encoded? # returns one of ENCODE_URL or ENCODE_KVFORM. return ENCODE_KVFORM unless BROWSER_REQUEST_MODES.member?(@request.mode) if @fields.is_openid2 and encode_to_url.length > OPENID1_URL_LIMIT ENCODE_HTML_FORM else ENCODE_URL end end |