Class OAuth2Processor
-
- All Implemented Interfaces:
public abstract class OAuth2ProcessorThis class is used by OAuth2Interceptor to authenticate when it detects an OAuth challenge.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classOAuth2Processor.Tag
-
Field Summary
Fields Modifier and Type Field Description private StringresponseTypeprivate Stringscopeprivate Stringstateprivate Stringsecretprivate BooleanisRequestReadonlyTokenprivate BooleanenablePKCE
-
Constructor Summary
Constructors Constructor Description OAuth2Processor(OAuth2Configuration oauth2Configuration)OAuth2Processor(OAuth2Configuration oauth2Configuration, OkHttpClient client)OAuth2Processor(OAuthConfig oAuthConfig)Constructs a new OAuth2Processor. OAuth2Processor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client)Constructs a new OAuth2Processor with designated AbstractOAuthClient and OkHttpClient.
-
Method Summary
Modifier and Type Method Description final StringgetResponseType()final UnitsetResponseType(String responseType)final StringgetScope()final UnitsetScope(String scope)final StringgetState()final UnitsetState(String state)final StringgetSecret()final UnitsetSecret(String secret)final BooleanisRequestReadonlyToken()final UnitsetRequestReadonlyToken(Boolean isRequestReadonlyToken)final BooleangetEnablePKCE()final UnitsetEnablePKCE(Boolean enablePKCE)abstract OAuth2Tokenauthenticate()Starts the OAuth 2.0 authentication process. abstract UnitcancelAuthentication()Cancels the ongoing authentication process. OAuth2Tokenrefresh(OAuth2Token token)Refreshes the given OAuth 2.0 token. final BooleanisAuthenticated(HttpUrl url)Checks whether the request has session or not, this is called from OAuth2Interceptor to determine whether or not to add the bearer token in the header. -
-
Constructor Detail
-
OAuth2Processor
OAuth2Processor(OAuth2Configuration oauth2Configuration)
-
OAuth2Processor
OAuth2Processor(OAuth2Configuration oauth2Configuration, OkHttpClient client)
-
OAuth2Processor
OAuth2Processor(OAuthConfig oAuthConfig)
Constructs a new OAuth2Processor.- Parameters:
oAuthConfig- the OAuth configuration
-
OAuth2Processor
OAuth2Processor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client)
Constructs a new OAuth2Processor with designated AbstractOAuthClient and OkHttpClient.- Parameters:
oAuthConfig- the OAuth configurationoAuthClient- the AbstractOAuthClient used as OAuth credentialsclient- the OkHttpClient used to make requests
-
-
Method Detail
-
getResponseType
final String getResponseType()
-
setResponseType
final Unit setResponseType(String responseType)
-
getScope
final String getScope()
-
setScope
final Unit setScope(String scope)
-
getState
final String getState()
-
setState
final Unit setState(String state)
-
getSecret
final String getSecret()
-
setSecret
final Unit setSecret(String secret)
-
isRequestReadonlyToken
final Boolean isRequestReadonlyToken()
-
setRequestReadonlyToken
final Unit setRequestReadonlyToken(Boolean isRequestReadonlyToken)
-
getEnablePKCE
final Boolean getEnablePKCE()
-
setEnablePKCE
final Unit setEnablePKCE(Boolean enablePKCE)
-
authenticate
abstract OAuth2Token authenticate()
Starts the OAuth 2.0 authentication process.
- Returns:
The obtained OAuth2Token if the process was successful, otherwise null.
-
cancelAuthentication
abstract Unit cancelAuthentication()
Cancels the ongoing authentication process. Does nothing if there was no ongoing authentication.
-
refresh
@WorkerThread() OAuth2Token refresh(OAuth2Token token)
Refreshes the given OAuth 2.0 token.
- Parameters:
token- The OAuth2Token to be refreshed- Returns:
The refreshed OAuth2Token if the process was successful.
-
isAuthenticated
final Boolean isAuthenticated(HttpUrl url)
Checks whether the request has session or not, this is called from OAuth2Interceptor to determine whether or not to add the bearer token in the header.
-
-
-
-