Package com.sodius.oslc.server.oauth
Class RedirectOAuthHandler
java.lang.Object
com.sodius.oslc.server.oauth.RedirectOAuthHandler
- All Implemented Interfaces:
OAuthHandler
A OAuth connection handler targeted for OSLC provider applications.
The handler uses a OAuth callback location that targets a servlet contributed by the implemented OSLC provider application.
This class is recommended to be used in conjunction with OslcOAuthService.
- Since:
- 1.3.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRedirectOAuthHandler(URI callbackLocation) Creates a handler that uses the specified callback location as base URL for the OAuth callback.RedirectOAuthHandler(URI callbackLocation, URI redirectLocation) Creates a handler that uses the specified callback location as base URL for the OAuth callback and redirect location when the OAuth challenge is completed. -
Method Summary
Modifier and TypeMethodDescriptionvoidauthorize(RootServices rootServices, URI authorizationUri) Throws aRedirectOAuthExceptionwrapping the specified authorization URI.createCallback(RootServices rootServices, String verifierId) Returns a callback URL to use when an OAuth token is requested.voiddownstreamAuthorize(URI authorizationUri) Throws aRedirectOAuthExceptionwrapping the specified downstream authorization URI.static URIgetRedirectLocation(HttpServletRequest request) Returns the URL the application should redirect to once the OAuth challenge is completed.
-
Constructor Details
-
RedirectOAuthHandler
Creates a handler that uses the specified callback location as base URL for the OAuth callback. When a OAuth callback is to compute, this handler will add the necessary query parameters to the base callback URL.- Parameters:
callbackLocation- the base URL used to compute an OAuth callback location, which must be a servlet contributed by the implemented OSLC provider application.
-
RedirectOAuthHandler
Creates a handler that uses the specified callback location as base URL for the OAuth callback and redirect location when the OAuth challenge is completed. When a OAuth callback is to compute, this handler will add the necessary query parameters to the base callback URL. When the OAuth challenge is completed (i.e. the user has logged-in the remote OSLC application), the web browser will display the specified redirect location.- Parameters:
callbackLocation- the base URL used to compute an OAuth callback location, which must be a servlet contributed by the implemented OSLC provider application.redirectLocation- the URL the application should redirect to once the OAuth challenge is completed,nullif none.
-
-
Method Details
-
getRedirectLocation
Returns the URL the application should redirect to once the OAuth challenge is completed. If the specified request is targeting HTML content, it is assumed the log-in to the remote OSLC application takes place in the web browser main window. In such case, this method returns the request location, so that once the log-in is completed the web page shows the location requested in the first place. If any other type of content is requested, it is assumed the log-in to the remote OSLC application takes place in a web browser pop-up. In such case, this method returnsnull, as there's no content to display in the pop-up once the log-in is completed.- Parameters:
request- the servlet request that triggers an OAuth challenge on an OSLC remote application.- Returns:
- the URL the application should redirect to once the OAuth challenge is completed,
nullif none.
-
createCallback
Returns a callback URL to use when an OAuth token is requested.The returned callback location combines the base URL provided in the constructor and following query parameters:
rootServices: the URL of the root services.verifierId: the verifier ID used to approve the connection.redirect: the URL the application should redirect to once the OAuth challenge is completed. This parameter is not set if no redirect location was provided in the constructor.
- Specified by:
createCallbackin interfaceOAuthHandler- Parameters:
rootServices- the root services of the target application.verifierId- the verifier ID used to approve the connection.- Returns:
- a URL to be called by the target application when the OAuth connection is approved.
-
authorize
public void authorize(RootServices rootServices, URI authorizationUri) throws net.oauth.OAuthException Throws aRedirectOAuthExceptionwrapping the specified authorization URI.- Specified by:
authorizein interfaceOAuthHandler- Parameters:
rootServices- the root services of the target application.authorizationUri- the URL to display in a web browser for the user to approve the connection.- Throws:
net.oauth.OAuthException- if the connection is not approved.
-
downstreamAuthorize
Throws aRedirectOAuthExceptionwrapping the specified downstream authorization URI.- Specified by:
downstreamAuthorizein interfaceOAuthHandler- Parameters:
authorizationUri- the URL to display in a web browser for the user to approve the connection.- Throws:
net.oauth.OAuthException- if the connection is not approved.
-