Class OltuAuthorizationController
- java.lang.Object
-
- ca.corefacility.bioinformatics.irida.ria.web.oauth.OltuAuthorizationController
-
@Controller public class OltuAuthorizationController extends java.lang.Object
Controller for handling OAuth2 authorizations
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
TOKEN_ENDPOINT
-
Constructor Summary
Constructors Constructor Description OltuAuthorizationController(RemoteAPITokenService tokenService, RemoteAPIService remoteAPIService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
authenticate(javax.servlet.http.HttpSession session, RemoteAPI remoteAPI, java.lang.String redirect)
Begin authentication procedure by redirecting to remote authorization locationjava.lang.String
getTokenFromAuthCode(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String state)
Receive the OAuth2 authorization code and request an OAuth2 tokenvoid
setServerBase(java.lang.String serverBase)
Set the base URL of this server
-
-
-
Field Detail
-
TOKEN_ENDPOINT
public static final java.lang.String TOKEN_ENDPOINT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OltuAuthorizationController
@Autowired public OltuAuthorizationController(RemoteAPITokenService tokenService, RemoteAPIService remoteAPIService)
-
-
Method Detail
-
authenticate
public java.lang.String authenticate(javax.servlet.http.HttpSession session, RemoteAPI remoteAPI, java.lang.String redirect) throws org.apache.oltu.oauth2.common.exception.OAuthSystemException
Begin authentication procedure by redirecting to remote authorization location- Parameters:
remoteAPI
- The API we need to authenticate withredirect
- The location to redirect back to after authentication is complete- Returns:
- A ModelAndView beginning the authentication procedure
- Throws:
org.apache.oltu.oauth2.common.exception.OAuthSystemException
- if we can't read from the authorization server.
-
getTokenFromAuthCode
@RequestMapping("/api/oauth/authorization/token") public java.lang.String getTokenFromAuthCode(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, @RequestParam("state") java.lang.String state) throws org.apache.oltu.oauth2.common.exception.OAuthSystemException, org.apache.oltu.oauth2.common.exception.OAuthProblemException
Receive the OAuth2 authorization code and request an OAuth2 token- Parameters:
request
- The incoming requestresponse
- The response to redirectstate
- The state param which contains a map including apiId and redirect- Returns:
- A ModelAndView redirecting back to the resource that was requested
- Throws:
org.apache.oltu.oauth2.common.exception.OAuthSystemException
- if we can't get an access token for the current request.org.apache.oltu.oauth2.common.exception.OAuthProblemException
- if we can't get a response from the authorization server
-
setServerBase
public void setServerBase(java.lang.String serverBase)
Set the base URL of this server- Parameters:
serverBase
- the base url of the server.
-
-