org.springframework.security.oauth2.client.token.grant.code
Class AuthorizationCodeAccessTokenProvider

java.lang.Object
  extended by org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport
      extended by org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider
All Implemented Interfaces:
AccessTokenProvider

public class AuthorizationCodeAccessTokenProvider
extends OAuth2AccessTokenSupport
implements AccessTokenProvider

Provider for obtaining an oauth2 access token by using an authorization code.

Author:
Ryan Heaton, Dave Syer

Field Summary
 
Fields inherited from class org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport
logger
 
Constructor Summary
AuthorizationCodeAccessTokenProvider()
           
 
Method Summary
protected  org.springframework.web.client.ResponseExtractor<org.springframework.http.ResponseEntity<Void>> getAuthorizationResponseExtractor()
           
protected  UserApprovalRequiredException getUserApprovalSignal(AuthorizationCodeResourceDetails resource, AccessTokenRequest request)
           
 OAuth2AccessToken obtainAccessToken(OAuth2ProtectedResourceDetails details, AccessTokenRequest request)
          Obtain a new access token for the specified protected resource.
 String obtainAuthorizationCode(OAuth2ProtectedResourceDetails details, AccessTokenRequest request)
           
 OAuth2AccessToken refreshAccessToken(OAuth2ProtectedResourceDetails resource, OAuth2RefreshToken refreshToken, AccessTokenRequest request)
           
 void setStateKeyGenerator(StateKeyGenerator stateKeyGenerator)
           
 boolean supportsRefresh(OAuth2ProtectedResourceDetails resource)
           
 boolean supportsResource(OAuth2ProtectedResourceDetails resource)
          Whether this provider supports the specified resource.
 
Methods inherited from class org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport
getAccessTokenUri, getHttpMethod, getRequestCallback, getResponseErrorHandler, getResponseExtractor, getRestTemplate, retrieveToken, setAuthenticationHandler, setMessageConverters, setRequestFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthorizationCodeAccessTokenProvider

public AuthorizationCodeAccessTokenProvider()
Method Detail

setStateKeyGenerator

public void setStateKeyGenerator(StateKeyGenerator stateKeyGenerator)
Parameters:
stateKeyGenerator - the stateKeyGenerator to set

supportsResource

public boolean supportsResource(OAuth2ProtectedResourceDetails resource)
Description copied from interface: AccessTokenProvider
Whether this provider supports the specified resource.

Specified by:
supportsResource in interface AccessTokenProvider
Parameters:
resource - The resource.
Returns:
Whether this provider supports the specified resource.

supportsRefresh

public boolean supportsRefresh(OAuth2ProtectedResourceDetails resource)
Specified by:
supportsRefresh in interface AccessTokenProvider
Parameters:
resource - The resource to check
Returns:
true if this provider can refresh an access token

obtainAuthorizationCode

public String obtainAuthorizationCode(OAuth2ProtectedResourceDetails details,
                                      AccessTokenRequest request)
                               throws UserRedirectRequiredException,
                                      UserApprovalRequiredException,
                                      org.springframework.security.access.AccessDeniedException,
                                      OAuth2AccessDeniedException
Throws:
UserRedirectRequiredException
UserApprovalRequiredException
org.springframework.security.access.AccessDeniedException
OAuth2AccessDeniedException

getAuthorizationResponseExtractor

protected org.springframework.web.client.ResponseExtractor<org.springframework.http.ResponseEntity<Void>> getAuthorizationResponseExtractor()

obtainAccessToken

public OAuth2AccessToken obtainAccessToken(OAuth2ProtectedResourceDetails details,
                                           AccessTokenRequest request)
                                    throws UserRedirectRequiredException,
                                           UserApprovalRequiredException,
                                           org.springframework.security.access.AccessDeniedException,
                                           OAuth2AccessDeniedException
Description copied from interface: AccessTokenProvider
Obtain a new access token for the specified protected resource.

Specified by:
obtainAccessToken in interface AccessTokenProvider
Parameters:
details - The protected resource for which this provider is to obtain an access token.
request - The parameters of the request giving context for the token details if any.
Returns:
The access token for the specified protected resource. The return value may NOT be null.
Throws:
UserRedirectRequiredException - If the provider requires the current user to be redirected for authorization.
UserApprovalRequiredException - If the provider is ready to issue a token but only if the user approves
org.springframework.security.access.AccessDeniedException - If the user denies access to the protected resource.
OAuth2AccessDeniedException

refreshAccessToken

public OAuth2AccessToken refreshAccessToken(OAuth2ProtectedResourceDetails resource,
                                            OAuth2RefreshToken refreshToken,
                                            AccessTokenRequest request)
                                     throws UserRedirectRequiredException,
                                            OAuth2AccessDeniedException
Specified by:
refreshAccessToken in interface AccessTokenProvider
Parameters:
resource - the resource for which a token refresh is required
refreshToken - the refresh token to send
Returns:
an access token
Throws:
UserRedirectRequiredException
OAuth2AccessDeniedException

getUserApprovalSignal

protected UserApprovalRequiredException getUserApprovalSignal(AuthorizationCodeResourceDetails resource,
                                                              AccessTokenRequest request)


Copyright © 2012. All Rights Reserved.