Package com.iizix.server.oauth
Class AbstractOAuthService
java.lang.Object
com.iizix.server.oauth.AbstractOAuthService
- All Implemented Interfaces:
- IOAuthService
The abstract service service using OAuth 1.0a or OAuth 2.0.
- Field SummaryFieldsModifier and TypeFieldDescription- protected static final StringAccept English US language.- protected AccessTokenThe access token, null for none.- protected final com.github.scribejava.core.oauth.OAuth10aServiceThe OAuth 1.0a authentication service.- protected final com.github.scribejava.core.oauth.OAuth20ServiceThe OAuth 2.0 authentication service.- protected final OAuthSessionThe session.
- Constructor SummaryConstructorsModifierConstructorDescription- protected- AbstractOAuthService- (OAuthSession session, com.github.scribejava.core.oauth.OAuth10aService service) Constructs the service for OAuth 1.0a.- protected- AbstractOAuthService- (OAuthSession session, com.github.scribejava.core.oauth.OAuth20Service service) Constructs the service for OAuth 2.0.
- Method SummaryModifier and TypeMethodDescription- protected static com.github.scribejava.core.builder.ServiceBuilder- createServiceBuilder- (String clientID, String clientSecret) Creates a ServiceBuilder that is initialized for debugging or not.- final void- dispose()Disposes of the session, i.e.- voidDisposes of the session because of a blocked pop-up window.- voidDisposes of the session because of a user cancel action.- void- doAuthenticate- (IOAuthListener listener) - protected final AccessTokenGets an access token, perhaps by means of refresh.- final com.github.scribejava.core.model.OAuth1AccessTokenGets the current, refreshes or get a new OAuth 1.0a Access Token.- final com.github.scribejava.core.model.OAuth2AccessTokenGets the current, refreshes or get a new OAuth 2.0 Access Token.- protected static OutputStreamGets the output stream for debugging.- abstract StringReturns the logout URL for the OAuth service.- protected longThe default additional required time in milliseconds to process a request, i.e.- abstract UserProfileInfoGets the UserProfileInformation from this service.- booleanInvalidates the current Access Token that may be valid for quite some time.- protected static voidValidates the clientID, clientSecret and scopes.- Methods inherited from class java.lang.Object- clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait- Methods inherited from interface com.iizix.comm.oauth.IOAuthService- getApproximateSize, getAuthenticationProvider, getServiceName
- Field Details- ACCEPT_LANGUAGEAccept English US language.- See Also:
 
- sessionThe session.
- service1protected final com.github.scribejava.core.oauth.OAuth10aService service1The OAuth 1.0a authentication service.
- service2protected final com.github.scribejava.core.oauth.OAuth20Service service2The OAuth 2.0 authentication service.
- accessTokenThe access token, null for none.
 
- Constructor Details- AbstractOAuthServiceprotected AbstractOAuthService- (OAuthSession session, com.github.scribejava.core.oauth.OAuth20Service service) Constructs the service for OAuth 2.0.- Parameters:
- session- The session.
- service- The service.
- Throws:
- NullPointerException- If- sessionor- serviceis- null.
 
- AbstractOAuthServiceprotected AbstractOAuthService- (OAuthSession session, com.github.scribejava.core.oauth.OAuth10aService service) Constructs the service for OAuth 1.0a.- Parameters:
- session- The session.
- service- The service.
- Throws:
- NullPointerException- If- sessionor- serviceis- null.
 
 
- Method Details- validateValidates the clientID, clientSecret and scopes.- Parameters:
- clientID- The Client ID.
- clientSecret- The Client Secret.
- scopes- The list of scopes as an array, or- nullfor default scopes.
- Throws:
- NullPointerException- If- clientID,- clientSecretor any of the- scopesvalues are null is- null.
- IllegalArgumentException- If- clientID,- clientSecretor any of the- scopesvalues is empty.
 
