This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package ru.soune.nocopy.entity.user;
|
||||
|
||||
public class Permission {
|
||||
public static final long LOGIN_BIT = 1L << 0;
|
||||
public static final long COMPANY_SETTINGS_BIT = 1L << 1;
|
||||
public static final long DEFAULT_USER_PERMISSIONS = LOGIN_BIT;
|
||||
public static final long COMPANY_ADMIN_PERMISSIONS =
|
||||
LOGIN_BIT | COMPANY_SETTINGS_BIT;
|
||||
public static final long SUPER_ADMIN_PERMISSIONS = -1L;
|
||||
|
||||
public static boolean hasPermission(long userPermissions, long permissionBit) {
|
||||
return (userPermissions & permissionBit) != 0;
|
||||
}
|
||||
|
||||
public static long addPermission(long userPermissions, long permissionBit) {
|
||||
return userPermissions | permissionBit;
|
||||
}
|
||||
|
||||
public static long removePermission(long userPermissions, long permissionBit) {
|
||||
return userPermissions & ~permissionBit;
|
||||
}
|
||||
|
||||
public static boolean canLogin(long userPermissions) {
|
||||
return hasPermission(userPermissions, LOGIN_BIT);
|
||||
}
|
||||
|
||||
public static boolean canManageCompanySettings(long userPermissions) {
|
||||
return hasPermission(userPermissions, COMPANY_SETTINGS_BIT);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user