Class AuthCodeGrantImpl
- java.lang.Object
-
- org.glassfish.jersey.client.oauth2.AuthCodeGrantImpl
-
- All Implemented Interfaces:
OAuth2CodeGrantFlow
class AuthCodeGrantImpl extends java.lang.Object implements OAuth2CodeGrantFlow
Default implementation ofOAuth2CodeGrantFlow
.- Since:
- 2.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
AuthCodeGrantImpl.Builder
Builder implementation.(package private) static class
AuthCodeGrantImpl.DefaultTokenMessageBodyReader
-
Nested classes/interfaces inherited from interface org.glassfish.jersey.client.oauth2.OAuth2CodeGrantFlow
OAuth2CodeGrantFlow.Phase
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.String>
accessTokenProperties
private java.lang.String
accessTokenUri
private java.util.Map<java.lang.String,java.lang.String>
authorizationProperties
private java.lang.String
authorizationUri
private javax.ws.rs.client.Client
client
private ClientIdentifier
clientIdentifier
private java.util.Map<java.lang.String,java.lang.String>
refreshTokenProperties
private java.lang.String
refreshTokenUri
private TokenResult
tokenResult
-
Constructor Summary
Constructors Modifier Constructor Description private
AuthCodeGrantImpl(java.lang.String authorizationUri, java.lang.String accessTokenUri, java.lang.String redirectUri, java.lang.String refreshTokenUri, ClientIdentifier clientIdentifier, java.lang.String scope, javax.ws.rs.client.Client client, java.util.Map<java.lang.String,java.lang.String> authorizationProperties, java.util.Map<java.lang.String,java.lang.String> accessTokenProperties, java.util.Map<java.lang.String,java.lang.String> refreshTokenProperties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private javax.ws.rs.client.Client
configureClient(javax.ws.rs.client.Client client)
TokenResult
finish(java.lang.String authorizationCode, java.lang.String state)
Finish the authorization process and return theTokenResult
.javax.ws.rs.client.Client
getAuthorizedClient()
Return the client configured for performing authorized requests to the Service Provider.javax.ws.rs.core.Feature
getOAuth2Feature()
Return theoauth filter feature
that can be used to configureclient
instances to perform authenticated requests to the Service Provider.private void
initDefaultProperties(java.lang.String redirectUri, java.lang.String scope)
TokenResult
refreshAccessToken(java.lang.String refreshToken)
Refresh the access token using a refresh token.private void
setDefaultProperty(java.lang.String key, java.lang.String value, java.util.Map<java.lang.String,java.lang.String>... properties)
java.lang.String
start()
Start the authorization process and return redirection URI on which the user should give a consent for our application to access resources.
-
-
-
Field Detail
-
accessTokenUri
private final java.lang.String accessTokenUri
-
authorizationUri
private final java.lang.String authorizationUri
-
refreshTokenUri
private final java.lang.String refreshTokenUri
-
clientIdentifier
private final ClientIdentifier clientIdentifier
-
client
private final javax.ws.rs.client.Client client
-
authorizationProperties
private final java.util.Map<java.lang.String,java.lang.String> authorizationProperties
-
accessTokenProperties
private final java.util.Map<java.lang.String,java.lang.String> accessTokenProperties
-
refreshTokenProperties
private final java.util.Map<java.lang.String,java.lang.String> refreshTokenProperties
-
tokenResult
private volatile TokenResult tokenResult
-
-
Constructor Detail
-
AuthCodeGrantImpl
private AuthCodeGrantImpl(java.lang.String authorizationUri, java.lang.String accessTokenUri, java.lang.String redirectUri, java.lang.String refreshTokenUri, ClientIdentifier clientIdentifier, java.lang.String scope, javax.ws.rs.client.Client client, java.util.Map<java.lang.String,java.lang.String> authorizationProperties, java.util.Map<java.lang.String,java.lang.String> accessTokenProperties, java.util.Map<java.lang.String,java.lang.String> refreshTokenProperties)
-
-
Method Detail
-
configureClient
private javax.ws.rs.client.Client configureClient(javax.ws.rs.client.Client client)
-
setDefaultProperty
private void setDefaultProperty(java.lang.String key, java.lang.String value, java.util.Map<java.lang.String,java.lang.String>... properties)
-
initDefaultProperties
private void initDefaultProperties(java.lang.String redirectUri, java.lang.String scope)
-
start
public java.lang.String start()
Description copied from interface:OAuth2CodeGrantFlow
Start the authorization process and return redirection URI on which the user should give a consent for our application to access resources.- Specified by:
start
in interfaceOAuth2CodeGrantFlow
- Returns:
- URI to which user should be redirected.
-
finish
public TokenResult finish(java.lang.String authorizationCode, java.lang.String state)
Description copied from interface:OAuth2CodeGrantFlow
Finish the authorization process and return theTokenResult
. The method must be called on the same instance after theOAuth2CodeGrantFlow.start()
method was called and user granted access to this application.The method makes a request to the Authorization Server in order to exchange
code
for access token.- Specified by:
finish
in interfaceOAuth2CodeGrantFlow
- Parameters:
authorizationCode
- Code received from the user authorization process.state
- State received from the user authorization response.- Returns:
- Token result.
-
refreshAccessToken
public TokenResult refreshAccessToken(java.lang.String refreshToken)
Description copied from interface:OAuth2CodeGrantFlow
Refresh the access token using a refresh token. This method can be called on newly created instance or on instance on which the authorization flow was already performed.- Specified by:
refreshAccessToken
in interfaceOAuth2CodeGrantFlow
- Parameters:
refreshToken
- Refresh token.- Returns:
- Token result.
-
getAuthorizedClient
public javax.ws.rs.client.Client getAuthorizedClient()
Description copied from interface:OAuth2CodeGrantFlow
Return the client configured for performing authorized requests to the Service Provider. The authorization process must be successfully finished by instance by calling methodsOAuth2CodeGrantFlow.start()
andOAuth2CodeGrantFlow.finish(String, String)
.- Specified by:
getAuthorizedClient
in interfaceOAuth2CodeGrantFlow
- Returns:
- Client configured to add correct
Authorization
header to requests.
-
getOAuth2Feature
public javax.ws.rs.core.Feature getOAuth2Feature()
Description copied from interface:OAuth2CodeGrantFlow
Return theoauth filter feature
that can be used to configureclient
instances to perform authenticated requests to the Service Provider.The authorization process must be successfully finished by instance by calling methods
OAuth2CodeGrantFlow.start()
andOAuth2CodeGrantFlow.finish(String, String)
.- Specified by:
getOAuth2Feature
in interfaceOAuth2CodeGrantFlow
- Returns:
- oauth filter feature configured with received
AccessToken
.
-
-