public interface UserInfo
The current user refers to the authenticated user for whom the request context has been opened. All user information like ids, names, roles, tenant and user attributes are assumed to be verified, i.e. they are secured by adequate means like JWT verification.
Modifier and Type | Method and Description |
---|---|
<T extends UserInfo> |
as(Class<T> concreteUserInfoClazz)
Provides type-safe access to
UserInfo and additional attributes. |
Object |
getAdditionalAttribute(String name)
Returns additional attribute with given name if existing.
|
Stream<String> |
getAttribute(String attribute)
Returns the verified value of the specified attribute as presented in the request.
|
String |
getId()
Returns the verified user id of the request's authenticated user.
|
String |
getName()
Returns the verified user name of the request's authenticated user.
|
String |
getTenant()
Returns the verified tenant of the request's authenticated user.
|
boolean |
hasRole(String role)
Checks if the current user is associated with the specified user role.
|
boolean |
isAuthenticated()
Returns
true if UserInfo is filled with data of an authenticated user |
boolean |
isSystemUser()
Returns
true if the user is a system user and not a named user. |
boolean |
isUnrestrictedAttribute(String attribute)
Returns
true if the passed attribute is unrestricted, i.e. |
String getId()
String getName()
String getTenant()
boolean isSystemUser()
true
if the user is a system user and not a named user.true
if the user is a system user and not a named user.boolean hasRole(String role)
role
- The name of the roletrue
if role is present, false
otherwiseStream<String> getAttribute(String attribute)
attribute
- The name of the attributenull
if not existingboolean isUnrestrictedAttribute(String attribute)
true
if the passed attribute is unrestricted, i.e. the current user has no restrictions with respect to this attribute.attribute
- The name of the attribute.true
if unrestricted, false
otherwise.boolean isAuthenticated()
true
if UserInfo
is filled with data of an authenticated usertrue
if UserInfo
is filled with data of an authenticated userObject getAdditionalAttribute(String name)
name
- The name of the attributeObject
<T extends UserInfo> T as(Class<T> concreteUserInfoClazz)
UserInfo
and additional attributes.
Creates a concrete proxy instance implementing UserInfo
and a sub interface concreteUserInfoClazz
which has a concrete API for the additional attributes according to the chosen authentication.Example:
XsuaaUserInfo xsuaaUser = eventContext.getUserInfo().as(XsuaaUserInfo.class);
T
- the type of the concrete UserInfo
interface.concreteUserInfoClazz
- The sub interface providing the concrete API of additional attributes.UserInfo
and concreteUserInfoClazz
.Copyright © 2020. All rights reserved.