Package com.avoka.fc.core.security
Class OAuth2Authenticator
java.lang.Object
com.avoka.fc.core.security.OAuth2Authenticator
Provides an oAuth2 authenticator client that can be used by a transact security Manager to authenticate against an oAuth2 provider
like Google.
Note this class performs standard oAuth2 authentication. It does NOT get the user profile from the authentication provider.
- Since:
- 4.1.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The Security Manager Parameter Name for Auth Uristatic final String
The Security Manager Parameter Name for Client Idstatic final String
The Security Manager Parameter Name for Client Secretstatic final String
The Security Manager Parameter Name for Redirect Uristatic final String
The Security Manager Parameter Name for Scopestatic final String
The Security Manager Parameter Name for Token Uri -
Constructor Summary
ConstructorDescriptionOAuth2Authenticator
(HttpServletRequest request) Create a OAuth2Authenticator from the given request, security manager.OAuth2Authenticator
(HttpServletRequest request, SecurityManager securityManager) Create a OAuth2Authenticator from the given request, security manager. -
Method Summary
Modifier and TypeMethodDescriptionPerforms the oAuth2 authentication.Performs the oAuth2 authentication.Returns the JSON response for the Access Token request.boolean
Returns true if the request has a "code" request parameter.void
setAuthUri
(String authUri) Sets the authUri String propertyvoid
setClientId
(String clientId) Sets the clientId String propertyvoid
setClientSecret
(String clientSecret) Sets the clientSecret String propertyvoid
setRedirectUri
(String redirectUri) Sets the redirectUri String propertyvoid
Sets the scope String propertyvoid
setTokenUrl
(String tokenUri) Sets the tokenUri String property
-
Field Details
-
PARAMETER_AUTH_URI
The Security Manager Parameter Name for Auth Uri- See Also:
-
PARAMETER_CLIENT_ID
The Security Manager Parameter Name for Client Id- See Also:
-
PARAMETER_CLIENT_SECRET
The Security Manager Parameter Name for Client Secret- See Also:
-
PARAMETER_REDIRECT_URI
The Security Manager Parameter Name for Redirect Uri- See Also:
-
PARAMETER_SCOPE
The Security Manager Parameter Name for Scope- See Also:
-
PARAMETER_TOKEN_URI
The Security Manager Parameter Name for Token Uri- See Also:
-
-
Constructor Details
-
OAuth2Authenticator
Create a OAuth2Authenticator from the given request, security manager.- Parameters:
request
- - HttpServletRequest that contains the SAML Token (required)
-
OAuth2Authenticator
Create a OAuth2Authenticator from the given request, security manager.- Parameters:
request
- - HttpServletRequest that is calling the OAuth2Authenticator (required)securityManager
- - The SecurityManager that is using the OAuth2Authenticator (required)
-
-
Method Details
-
hasRequestCode
public boolean hasRequestCode()Returns true if the request has a "code" request parameter. When the SSO is initiated the request wont have a "code" request parameter. The request will be redirected to the oAuth2 login server where the user will authenticate. The oAuthLogin server will then redirect the browser back to the portal/secure/account/home.htm page with the code as a parameter like '/secure/account/home.htm?code=AKLDSFJASLKDJF123213SASDFLKJ234WERSDFTST'- Returns:
- true if the request has a "code" request parameter.
-
getAccessToken
Performs the oAuth2 authentication. First redirects the browser to the oAuth2 providers auth url. Handles the return callback the gets the oAuth2 Access Token- Returns:
- the String oAuth2 Access Token that is used to call the user profile information.
-
getAccessTokenEncoded
Performs the oAuth2 authentication. First redirects the browser to the oAuth2 providers auth url. Handles the return callback the gets the oAuth2 Access Token- Returns:
- the String oAuth2 Access Token that is used to call the user profile information.
- Since:
- 5.0.0
-
getAccessTokenResponseJson
Returns the JSON response for the Access Token request. The getAccessTone() method executes the oAuth2 url steps. This is a Utility method that can be called after getAccessToken() method call to use other JSON attibutes.- Returns:
- the String representation of oAuth2 Access Token response. Null value will be returned if Access Token hasn't been returned yet.
- Since:
- 5.0.0
-
setAuthUri
Sets the authUri String property- Parameters:
authUri
- the String oAuth2 auth uri
-
setClientId
Sets the clientId String property- Parameters:
clientId
- the String oAuth2 client id
-
setClientSecret
Sets the clientSecret String property- Parameters:
clientSecret
- the String oAuth client secret
-
setRedirectUri
Sets the redirectUri String property- Parameters:
redirectUri
- the String uri to redirect back to transaction manager secure page: /secure/account/home.htm
-
setScope
Sets the scope String property- Parameters:
scope
- the String oAuth scope property
-
setTokenUrl
Sets the tokenUri String property- Parameters:
tokenUri
- the String uri for requesting the oAuth token
-