Skip to content

Commit

Permalink
chore: Use ServiceIdentifier Constants from the Service Binding Lib…
Browse files Browse the repository at this point in the history
…rary (#367)

Co-authored-by: Johannes Schneider <johannes.schneider03@sap.com>
Co-authored-by: CharlesDuboisSAP <charles.dubois@sap.com>
Co-authored-by: Charles Dubois <103174266+CharlesDuboisSAP@users.noreply.github.com>
  • Loading branch information
4 people authored Sep 10, 2024
1 parent e500da4 commit 624b943
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,17 @@
class BtpServicePropertySuppliers
{
static final OAuth2PropertySupplierResolver XSUAA =
OAuth2PropertySupplierResolver.forServiceIdentifier(ServiceIdentifier.of("xsuaa"), Xsuaa::new);
OAuth2PropertySupplierResolver.forServiceIdentifier(ServiceIdentifier.XSUAA, Xsuaa::new);

static final OAuth2PropertySupplierResolver DESTINATION =
OAuth2PropertySupplierResolver.forServiceIdentifier(ServiceIdentifier.DESTINATION, Destination::new);

static final OAuth2PropertySupplierResolver CONNECTIVITY =
OAuth2PropertySupplierResolver.forServiceIdentifier(ServiceIdentifier.CONNECTIVITY, ConnectivityProxy::new);

/**
* {@link ServiceIdentifier#IDENTITY_AUTHENTICATION} referenced indirectly for backwards compatibility.
*/
static final OAuth2PropertySupplierResolver IDENTITY_AUTHENTICATION =
OAuth2PropertySupplierResolver
.forServiceIdentifier(ServiceIdentifier.of("identity"), IdentityAuthentication::new);
.forServiceIdentifier(ServiceIdentifier.IDENTITY_AUTHENTICATION, IdentityAuthentication::new);

static final OAuth2PropertySupplierResolver WORKFLOW =
OAuth2PropertySupplierResolver
Expand Down Expand Up @@ -82,7 +79,7 @@ class BtpServicePropertySuppliers
.withUrlKey(BusinessLoggingOptions.WRITE_API, "writeservice", REMOVE_PATH)
.factory());
static final OAuth2PropertySupplierResolver AI_CORE =
OAuth2PropertySupplierResolver.forServiceIdentifier(ServiceIdentifier.of("aicore"), AiCore::new);
OAuth2PropertySupplierResolver.forServiceIdentifier(ServiceIdentifier.AI_CORE, AiCore::new);

private static final List<OAuth2PropertySupplierResolver> DEFAULT_SERVICE_RESOLVERS = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Try<HttpDestination> tryGetDestination( @Nonnull final ServiceBindingDest

final ServiceBindingDestinationOptions.Builder optionsBuilder;
try {
optionsBuilder = ServiceBindingDestinationOptions.forService(ServiceIdentifier.of("identity"));
optionsBuilder = ServiceBindingDestinationOptions.forService(ServiceIdentifier.IDENTITY_AUTHENTICATION);
}
catch( final DestinationAccessException e ) {
return Try.failure(new DestinationAccessException(preparedMessage, e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,6 @@ static class Builder
{
private static final String XSUAA_TOKEN_PATH = "/oauth/token";

/**
* {@link ServiceIdentifier#IDENTITY_AUTHENTICATION} referenced indirectly for backwards compatibility.
*/
private static final ServiceIdentifier IDENTITY_AUTHENTICATION = ServiceIdentifier.of("identity");

private URI tokenUri;
private ClientIdentity identity;
private OnBehalfOf onBehalfOf = OnBehalfOf.TECHNICAL_USER_CURRENT_TENANT;
Expand Down Expand Up @@ -371,7 +366,7 @@ Builder withTenantPropagationStrategy( @Nonnull final TenantPropagationStrategy
Builder withTenantPropagationStrategyFrom( @Nullable final ServiceIdentifier serviceIdentifier )
{
final TenantPropagationStrategy tenantPropagationStrategy;
if( IDENTITY_AUTHENTICATION.equals(serviceIdentifier) ) {
if( ServiceIdentifier.IDENTITY_AUTHENTICATION.equals(serviceIdentifier) ) {
tenantPropagationStrategy = TenantPropagationStrategy.TENANT_SUBDOMAIN;
} else {
tenantPropagationStrategy = TenantPropagationStrategy.ZID_HEADER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ class XsuaaTest
private static final String PROVIDER_CERT_URL = "https://provider.cert.xsuaa.domain";
private static final ServiceBinding INSTANCE_SECRET_BINDING =
bindingWithCredentials(
ServiceIdentifier.of("xsuaa"),
ServiceIdentifier.XSUAA,
entry("credential-type", "instance-secret"),
entry("clientid", "client-id"),
entry("clientsecret", "client-secret"),
entry("url", PROVIDER_URL));
private static final ServiceBinding X509_BINDING =
bindingWithCredentials(
ServiceIdentifier.of("xsuaa"),
ServiceIdentifier.XSUAA,
entry("credential-type", "x509_generated"),
entry("clientid", "client-id"),
entry("key", "key"),
Expand Down Expand Up @@ -360,7 +360,7 @@ class AiCoreTest
{
final ServiceBinding binding =
bindingWithCredentials(
ServiceIdentifier.of("aicore"),
ServiceIdentifier.AI_CORE,
entry("serviceurls.AI_API_URL", "https://api.ai.internalprod.eu-central-1.aws.ml.hana.ondemand.com"),
entry("clientid", "client-id"),
entry("clientsecret", "client-secret"),
Expand Down
4 changes: 4 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

### 🔧 Compatibility Notes

- Minimum required versions:
- SAP BTP Security Services Integration Libraries `com.sap.cloud.security` 3.4.3
- CAP `com.sap.cds` 2.9.3
- SAP Java Buildpack `com.sap.cloud.sjb` 2.10.0
- Using IAS requires XSUAA version to be minimum `3.4.0`.

### ✨ New Functionality
Expand Down

0 comments on commit 624b943

Please sign in to comment.