The class com.sap.cloud.sdk.cloudplatform.security.user.UserAccessor allows to me to retrieve the current user and it's attributes.
For example:
Optional<UserAttribute> optionalfirstName = user.getAttribute("firstname");
UserAttribute ua = optionalfirstName.get();
Once I have retrieved the UserAttribute, it has two properites "Name" and "Value". However there is no method available to get the Value. How can I access the value?
Depending on the SAP CP environment you are using, the UserAttribute is an instance of:
SimpleUserAttribute<String>
on NeoCollectionUserAttribute<String>
on Cloud FoundryYou can access the respective values by type-casting to the required instance:
Note: We plan to simplify this in future releases of the SDK so that
StringUserAttribute
andStringCollectionUserAttribute
instances are returned for more convenient consumption.