Class DefaultOAuth2PropertySupplier

java.lang.Object
com.sap.cloud.sdk.cloudplatform.connectivity.DefaultOAuth2PropertySupplier
All Implemented Interfaces:
OAuth2PropertySupplier

@Beta public class DefaultOAuth2PropertySupplier extends Object implements OAuth2PropertySupplier
A default strategy to extract OAuth client information from service bindings.

Supports bindings with a credentials block containing a clientid. Further OAuth properties are expected to also be contained in the credentials block.

Since:
4.20.0
  • Field Details

    • DEFAULT_UAA_CREDENTIAL_PATH

      @Nonnull public static final List<String> DEFAULT_UAA_CREDENTIAL_PATH
      By default, the oauth client details are expected to be contained in a uaa block of the credentials of the service binding.
    • options

      @Nonnull protected final ServiceBindingDestinationOptions options
      The ServiceBindingDestinationOptions containing the service binding to interpret.
    • credentials

      @Nonnull protected final com.sap.cloud.environment.servicebinding.api.TypedMapView credentials
      The credentials contained in the service binding.
  • Constructor Details

  • Method Details

    • isOAuth2Binding

      public boolean isOAuth2Binding()
      Description copied from interface: OAuth2PropertySupplier
      Indicates if the binding is supported by this supplier.
      Specified by:
      isOAuth2Binding in interface OAuth2PropertySupplier
      Returns:
      True, if the binding appears to be an OAuth binding and this property supplier is capable of parsing it.
    • getServiceUri

      @Nonnull public URI getServiceUri()
      Description copied from interface: OAuth2PropertySupplier
      URL that the OAuth client should authenticate to.
      Specified by:
      getServiceUri in interface OAuth2PropertySupplier
      Returns:
      A valid URI.
    • getTokenUri

      @Nonnull public URI getTokenUri()
      Description copied from interface: OAuth2PropertySupplier
      URL of the OAuth token service.
      Specified by:
      getTokenUri in interface OAuth2PropertySupplier
      Returns:
      A valid URI.
    • getClientIdentity

      @Nonnull public com.sap.cloud.security.config.ClientIdentity getClientIdentity()
      Description copied from interface: OAuth2PropertySupplier
      OAuth client identity to be used for obtaining a token.
      Specified by:
      getClientIdentity in interface OAuth2PropertySupplier
      Returns:
      a ClientIdentity.
    • getOAuthPropertyPath

      @Nonnull protected List<String> getOAuthPropertyPath()
      Get the path under which the oauth properties are stored in the service binding credentials.
      Returns:
      The path to the oauth properties.
    • getCredentialOrThrow

      @Nonnull protected <T> T getCredentialOrThrow(@Nonnull Class<T> resultType, @Nonnull String... path) throws DestinationAccessException
      Obtain an entry from the credentials block of the service binding.
      Type Parameters:
      T - The type of the entry to obtain.
      Parameters:
      resultType - The type of the entry to obtain.
      path - The path to the entry to obtain.
      Returns:
      The entry from the credentials block of the service binding.
      Throws:
      DestinationAccessException - If the property was not found or could not be converted to the requested type.
      See Also:
    • getCredential

      @Nonnull protected <T> io.vavr.control.Option<T> getCredential(@Nonnull Class<T> resultType, @Nonnull String... path)
      Obtain an entry from the credentials block of the service binding.
      Type Parameters:
      T - The type of the entry to obtain.
      Parameters:
      resultType - The type of the entry to obtain.
      path - The path to the entry to obtain.
      Returns:
      The entry from the credentials block of the service binding.
      See Also:
    • getOAuthCredentialOrThrow

      @Nonnull protected <T> T getOAuthCredentialOrThrow(@Nonnull Class<T> resultType, @Nonnull String... path) throws DestinationAccessException
      Obtain an oauth property from the credentials block of the service binding. Uses getOAuthPropertyPath() as prefix to the path.
      Type Parameters:
      T - The type of the entry to obtain.
      Parameters:
      resultType - The type of the entry to obtain.
      path - The path to the entry to obtain.
      Returns:
      The oauth property from the credentials block of the service binding.
      Throws:
      DestinationAccessException - If the property was not found or could not be converted to the requested type.
      See Also:
    • getOAuthCredential

      @Nonnull protected <T> io.vavr.control.Option<T> getOAuthCredential(@Nonnull Class<T> resultType, @Nonnull String... path)
      Obtain an oauth property from the credentials block of the service binding. Uses getOAuthPropertyPath() as prefix to the path.
      Type Parameters:
      T - The type of the entry to obtain.
      Parameters:
      resultType - The type of the entry to obtain.
      path - The path to the entry to obtain.
      Returns:
      The oauth property from the credentials block of the service binding.
      See Also: