public class BoxJWTAuth extends Object implements Authentication
| Modifier and Type | Field and Description |
|---|---|
JWTConfig |
config
An object containing all JWT configuration to use for authentication
|
String |
subjectId
The ID of the user or enterprise to authenticate as.
|
String |
subjectType
The type of the subject ID provided.
|
TokenStorage |
tokenStorage
An object responsible for storing token.
|
| Constructor and Description |
|---|
BoxJWTAuth(JWTConfig config) |
| Modifier and Type | Method and Description |
|---|---|
AccessToken |
downscopeToken(List<String> scopes,
String resource,
String sharedLink,
NetworkSession networkSession)
Downscope access token to the provided scopes.
|
JWTConfig |
getConfig() |
TokenStorage |
getTokenStorage() |
AccessToken |
refreshToken()
Get new access token using JWT auth.
|
AccessToken |
refreshToken(NetworkSession networkSession)
Get new access token using JWT auth.
|
String |
retrieveAuthorizationHeader() |
String |
retrieveAuthorizationHeader(NetworkSession networkSession) |
AccessToken |
retrieveToken()
Get the current access token.
|
AccessToken |
retrieveToken(NetworkSession networkSession)
Get the current access token.
|
void |
revokeToken()
Revoke the current access token and remove it from token storage.
|
void |
revokeToken(NetworkSession networkSession)
Revoke the current access token and remove it from token storage.
|
BoxJWTAuth |
withEnterpriseSubject(String enterpriseId)
Create a new BoxJWTAuth instance that uses the provided enterprise ID as the subject of the JWT
assertion.
|
BoxJWTAuth |
withEnterpriseSubject(String enterpriseId,
TokenStorage tokenStorage)
Create a new BoxJWTAuth instance that uses the provided enterprise ID as the subject of the JWT
assertion.
|
BoxJWTAuth |
withUserSubject(String userId)
Create a new BoxJWTAuth instance that uses the provided user ID as the subject of the JWT
assertion.
|
BoxJWTAuth |
withUserSubject(String userId,
TokenStorage tokenStorage)
Create a new BoxJWTAuth instance that uses the provided user ID as the subject of the JWT
assertion.
|
public final JWTConfig config
public final TokenStorage tokenStorage
public String subjectId
public String subjectType
public BoxJWTAuth(JWTConfig config)
public AccessToken refreshToken()
refreshToken in interface Authenticationpublic AccessToken refreshToken(NetworkSession networkSession)
refreshToken in interface AuthenticationnetworkSession - An object to keep network session statepublic AccessToken retrieveToken()
retrieveToken in interface Authenticationpublic AccessToken retrieveToken(NetworkSession networkSession)
retrieveToken in interface AuthenticationnetworkSession - An object to keep network session statepublic String retrieveAuthorizationHeader()
retrieveAuthorizationHeader in interface Authenticationpublic String retrieveAuthorizationHeader(NetworkSession networkSession)
retrieveAuthorizationHeader in interface Authenticationpublic BoxJWTAuth withUserSubject(String userId)
userId - The id of the user to authenticatepublic BoxJWTAuth withUserSubject(String userId, TokenStorage tokenStorage)
userId - The id of the user to authenticatetokenStorage - Object responsible for storing token in newly created BoxJWTAuth. If no
custom implementation provided, the token will be stored in memory.public BoxJWTAuth withEnterpriseSubject(String enterpriseId)
enterpriseId - The id of the enterprise to authenticatepublic BoxJWTAuth withEnterpriseSubject(String enterpriseId, TokenStorage tokenStorage)
enterpriseId - The id of the enterprise to authenticatetokenStorage - Object responsible for storing token in newly created BoxJWTAuth. If no
custom implementation provided, the token will be stored in memory.public AccessToken downscopeToken(List<String> scopes, String resource, String sharedLink, NetworkSession networkSession)
downscopeToken in interface Authenticationscopes - The scope(s) to apply to the resulting token.resource - The file or folder to get a downscoped token for. If None and shared_link None,
the resulting token will not be scoped down to just a single item. The resource should be a
full URL to an item, e.g. https://api.box.com/2.0/files/123456.sharedLink - The shared link to get a downscoped token for. If None and item None, the
resulting token will not be scoped down to just a single item.networkSession - An object to keep network session statepublic void revokeToken()
revokeToken in interface Authenticationpublic void revokeToken(NetworkSession networkSession)
revokeToken in interface AuthenticationnetworkSession - An object to keep network session statepublic TokenStorage getTokenStorage()