public class OauthClientImpl extends Object implements OauthClient
| Modifier and Type | Class and Description |
|---|---|
static class |
OauthClientImpl.AppList |
static class |
OauthClientImpl.OauthTokenDetailList |
| Modifier and Type | Method and Description |
|---|---|
OauthToken |
createOAuthClientToken(Collection<String> scopes)
OAuth client application can use this method to create an OAuth token with arbitrary scopes
that belongs to the user who registered the application.
|
OauthToken |
createOAuthClientToken(String... scopes)
Overloaded version of
OauthClient.createOAuthClientToken(Collection) |
OauthToken |
createOAuthClientToken(TokenRequest tokenRequest)
Overloaded version of
OauthClient.createOAuthClientToken(Collection) |
OauthToken |
createToken(TokenRequest tokenRequest)
Creates a OAuth token for the current user (used to create
BeesClient) |
void |
deleteApplication(String clientId) |
void |
deleteToken(String oauthTokenId)
Deletes a token created by
OauthClient.createToken(TokenRequest) |
OauthToken |
exchangeToAccessToken(String refreshToken,
String... scopes)
Exchange refresh_token to an access token.
|
OauthToken |
exchangeToAccessToken(String authorizationCode,
String redirectUri)
OAuth client application can use this method to exchange the authorization code
(which it gets from the browser after GC authenticates the user and redirects him back to you)
to the OAuth access token.
|
OauthClientApplication |
getApplication(String clientId)
Gets the details of an OAuth client application by its client ID.
|
List<OauthClientApplication> |
listApplication()
Lists up all the OAuth client applications registered by the current user.
|
List<OauthTokenDetail> |
listTokens()
Lists up all the tokens generated by te current user.
|
String |
parseAuthorizationHeader(String authorizationHeader)
Parses Bearer token from HTTP Authorization header
|
OauthClientApplication |
registerApplication(OauthClientApplication input)
Registers a new OAuth client application.
|
OauthToken |
validateToken(String token)
Obtains the details of the token and performs minimal validation (such as expiration.)
Returns null if the given access token is invalid, otherwise OauthToken is returned.
|
OauthToken |
validateToken(String token,
String... scopes)
Validates token with the given scopes.
|
public OauthToken createToken(TokenRequest tokenRequest) throws OauthClientException
OauthClientBeesClient)createToken in interface OauthClientOauthClientException - if there is any error during token validationpublic List<OauthTokenDetail> listTokens() throws OauthClientException
OauthClientlistTokens in interface OauthClientOauthClientExceptionpublic void deleteToken(String oauthTokenId) throws OauthClientException
OauthClientOauthClient.createToken(TokenRequest)deleteToken in interface OauthClientOauthClientExceptionAbstractOauthToken.delete()public OauthToken validateToken(String token, String... scopes) throws OauthClientException
OauthClient
BeesClient must be constructed with OAuth client ID and client secret as the username and password.
validateToken in interface OauthClienttoken - non-null tokenscopes - array of scope that are expected to be granted for this tokenOauthClientExceptionpublic OauthToken validateToken(String token) throws OauthClientException
OauthClient
BeesClient must be constructed with OAuth client ID and client secret as the username and password.
This method call is a network operation. If you are developing a server application that performs frequent token validations, then consider using https://github.com/CloudBees-community/cached-token-validator , which adds caching on top of this.
validateToken in interface OauthClienttoken - non-null tokenOauthClientExceptionpublic String parseAuthorizationHeader(String authorizationHeader)
OauthClientparseAuthorizationHeader in interface OauthClientauthorizationHeader - HTTP Authorization Headerpublic OauthClientApplication registerApplication(OauthClientApplication input) throws OauthClientException
OauthClientregisterApplication in interface OauthClientOauthClientApplication object. This is not the same object
as you passed in the input.OauthClientExceptionpublic OauthClientApplication getApplication(String clientId) throws OauthClientException
OauthClientgetApplication in interface OauthClientOauthClientExceptionpublic void deleteApplication(String clientId) throws OauthClientException
deleteApplication in interface OauthClientOauthClientExceptionpublic List<OauthClientApplication> listApplication() throws OauthClientException
OauthClientlistApplication in interface OauthClientOauthClientExceptionpublic OauthToken exchangeToAccessToken(String authorizationCode, String redirectUri) throws OauthClientException
OauthClient
For this method to work, BeesClient should be called with OAuth client ID and secret.
exchangeToAccessToken in interface OauthClientredirectUri - Required if present in the authorization request, and the value must be the same.OauthClientExceptionpublic OauthToken exchangeToAccessToken(String refreshToken, String... scopes) throws OauthClientException
OauthClientexchangeToAccessToken in interface OauthClientrefreshToken - required. refresh_token.scopes - optional. If not provided the returned access_token carries the same scopes as the one granted
to refresh_token.OauthClientExceptionpublic OauthToken createOAuthClientToken(Collection<String> scopes) throws OauthClientException
OauthClient
For this method to work, BeesClient should be called with OAuth client ID and secret.
createOAuthClientToken in interface OauthClientOauthClientExceptionpublic OauthToken createOAuthClientToken(String... scopes) throws OauthClientException
OauthClientOauthClient.createOAuthClientToken(Collection)createOAuthClientToken in interface OauthClientOauthClientExceptionpublic OauthToken createOAuthClientToken(TokenRequest tokenRequest) throws OauthClientException
OauthClientOauthClient.createOAuthClientToken(Collection)createOAuthClientToken in interface OauthClientOauthClientExceptionCopyright © 2011-2015. All Rights Reserved.