User
Overview
Module
- package:
org.eclipse.dirigible.sdk.security - source: security/User.java
Identity and role lookup for the user behind the current request. The methods return whatever the platform's authentication chain populated — Spring Security principal, OIDC subject, basic-auth username, etc.
isInRole(role) is the authoritative check used by @Roles dispatch in controllers; getRoles() returns the full set if you need to make a finer-grained decision inside a method body.
In an unauthenticated context (anonymous request, scheduled job) the user name resolves to the platform's anonymous user; role checks then defer to the platform's anonymous-mode configuration.
Key Features:
- Auth-chain agnostic — same surface across Spring Security, OIDC, basic auth.
- Authoritative role check —
isInRolematches what@Rolesdispatch uses. - Anonymous fallback — clean defaults in non-request contexts (jobs, listeners).
Example Usage:
import org.eclipse.dirigible.sdk.security.User;
String who = User.getName();
boolean isAdmin = User.isInRole("admin");
String lang = User.getLanguage();Methods
getName()
Returns the authenticated user name (or the anonymous user name when unauthenticated).
javapublic static String getName();Returns
- Type:
String- Description: User name from the platform's authentication context.
isInRole()
Checks whether the current user holds the given role.
javapublic static boolean isInRole(String role);
Parameter Type Description roleStringRole name to check. Returns
- Type:
boolean- Description:
trueif the user has the role;falseotherwise.
getRoles()
Returns the full set of role names assigned to the user.
javapublic static Collection<String> getRoles();Returns
- Type:
Collection<String>- Description: All roles for the user.
getAuthType()
Returns the authentication mechanism used (e.g. BASIC, OAUTH2).
javapublic static String getAuthType();
getSecurityToken()
Returns the user's security token, if one is available on the current request.
javapublic static String getSecurityToken();
getInvocationCount()
Returns a platform-managed invocation counter for the current session.
javapublic static String getInvocationCount();
getLanguage()
Returns the user's preferred language code (e.g. en, de).
javapublic static String getLanguage();
getTimeout()
Returns the session timeout for the user, in seconds.
javapublic static Integer getTimeout();