Class JwtBearerTokenFlow
java.lang.Object
com.sap.cloud.security.xsuaa.tokenflows.JwtBearerTokenFlow
A JWT bearer token flow builder.
Applications can use this flow to exchange a given user token for a new JWT token.
Applications can use this flow to exchange a given user token for a new JWT token.
-
Constructor Summary
ConstructorsConstructorDescriptionJwtBearerTokenFlow(OAuth2TokenService tokenService, OAuth2ServiceEndpointsProvider endpointsProvider, ClientIdentity clientIdentity) -
Method Summary
Modifier and TypeMethodDescriptionattributes(Map<String, String> additionalAuthorizationAttributes) Adds additional authorization attributes to the request.disableCache(boolean disableCache) Can be used to disable the cache for the flow.execute()Executes this flow against the XSUAA endpoint.Sets the scope attribute for the token request.setOpaqueTokenFormat(boolean opaque) Can be used to change the format of the returned token.Set the Subdomain the token is requested for.Sets the JWT token that should be exchanged for another JWT token.Sets the bearer token that should be exchanged for another JWT token.Sets the zid(zone id) of the tenant
-
Constructor Details
-
JwtBearerTokenFlow
public JwtBearerTokenFlow(@Nonnull OAuth2TokenService tokenService, @Nonnull OAuth2ServiceEndpointsProvider endpointsProvider, @Nonnull ClientIdentity clientIdentity)
-
-
Method Details
-
token
Sets the bearer token that should be exchanged for another JWT token.- Parameters:
bearerToken- - the bearer token.- Returns:
- this builder.
-
token
Sets the JWT token that should be exchanged for another JWT token. This setter also extracts the zid(zone id) claim from the token and sets it in the X-zid header, thereforezoneId(String)} is not required to be used.- Parameters:
token- - the Token.- Returns:
- this builder.
-
zoneId
Sets the zid(zone id) of the tenant- Parameters:
zoneId- - the zoneId.- Returns:
- this builder.
-
scopes
Sets the scope attribute for the token request. This will restrict the scope of the created token to the scopes provided. By default the scope is not restricted and the created token contains all granted scopes.If you specify a scope that is not authorized for the user, the token request will fail.
- Parameters:
scopes- - one or many scopes as string.- Returns:
- this builder.
-
subdomain
Set the Subdomain the token is requested for.- Parameters:
subdomain- - the subdomain.- Returns:
- this builder.
-
attributes
Adds additional authorization attributes to the request.
Clients can use this to request additional attributes in the 'az_attr' claim of the returned token.- Parameters:
additionalAuthorizationAttributes- - the additional attributes.- Returns:
- this builder.
-
disableCache
Can be used to disable the cache for the flow.- Parameters:
disableCache- - disables cache when set totrue.- Returns:
- this builder.
-
setOpaqueTokenFormat
Can be used to change the format of the returned token.- Parameters:
opaque- enables opaque token format when set totrue.- Returns:
- this builder.
-
execute
Executes this flow against the XSUAA endpoint. As a result the exchanged JWT token is returned.- Returns:
- the JWT instance returned by XSUAA.
- Throws:
IllegalStateException- - in case not all mandatory fields of the token flow request have been set.TokenFlowException- - in case of an error during the flow, or when the token cannot be obtained.
-