Class OAuthService
java.lang.Object
org.eclipse.lyo.server.oauth.webapp.services.OAuthService
Issues OAuth request tokens, handles authentication, and then exchanges
request tokens for access tokens based on the OAuth configuration set in the
OAuthConfiguration singleton.- Author:
- Samuel Padgett
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionResponds with a web page to log in.protected booleanconfirmCallback(OAuthRequest oAuthRequest) Responds with an access token and token secret for valid OAuth requests.Responds with a request token and token secret.Validates that the ID and password are for an administrator.Validates the ID and password on the authorization form.Generates a provisional consumer key.protected ResponserespondWithOAuthProblem(net.oauth.OAuthException e) protected ResponserespondWithToken(String token, String tokenSecret) protected ResponserespondWithToken(String token, String tokenSecret, boolean callbackConfirmed) showApproveKeyPage(String key) Shows the approval page for a single provisional consumer.Shows the consumer management page, which allows administrator to approve or remove OAuth consumers.protected OAuthRequestValidates this is a known consumer and the request is valid usingOAuthValidator.validateMessage(net.oauth.OAuthMessage, OAuthAccessor).
-
Field Details
-
httpRequest
-
httpResponse
-
-
Constructor Details
-
OAuthService
public OAuthService()
-
-
Method Details
-
doGetRequestToken
@GET @Path("/requestToken") public Response doGetRequestToken() throws IOException, ServletException- Throws:
IOExceptionServletException
-
doPostRequestToken
@POST @Path("/requestToken") public Response doPostRequestToken() throws IOException, ServletExceptionResponds with a request token and token secret.- Returns:
- the response
- Throws:
IOException- on I/O errorsServletException- on servlet errors
-
authorize
Responds with a web page to log in.- Returns:
- the response
- Throws:
IOException- on I/O errorsServletException- on internal errors validating the request
-
login
@POST @Path("/login") public Response login(@FormParam("id") String id, @FormParam("password") String password, @FormParam("requestToken") String requestToken) Validates the ID and password on the authorization form. This is intended to be invoked by an XHR on the login page.- Returns:
- the response, 409 if login failed or 204 if successful
-
authorize
@POST @Path("/internal/approveToken") public Response authorize(@FormParam("requestToken") String requestToken) -
doGetAccessToken
- Throws:
IOExceptionServletException
-
doPostAccessToken
@POST @Path("/accessToken") public Response doPostAccessToken() throws IOException, ServletExceptionResponds with an access token and token secret for valid OAuth requests. The request must be signed and the request token valid.- Returns:
- the response
- Throws:
IOException- on I/O errorsServletException- on servlet errors
-
provisionalKey
@POST @Path("/requestKey") @Produces("application/json") public Response provisionalKey() throws NullPointerException, IOExceptionGenerates a provisional consumer key. This request must be later approved by an administrator.- Returns:
- a JSON response with the provisional key
- Throws:
IOExceptionNullPointerException- See Also:
-
showApproveKeyPage
@GET @Path("/approveKey") @Produces("text/html") public Response showApproveKeyPage(@QueryParam("key") String key) throws ServletException, IOException Shows the approval page for a single provisional consumer. Shows the consumer management page instead if no key is passed in.- Parameters:
key- the consumer- Returns:
- the approve consumer page
- Throws:
ServletException- on errors showing the JSPIOException- on errors showing the JSP- See Also:
-
showConsumerKeyManagementPage
@GET @Path("/admin") public Response showConsumerKeyManagementPage() throws ServletException, IOExceptionShows the consumer management page, which allows administrator to approve or remove OAuth consumers.- Returns:
- the consumer management page
- Throws:
ServletException- on JSP errorsIOException- on JSP errors
-
login
@POST @Path("/adminLogin") public Response login(@FormParam("id") String id, @FormParam("password") String password) Validates that the ID and password are for an administrator. This is used by the admin login page to protect the OAuth administration pages.- Returns:
- the response, 409 if login failed or 204 if successful
-
confirmCallback
- Throws:
net.oauth.OAuthException
-
validateRequest
Validates this is a known consumer and the request is valid usingOAuthValidator.validateMessage(net.oauth.OAuthMessage, OAuthAccessor). Does not check for any tokens.- Returns:
- an OAuthRequest
- Throws:
net.oauth.OAuthException- if the request fails validationIOException- on I/O errors
-
respondWithToken
- Throws:
IOException
-
respondWithToken
protected Response respondWithToken(String token, String tokenSecret, boolean callbackConfirmed) throws IOException - Throws:
IOException
-
respondWithOAuthProblem
protected Response respondWithOAuthProblem(net.oauth.OAuthException e) throws IOException, ServletException - Throws:
IOExceptionServletException
-