Package org.molgenis.security.core.utils
Class SecurityUtils
- java.lang.Object
-
- org.molgenis.security.core.utils.SecurityUtils
-
public class SecurityUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringANONYMOUS_USERNAMEstatic StringAUTHORITY_ANONYMOUSstatic StringAUTHORITY_SUstatic StringAUTHORITY_USERstatic StringROLE_ACL_GENERAL_CHANGESstatic StringROLE_ACL_MODIFY_AUDITINGstatic StringROLE_ACL_TAKE_OWNERSHIPstatic StringROLE_SYSTEM
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancurrentUserHasRole(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 StringgetCurrentUsername()Returns the username of the current authentication.
-
-
-
Field Detail
-
ANONYMOUS_USERNAME
public static final String ANONYMOUS_USERNAME
- See Also:
- Constant Field Values
-
AUTHORITY_SU
public static final String AUTHORITY_SU
- See Also:
- Constant Field Values
-
AUTHORITY_ANONYMOUS
public static final String AUTHORITY_ANONYMOUS
- See Also:
- Constant Field Values
-
AUTHORITY_USER
public static final String AUTHORITY_USER
- See Also:
- Constant Field Values
-
ROLE_SYSTEM
public static final String ROLE_SYSTEM
- See Also:
- Constant Field Values
-
ROLE_ACL_TAKE_OWNERSHIP
public static final String ROLE_ACL_TAKE_OWNERSHIP
- See Also:
- Constant Field Values
-
ROLE_ACL_MODIFY_AUDITING
public static final String ROLE_ACL_MODIFY_AUDITING
- See Also:
- Constant Field Values
-
ROLE_ACL_GENERAL_CHANGES
public static final String ROLE_ACL_GENERAL_CHANGES
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCurrentUsername
@Nullable @CheckForNull public static 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(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()
-
-