Package org.molgenis.security.core.utils
Class SecurityUtils
- java.lang.Object
-
- org.molgenis.security.core.utils.SecurityUtils
-
public class SecurityUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringANONYMOUS_USERNAMEstatic java.lang.StringAUTHORITY_ANONYMOUSstatic java.lang.StringAUTHORITY_SUstatic java.lang.StringAUTHORITY_USERstatic java.lang.StringROLE_ACL_GENERAL_CHANGESstatic java.lang.StringROLE_ACL_MODIFY_AUDITINGstatic java.lang.StringROLE_ACL_TAKE_OWNERSHIPstatic java.lang.StringROLE_SYSTEM
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancurrentUserHasRole(java.lang.String... roles)Returns whether the current user has at least one of the given rolesstatic booleancurrentUserIsAnonymous()static booleancurrentUserIsAuthenticated()Returns whether the current user is authenticated and not the anonymous userstatic booleancurrentUserIsSu()Returns whether the current user is a super userstatic booleancurrentUserIsSuOrSystem()Returns whether the current user is a superuser or the system user.static booleancurrentUserIsSystem()Returns whether the current user is the system user.static java.lang.StringgetCurrentUsername()Returns the username of the current authentication.
-
-
-
Field Detail
-
ANONYMOUS_USERNAME
public static final java.lang.String ANONYMOUS_USERNAME
- See Also:
- Constant Field Values
-
AUTHORITY_SU
public static final java.lang.String AUTHORITY_SU
- See Also:
- Constant Field Values
-
AUTHORITY_ANONYMOUS
public static final java.lang.String AUTHORITY_ANONYMOUS
- See Also:
- Constant Field Values
-
AUTHORITY_USER
public static final java.lang.String AUTHORITY_USER
- See Also:
- Constant Field Values
-
ROLE_SYSTEM
public static final java.lang.String ROLE_SYSTEM
- See Also:
- Constant Field Values
-
ROLE_ACL_TAKE_OWNERSHIP
public static final java.lang.String ROLE_ACL_TAKE_OWNERSHIP
- See Also:
- Constant Field Values
-
ROLE_ACL_MODIFY_AUDITING
public static final java.lang.String ROLE_ACL_MODIFY_AUDITING
- See Also:
- Constant Field Values
-
ROLE_ACL_GENERAL_CHANGES
public static final java.lang.String ROLE_ACL_GENERAL_CHANGES
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCurrentUsername
@Nullable @CheckForNull public static java.lang.String getCurrentUsername()
Returns the username of the current authentication.- Returns:
- username or null if 1) the current authentication is null or 2) the currently authenticated principal is the system.
-
currentUserHasRole
public static boolean currentUserHasRole(java.lang.String... roles)
Returns whether the current user has at least one of the given roles
-
currentUserIsSuOrSystem
public static boolean currentUserIsSuOrSystem()
Returns whether the current user is a superuser or the system user.
-
currentUserIsSu
public static boolean currentUserIsSu()
Returns whether the current user is a super user
-
currentUserIsSystem
public static boolean currentUserIsSystem()
Returns whether the current user is the system user.
-
currentUserIsAuthenticated
public static boolean currentUserIsAuthenticated()
Returns whether the current user is authenticated and not the anonymous user
-
currentUserIsAnonymous
public static boolean currentUserIsAnonymous()
-
-