Class XsuaaTokenFlows

java.lang.Object
com.sap.cloud.security.xsuaa.tokenflows.XsuaaTokenFlows
All Implemented Interfaces:
Serializable

public class XsuaaTokenFlows extends Object implements Serializable
A bean that can be @Autowired by applications to get access to token flow builders. The token flow builders allow for the execution of a client credentials flow (to get a technical user token) and a jwt bearer token flow (to get an exchange token with different scopes).
This class uses a RestTemplate which it passes on to the builders.
See Also:
  • Constructor Details

    • XsuaaTokenFlows

      public XsuaaTokenFlows(OAuth2TokenService oAuth2TokenService, OAuth2ServiceEndpointsProvider endpointsProvider, ClientIdentity clientIdentity)
      Create a new instance of this bean with the given RestTemplate. Applications should @Autowire instances of this bean.
      Parameters:
      oAuth2TokenService - the OAuth2TokenService that will be used to send the token exchange request.
      endpointsProvider - the endpoint provider that serves the token endpoint.
      clientIdentity - the OAuth2.0 client identity
                  
       String clientId     = "<<get your client id from your service binding>>";
       String clientSecret = "<<get your client secret from your service binding>>";
       String xsuaaBaseUrl = "<<get your xsuaa base url from service binding>>";
      
       XsuaaTokenFlows tokenFlows = new XsuaaTokenFlows(
                                 new DefaultOAuth2TokenService(),
                                 new XsuaaDefaultEndpoints(xsuaaBaseUrl),
                                 new ClientCredentials(clientId, clientSecret));
       
                  
  • Method Details

    • clientCredentialsTokenFlow

      public ClientCredentialsTokenFlow clientCredentialsTokenFlow()
      Creates a new Client Credentials Flow builder object.
      Token, authorize and key set endpoints will be derived relative to the base URI.
      Returns:
      the ClientCredentialsTokenFlow builder object.
    • refreshTokenFlow

      public RefreshTokenFlow refreshTokenFlow()
      Creates a new Refresh Token Flow builder object.
      Token, authorize and key set endpoints will be derived relative to the base URI.
      Returns:
      the RefreshTokenFlow builder object.
    • passwordTokenFlow

      public PasswordTokenFlow passwordTokenFlow()
      Creates a new Password Token Flow builder object.
      Token, authorize and key set endpoints will be derived relative to the base URI.
      Returns:
      the PasswordTokenFlow builder object.
    • jwtBearerTokenFlow

      public JwtBearerTokenFlow jwtBearerTokenFlow()
      Creates a new JWT Bearer Token Flow builder object.
      Token, authorize and key set endpoints will be derived relative to the base URI.
      Returns:
      the JwtBearerTokenFlow builder object.