SAP Cloud SDK 3.0及以上版本如何获取用户信息和权限

How to get user info and authorities in SAP Cloud SDK 3.0 and above

我想获取用户信息和权限,但找不到任何接口。 但是在包 com.sap.cloud.sdk.cloudplatform.security 中有一个名为 AuthTokenAccessor 的接口。 我可以获得 JWT 令牌,但由于缺少信息而无法解析它,例如签名键。

String token = AuthTokenAccessor.getCurrentToken().getJwt().getToken();

在SAP Cloud SDK 2.0版本中,有一个接口UserAccessor可以满足要求,但是在3.X版本中好像没有了。

能否建议在 3.0 及以上版本中如何操作?

更新

PrincipalAccessor 接口就是答案。但是返回的授权是空的。 我正在使用 App 路由器访问后端 restful API。

 Set<Authorization> authorizations = principal.getAuthorizations();
 log.info("Authentication set is empty:" + authorizations.isEmpty());

SDK 版本为 3.15.1。

远程调试。属性和授权都是空的。

请改用PrincipalAccessorUserAccessor 已合并到更通用的 PrincipalAccessor

此外,从 Cloud SDK v2 迁移到 v3 时,请参考此 migration guide. You can also find release notes of the SDK here