Class DefaultOAuth2PropertySupplier
java.lang.Object
com.sap.cloud.sdk.cloudplatform.connectivity.DefaultOAuth2PropertySupplier
- All Implemented Interfaces:
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 Summary
Modifier and TypeFieldDescriptionprotected final com.sap.cloud.environment.servicebinding.api.TypedMapView
The credentials contained in the service binding.By default, the oauth client details are expected to be contained in auaa
block of thecredentials
of the service binding.protected final ServiceBindingDestinationOptions
TheServiceBindingDestinationOptions
containing the service binding to interpret. -
Constructor Summary
ConstructorDescriptionCreate a new instance to parse the given service binding.DefaultOAuth2PropertySupplier
(ServiceBindingDestinationOptions options, List<String> oauthPropertyPath) Create a new instance to parse the given service binding. -
Method Summary
Modifier and TypeMethodDescriptioncom.sap.cloud.security.config.ClientIdentity
OAuth client identity to be used for obtaining a token.protected <T> io.vavr.control.Option<T>
getCredential
(Class<T> resultType, String... path) Obtain an entry from the credentials block of the service binding.protected <T> T
getCredentialOrThrow
(Class<T> resultType, String... path) Obtain an entry from the credentials block of the service binding.Returns additional configuration for the OAuth2 destination that is to be created.protected <T> io.vavr.control.Option<T>
getOAuthCredential
(Class<T> resultType, String... path) Obtain an oauth property from the credentials block of the service binding.protected <T> T
getOAuthCredentialOrThrow
(Class<T> resultType, String... path) Obtain an oauth property from the credentials block of the service binding.Get the path under which the oauth properties are stored in the service binding credentials.URL that the OAuth client should authenticate to.URL of the OAuth token service.boolean
Indicates if the binding is supported by this supplier.
-
Field Details
-
DEFAULT_UAA_CREDENTIAL_PATH
By default, the oauth client details are expected to be contained in auaa
block of thecredentials
of the service binding. -
options
TheServiceBindingDestinationOptions
containing the service binding to interpret. -
credentials
@Nonnull protected final com.sap.cloud.environment.servicebinding.api.TypedMapView credentialsThe credentials contained in the service binding.
-
-
Constructor Details
-
DefaultOAuth2PropertySupplier
Create a new instance to parse the given service binding. Will useDEFAULT_UAA_CREDENTIAL_PATH
as the default path to oauth properties.- Parameters:
options
- The options containing the service binding to interpret.- See Also:
-
DefaultOAuth2PropertySupplier
public DefaultOAuth2PropertySupplier(@Nonnull ServiceBindingDestinationOptions options, @Nonnull List<String> oauthPropertyPath) Create a new instance to parse the given service binding. Will use the given list as the path to url property.- Parameters:
options
- The options containing the service binding to interpret.oauthPropertyPath
- The path to the oauth properties in the service binding.- See Also:
-
-
Method Details
-
isOAuth2Binding
public boolean isOAuth2Binding()Description copied from interface:OAuth2PropertySupplier
Indicates if the binding is supported by this supplier.- Specified by:
isOAuth2Binding
in interfaceOAuth2PropertySupplier
- Returns:
- True, if the binding appears to be an OAuth binding and this property supplier is capable of parsing it.
-
getServiceUri
Description copied from interface:OAuth2PropertySupplier
URL that the OAuth client should authenticate to.- Specified by:
getServiceUri
in interfaceOAuth2PropertySupplier
- Returns:
- A valid URI.
-
getTokenUri
Description copied from interface:OAuth2PropertySupplier
URL of the OAuth token service.- Specified by:
getTokenUri
in interfaceOAuth2PropertySupplier
- 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 interfaceOAuth2PropertySupplier
- Returns:
- a
ClientIdentity
.
-
getOAuth2Options
Description copied from interface:OAuth2PropertySupplier
Returns additional configuration for the OAuth2 destination that is to be created. By default, this method returnsOAuth2Options.DEFAULT
.- Specified by:
getOAuth2Options
in interfaceOAuth2PropertySupplier
- Returns:
- An instance of
OAuth2Options
to further customize the OAuth2 destination creation.
-
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. UsesgetOAuthPropertyPath()
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. UsesgetOAuthPropertyPath()
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:
-