cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hi Experts,

Now I'm using latest Java SAP cloud SDK, and found that Authorization is deprecated.

Set<Authorization> getAuthorizations()

how to get the Authorization list?

final Try<Principal> principalTry = PrincipalAccessor.tryGetCurrentPrincipal();
if (principalTry.isFailure()) {
throw new ServiceException(ResultCode.GET_PRINCIPAL_ERROR, principalTry.getCause());
}
Principal principal = principalTry.get();
0 Likes
View Entire Topic
cschubert
Employee
Employee
0 Likes

Hi Gary,

the SAP Cloud SDK team is currently working hard on the release of the next major version (v5). Related documentation you can find here: https://sap.github.io/cloud-sdk/docs/java/v5/guides/5.0-upgrade

In the case of the Authorization API we decided to drop the SAP Cloud SDK side implementation, in favor of leveraging the more central "cloud-security-services-integration-library", which you can find here: https://github.com/SAP/cloud-security-services-integration-library/tree/main

As already bring the required replacement as a dependency of the SAP Cloud SDK, you should be able to retrieve the Authorizations by using the following code:

Token token = SecurityContext.getToken(); 
List<String> scopes = token.getClaimAsStringList(TokenClaims.XSUAA.SCOPES);

These scopes represent what the SAP Cloud SDK was calling "Authorizations" before.

I hope this helps!

Greetings
Chris

0 Likes

Hi Chris,

Thanks a lot.

So currently 4.24.0 the changes in SecurityConfigXSUAA no need to change anything, right?

I mean still can use hasAnyAuthority to limit the API access permission.

cschubert
Employee
Employee

No, currently you don't "need" to change anything, those API will just be removed in version 5 of the Cloud SDK.