Package net.oauth.server
Class OAuthServlet
- java.lang.Object
-
- net.oauth.server.OAuthServlet
-
public class OAuthServlet extends Object
Utility methods for servlets that implement OAuth.- Author:
- John Kristian
-
-
Constructor Summary
Constructors Constructor Description OAuthServlet()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static OAuthMessagegetMessage(HttpServletRequest request, String URL)Extract the parts of the given request that are relevant to OAuth.static StringgetRequestURL(HttpServletRequest request)Reconstruct the requested URL, complete with query string (if any).static voidhandleException(HttpServletResponse response, Exception e, String realm)static voidhandleException(HttpServletResponse response, Exception e, String realm, boolean sendBody)static StringhtmlEncode(String s)Return the HTML representation of the given plain text.static voidsendForm(HttpServletResponse response, Iterable<? extends Map.Entry> parameters)Send the given parameters as a form-encoded response body.
-
-
-
Method Detail
-
getMessage
public static OAuthMessage getMessage(HttpServletRequest request, 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 String getRequestURL(HttpServletRequest request)
Reconstruct the requested URL, complete with query string (if any).
-
handleException
public static void handleException(HttpServletResponse response, Exception e, String realm) throws IOException, ServletException
- Throws:
IOExceptionServletException
-
handleException
public static void handleException(HttpServletResponse response, Exception e, String realm, boolean sendBody) throws IOException, ServletException
- Throws:
IOExceptionServletException
-
sendForm
public static void sendForm(HttpServletResponse response, Iterable<? extends Map.Entry> parameters) throws IOException
Send the given parameters as a form-encoded response body.- Throws:
IOException
-
htmlEncode
public static String htmlEncode(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.
-
-