Class OAuth2BrowserProcessor
-
- All Implemented Interfaces:
public class OAuth2BrowserProcessor extends OAuth2Processor
Handles authentication with OAuth2. The default browser will be used if it matches the browser whitelist. A custom tab will be used instead of a standalone browser, if the default browser supports it. If there is no default browser, a browser matching the whitelist that supports custom tabs will be chosen if one exists (with preference given to Chrome if multiple browsers meet that criteria). Otherwise, any browser matching the whitelist will be chosen. If there are no browsers installed that are allowed by the whitelist then authentication will fail. This class is meant to be used with OAuth2Interceptor.
OkHttpClient okHttpClient = new OkHttpClient.Builder() .addInterceptor( new OAuth2Interceptor( new OAuth2BrowserProcessor(oauthConfiguration), tokenStore)) .cookieJar(new WebkitCookieJar()) .build();
-
-
Field Summary
Fields Modifier and Type Field Description public final static OAuth2Processor.Companion
Companion
public final static Logger
logger
public final static String
TOKEN_REQUEST_CONTENT_TYPE
public String
responseType
public String
scope
public String
state
public String
secret
public boolean
isRequestReadonlyToken
public boolean
enablePKCE
-
Constructor Summary
Constructors Constructor Description OAuth2BrowserProcessor(OAuth2Configuration oauth2Configuration)
OAuth2BrowserProcessor(OAuth2Configuration oauth2Configuration, OkHttpClient client)
OAuth2BrowserProcessor(OAuth2Configuration oauth2Configuration, OkHttpClient client, BrowserWhitelist browserWhitelist)
OAuth2BrowserProcessor(OAuth2Configuration oauth2Configuration, BrowserWhitelist browserWhitelist)
OAuth2BrowserProcessor(OAuthConfig oAuthConfig)
Constructs a new OAuth2BrowserProcessor. OAuth2BrowserProcessor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client)
Constructs a new OAuth2BrowserProcessor. OAuth2BrowserProcessor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client, OAuth2WebOption authOption)
Constructs a new OAuth2BrowserProcessor. OAuth2BrowserProcessor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client, OAuth2WebOption authOption, BrowserWhitelist browserWhitelist)
Constructs a new OAuth2BrowserProcessor. OAuth2BrowserProcessor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client, OAuth2WebOption authOption, BrowserWhitelist browserWhitelist, BrowserDetails preferredBrowser)
OAuth2BrowserProcessor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client, BrowserWhitelist browserWhitelist)
Constructs a new OAuth2BrowserProcessor.
-
Method Summary
Modifier and Type Method Description OAuth2Token
authenticate()
Starts the OAuth 2.0 authentication process. void
cancelAuthentication()
Cancels the ongoing authentication process. -
Methods inherited from class com.sap.cloud.mobile.foundation.authentication.OAuth2Processor
getEnablePKCE, getResponseType, getScope, getSecret, getState, isAuthenticated, isRequestReadonlyToken, refresh, setEnablePKCE, setRequestReadonlyToken, setResponseType, setScope, setSecret, setState
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
OAuth2BrowserProcessor
OAuth2BrowserProcessor(OAuth2Configuration oauth2Configuration)
- Parameters:
oauth2Configuration
- Contains the configuration information.
-
OAuth2BrowserProcessor
OAuth2BrowserProcessor(OAuth2Configuration oauth2Configuration, OkHttpClient client)
- Parameters:
oauth2Configuration
- Contains the configuration information.client
- The OkHttpClient that will be used to make requests.
-
OAuth2BrowserProcessor
OAuth2BrowserProcessor(OAuth2Configuration oauth2Configuration, OkHttpClient client, BrowserWhitelist browserWhitelist)
- Parameters:
oauth2Configuration
- Contains the configuration information.client
- The OkHttpClient that will be used to make requests.browserWhitelist
- The BrowserWhitelist that will be used when selecting the browser used to perform the OAuth flow.
-
OAuth2BrowserProcessor
OAuth2BrowserProcessor(OAuth2Configuration oauth2Configuration, BrowserWhitelist browserWhitelist)
- Parameters:
oauth2Configuration
- Contains the configuration information.browserWhitelist
- The BrowserWhitelist that will be used when selecting the browser used to perform the OAuth flow.
-
OAuth2BrowserProcessor
OAuth2BrowserProcessor(OAuthConfig oAuthConfig)
Constructs a new OAuth2BrowserProcessor.- Parameters:
oAuthConfig
- the OAuth configuration
-
OAuth2BrowserProcessor
OAuth2BrowserProcessor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client)
Constructs a new OAuth2BrowserProcessor.- Parameters:
oAuthConfig
- the OAuth configurationoAuthClient
- the AbstractOAuthClient used as OAuth credentialsclient
- the OkHttpClient used to make requests
-
OAuth2BrowserProcessor
OAuth2BrowserProcessor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client, OAuth2WebOption authOption)
Constructs a new OAuth2BrowserProcessor.- Parameters:
oAuthConfig
- the OAuth configurationoAuthClient
- the AbstractOAuthClient used as OAuth credentialsclient
- the OkHttpClient used to make requestsauthOption
- 0: CCT, 1: Browser
-
OAuth2BrowserProcessor
OAuth2BrowserProcessor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client, OAuth2WebOption authOption, BrowserWhitelist browserWhitelist)
Constructs a new OAuth2BrowserProcessor.- Parameters:
oAuthConfig
- the OAuth configurationoAuthClient
- the AbstractOAuthClient used as OAuth credentialsclient
- the OkHttpClient used to make requestsauthOption
- The authentication option, CCT or WebViewbrowserWhitelist
- the browser white list.
-
OAuth2BrowserProcessor
OAuth2BrowserProcessor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client, OAuth2WebOption authOption, BrowserWhitelist browserWhitelist, BrowserDetails preferredBrowser)
-
OAuth2BrowserProcessor
OAuth2BrowserProcessor(OAuthConfig oAuthConfig, AbstractOAuthClient oAuthClient, OkHttpClient client, BrowserWhitelist browserWhitelist)
Constructs a new OAuth2BrowserProcessor.- Parameters:
oAuthConfig
- the OAuth configurationoAuthClient
- the AbstractOAuthClient used as OAuth credentialsclient
- the OkHttpClient used to make requestsbrowserWhitelist
- The BrowserWhitelist used when selecting the browser to perform the OAuth flow
-
-
Method Detail
-
authenticate
@Nullable()@WorkerThread() OAuth2Token authenticate()
Starts the OAuth 2.0 authentication process.
- Returns:
The obtained OAuth2Token if the process was successful, otherwise null.
-
cancelAuthentication
void cancelAuthentication()
Cancels the ongoing authentication process. Does nothing if there was no ongoing authentication.
-
-
-
-