net.oauth.server
Class OAuthServlet

java.lang.Object
  extended by net.oauth.server.OAuthServlet

public class OAuthServlet
extends java.lang.Object

Utility methods for servlets that implement OAuth.


Constructor Summary
OAuthServlet()
           
 
Method Summary
static net.oauth.OAuthMessage getMessage(HttpServletRequest request, java.lang.String URL)
          Extract the parts of the given request that are relevant to OAuth.
static java.lang.String getRequestURL(HttpServletRequest request)
          Reconstruct the requested URL, complete with query string (if any).
static void handleException(HttpServletResponse response, java.lang.Exception e, java.lang.String realm)
           
static void handleException(HttpServletResponse response, java.lang.Exception e, java.lang.String realm, boolean sendBody)
           
static java.lang.String htmlEncode(java.lang.String s)
          Return the HTML representation of the given plain text.
static void sendForm(HttpServletResponse response, java.lang.Iterable<? extends java.util.Map.Entry> parameters)
          Send the given parameters as a form-encoded response body.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OAuthServlet

public OAuthServlet()
Method Detail

getMessage

public static net.oauth.OAuthMessage getMessage(HttpServletRequest request,
                                                java.lang.String URL)
Extract the parts of the given request that are relevant to OAuth. Parameters include OAuth Authorization headers and the usual request parameters in the query string and/or form encoded body. The header parameters come first, followed by the rest in the order they came from request.getParameterMap().

Parameters:
URL - the official URL of this service; that is the URL a legitimate client would use to compute the digital signature. If this parameter is null, this method will try to reconstruct the URL from the HTTP request; which may be wrong in some cases.

getRequestURL

public static java.lang.String getRequestURL(HttpServletRequest request)
Reconstruct the requested URL, complete with query string (if any).


handleException

public static void handleException(HttpServletResponse response,
                                   java.lang.Exception e,
                                   java.lang.String realm)
                            throws java.io.IOException,
                                   ServletException
Throws:
java.io.IOException
ServletException

handleException

public static void handleException(HttpServletResponse response,
                                   java.lang.Exception e,
                                   java.lang.String realm,
                                   boolean sendBody)
                            throws java.io.IOException,
                                   ServletException
Throws:
java.io.IOException
ServletException

sendForm

public static void sendForm(HttpServletResponse response,
                            java.lang.Iterable<? extends java.util.Map.Entry> parameters)
                     throws java.io.IOException
Send the given parameters as a form-encoded response body.

Throws:
java.io.IOException

htmlEncode

public static java.lang.String htmlEncode(java.lang.String s)
Return the HTML representation of the given plain text. Characters that would have special significance in HTML are replaced by character entity references. Whitespace is not converted.