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 protected OAuthConfigoAuthConfigprotected AbstractOAuthClientoAuthClientprivate 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 value)final StringgetScope()final UnitsetScope(String value)final StringgetState()final UnitsetState(String value)final StringgetSecret()final UnitsetSecret(String value)final BooleanisRequestReadonlyToken()final UnitsetRequestReadonlyToken(Boolean value)final BooleangetEnablePKCE()final UnitsetEnablePKCE(Boolean value)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 OkHttpClientgetOKHttpClient()Returns the provided client if available otherwise uses the global client. 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. final OAuth2TokenrequestToken(String code)final StringgetAuthenticationUri()-
-
Constructor Detail
-
OAuth2Processor
OAuth2Processor(OAuth2Configuration oauth2Configuration)
-
OAuth2Processor
OAuth2Processor(OAuth2Configuration oauth2Configuration, OkHttpClient client)
-
OAuth2Processor
OAuth2Processor(OAuthConfig oAuthConfig)
Constructs a new OAuth2Processor. When needed, the OkHttpClient will be retrieved from com.sap.cloud.mobile.foundation.common.ClientProvider, so make sure it has a client set.
- Parameters:
oAuthConfig- the OAuth configuration
-
OAuth2Processor
OAuth2Processor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client)
Constructs a new OAuth2Processor with designated AbstractOAuthClient and OkHttpClient. The AbstractOAuthClient should be included in OAuthConfig.getAllOAuthClients.
- 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 value)
-
getScope
final String getScope()
-
setScope
final Unit setScope(String value)
-
getState
final String getState()
-
setState
final Unit setState(String value)
-
getSecret
final String getSecret()
-
setSecret
final Unit setSecret(String value)
-
isRequestReadonlyToken
final Boolean isRequestReadonlyToken()
-
setRequestReadonlyToken
final Unit setRequestReadonlyToken(Boolean value)
-
getEnablePKCE
final Boolean getEnablePKCE()
-
setEnablePKCE
final Unit setEnablePKCE(Boolean value)
-
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.
-
getOKHttpClient
final OkHttpClient getOKHttpClient()
Returns the provided client if available otherwise uses the global client.
- Returns:
The OKHttpClient
-
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.
-
requestToken
final OAuth2Token requestToken(String code)
-
getAuthenticationUri
final String getAuthenticationUri()
-
-
-
-