Class 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  
    • 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 location
      java.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 token
      void setServerBase​(java.lang.String serverBase)
      Set the base URL of this server
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 with
        redirect - 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 request
        response - The response to redirect
        state - 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.