public interface UserFacade
User information.| Modifier and Type | Method and Description |
|---|---|
User |
getCurrentUser()
Returns the current
User. |
Optional<User> |
getCurrentUserIfAuthenticated()
Returns the current
User, if authenticated. |
Optional<User> |
getUserByName(String name)
Returns a
User by its name, if it exists. |
Class<? extends User> |
getUserClass()
Returns the platform-specific implementation class of
User. |
Optional<User> |
resolveCurrentUser()
Resolves the current
User using the platform-specific lookup. |
io.vavr.control.Try<User> |
tryGetCurrentUser()
Returns a
Try for the current User. |
@Nonnull Class<? extends User> getUserClass()
User. For internal use only.@Nonnull Optional<User> resolveCurrentUser() throws UserAccessException
User using the platform-specific lookup. For internal use only.
Caution: This method must only be invoked within the container-managed thread of a request.
Optional of the current User.UserAccessException - If there is an issue while resolving the User.UserRequestContextListener@Nonnull User getCurrentUser() throws UserNotAuthenticatedException, UserAccessException
User.User.UserNotAuthenticatedException - If the User is currently not authenticated. This typically occurs when trying to access the
user within code that is running outside the context of a request, e.g., within a background task.
For more details on how user authentication is defined, refer to
getCurrentUserIfAuthenticated().UserAccessException - If there is an issue while accessing the User.@Nonnull Optional<User> getCurrentUserIfAuthenticated() throws UserAccessException
User, if authenticated.
The user authentication is defined as follows:
| User authenticated | User not authenticated | |
|---|---|---|
| SAP Cloud Platform Cloud Foundry | A request is present with an "Authorization" header that contains a valid JWT bearer with field "user_name". | A request is not available, no "Authorization" header is present in the current request, or the JWT bearer does not hold a field "user_name". |
| SAP Cloud Platform Neo | A request is present that holds an authenticated principal according to the UserProvider API. |
A request is not available or the user is not authenticated according to the UserProvider API. |
Optional of the current User.UserAccessException - If there is an issue while accessing the User.@Nonnull io.vavr.control.Try<User> tryGetCurrentUser()
Try for the current User.Try for the current User.@Nonnull Optional<User> getUserByName(@Nullable String name) throws UserAccessDeniedException, UserAccessException
User by its name, if it exists.name - The name of the User to find.UserAccessDeniedException - If accessing user information is denied.UserAccessException - If there is an issue while accessing the User.Copyright © 2019 SAP SE. All rights reserved.