- createServiceBuilderprotected static com.github.scribejava.core.builder.ServiceBuilder createServiceBuilder- (String clientID, String clientSecret) Creates a ServiceBuilder that is initialized for debugging or not.- Parameters:
- clientID- The Client ID.
- clientSecret- The Client Secret.
- Returns:
- ServiceBuilder The service builder instance.
- Throws:
- NullPointerException- If- clientIDor- clientSecretis- null.
- IllegalArgumentException- If- clientIDor- clientSecretis empty String.
 
- getDebugOutputStreamGets the output stream for debugging.- Returns:
- The output stream when debugging, or {code null} when not debugging.
 
- getRequestAdditionalTimeprotected long getRequestAdditionalTime()The default additional required time in milliseconds to process a request, i.e. to see if an access token is still valid.- Subclasses override this method to return another value. - Returns:
- The default value of 20_000 milliseconds (20 seconds).
 
- getLogoutURLReturns the logout URL for the OAuth service. It is not the same as invalidating an access URL.- Subclasses must override this method and implement a return value. - Returns:
- The logout URL, or nullif none exists.
 
- disposeBlockedpublic void disposeBlocked()Disposes of the session because of a blocked pop-up window. The listener is notified, if any.- Specified by:
- disposeBlockedin interface- IOAuthService
 
- disposeUserCancelpublic void disposeUserCancel()Disposes of the session because of a user cancel action.- Specified by:
- disposeUserCancelin interface- IOAuthService
 
- disposepublic final void dispose()Disposes of the session, i.e. can e.g. close an asynchronous client in progress.- Specified by:
- disposein interface- IOAuthService
 
- doAuthenticatepublic void doAuthenticate- (IOAuthListener listener) throws IOException, InterruptedException, ExecutionException 
- getAccessTokenprotected final AccessToken getAccessToken() throws IOException, InterruptedException, ExecutionExceptionGets an access token, perhaps by means of refresh.- Returns:
- The AccessToken instance.
- Throws:
- IllegalStateException- If the authentication has not completed successfully.
- IOException- For I/O errors.
- ExecutionException- If execution failed when requesting the token.
- InterruptedException- If thread was interrupted while waiting for the token.
 
- invalidateAccessTokenInvalidates the current Access Token that may be valid for quite some time.- The last access token is revoked and this might lead to IOException's. - For OAuth 1.0, this method just clears the Access Token so it has to be retrieved again and just returns false for failure. - Returns:
- true for success, false for failure (no token to invalidate), or the service is of OAuth 1.0a type.
- Throws:
- ExecutionException- For execution errors.
- InterruptedException- If the revocation action was interrupted.
- IOException- For I/O errors.
 
- getAccessToken2public final com.github.scribejava.core.model.OAuth2AccessToken getAccessToken2() throws IOException, InterruptedException, ExecutionExceptionGets the current, refreshes or get a new OAuth 2.0 Access Token.- Returns:
- The OAuth 2.0 Access Token instance.
- Throws:
- IllegalStateException- If the authentication has not completed successfully.
- IOException- For I/O errors.
- ExecutionException- If execution failed when requesting the token.
- InterruptedException- If thread was interrupted while waiting for the token.
 
- getAccessToken1public final com.github.scribejava.core.model.OAuth1AccessToken getAccessToken1() throws IOException, InterruptedException, ExecutionExceptionGets the current, refreshes or get a new OAuth 1.0a Access Token.- Returns:
- The OAuth 1.0a Access Token instance.
- Throws:
- IllegalStateException- If the authentication has not completed successfully.
- IOException- For I/O errors.
- ExecutionException- If execution failed when requesting the token.
- InterruptedException- If thread was interrupted while waiting for the token.
 
- getUserProfileInfopublic abstract UserProfileInfo getUserProfileInfo() throws IOException, InterruptedException, ExecutionExceptionGets the UserProfileInformation from this service.- This will cause the user to have to authenticate with the service, unless not already done. - All fields available for this service that are possible to set and available will be initialized. Other values will be left - null, unknown or undefined.- Returns:
- The UserProfileInfo instance.
- Throws:
- ExecutionException- For execution errors.
- InterruptedException- If the revocation action was interrupted.
- IOException- For I/O errors.