Package org.apache.iotdb.commons.utils
Class AuthUtils
- java.lang.Object
-
- org.apache.iotdb.commons.utils.AuthUtils
-
public class AuthUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static PartialPathROOT_PATH_PRIVILEGE_PATH
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddPrivilege(PartialPath path, int privilegeId, java.util.List<PathPrivilege> privilegeList)Add privilegestatic booleancheckPrivilege(PartialPath path, int privilegeId, java.util.List<PathPrivilege> privilegeList)Check privilegestatic java.util.List<PartialPath>deserializePartialPathList(java.nio.ByteBuffer buffer)static java.lang.StringencryptPassword(java.lang.String password)Encrypt passwordstatic org.apache.iotdb.confignode.rpc.thrift.TPermissionInfoRespgenerateEmptyPermissionInfoResp()Generate empty permission response when failedstatic java.util.Set<java.lang.Integer>getPrivileges(PartialPath path, java.util.List<PathPrivilege> privilegeList)Get privilegesstatic booleanhasPrivilege(PartialPath path, int privilegeId, java.util.List<PathPrivilege> privilegeList)Check if series path has this privilegestatic voidremovePrivilege(PartialPath path, int privilegeId, java.util.List<PathPrivilege> privilegeList)Remove privilegestatic java.nio.ByteBufferserializePartialPathList(java.util.List<PartialPath> paths)static java.util.Set<java.lang.Integer>strToPermissions(java.lang.String[] authorizationList)Transform permission from name to privilegeIdstatic voidvalidatePassword(java.lang.String password)Validate passwordstatic booleanvalidatePassword(java.lang.String originPassword, java.lang.String encryptPassword)Checking whether origin password is mapping to encrypt password by encryptionstatic voidvalidatePath(PartialPath path)Validate pathstatic voidvalidatePrivilege(int privilegeId)Validate privilegestatic voidvalidatePrivilegeOnPath(PartialPath path, int privilegeId)Validate privilege on pathstatic voidvalidateRolename(java.lang.String rolename)Validate role namestatic voidvalidateUsername(java.lang.String username)Validate username
-
-
-
Field Detail
-
ROOT_PATH_PRIVILEGE_PATH
public static PartialPath ROOT_PATH_PRIVILEGE_PATH
-
-
Method Detail
-
validatePassword
public static void validatePassword(java.lang.String password) throws AuthExceptionValidate password- Parameters:
password- user password- Throws:
AuthException- contains message why password is invalid
-
validatePassword
public static boolean validatePassword(java.lang.String originPassword, java.lang.String encryptPassword)Checking whether origin password is mapping to encrypt password by encryption- Parameters:
originPassword- the password before encryptionencryptPassword- the password after encryption
-
validateUsername
public static void validateUsername(java.lang.String username) throws AuthExceptionValidate username- Parameters:
username- username- Throws:
AuthException- contains message why username is invalid
-
validateRolename
public static void validateRolename(java.lang.String rolename) throws AuthExceptionValidate role name- Parameters:
rolename- role name- Throws:
AuthException- contains message why rolename is invalid
-
validatePrivilege
public static void validatePrivilege(int privilegeId) throws AuthExceptionValidate privilege- Parameters:
privilegeId- privilege ID- Throws:
AuthException- contains message why privilege is invalid
-
validatePath
public static void validatePath(PartialPath path) throws AuthException
Validate path- Parameters:
path- series path- Throws:
AuthException- contains message why path is invalid
-
validatePrivilegeOnPath
public static void validatePrivilegeOnPath(PartialPath path, int privilegeId) throws AuthException
Validate privilege on path- Parameters:
path- the path of privilegeprivilegeId- privilege Id- Throws:
AuthException- contains message why path is invalid
-
encryptPassword
public static java.lang.String encryptPassword(java.lang.String password)
Encrypt password- Parameters:
password- password- Returns:
- encrypted password if success
-
checkPrivilege
public static boolean checkPrivilege(PartialPath path, int privilegeId, java.util.List<PathPrivilege> privilegeList) throws AuthException
Check privilege- Parameters:
path- series pathprivilegeId- privilege IdprivilegeList- privileges in List structure- Returns:
- True if privilege-check passed
- Throws:
AuthException- throw if path is invalid or path in privilege is invalid
-
getPrivileges
public static java.util.Set<java.lang.Integer> getPrivileges(PartialPath path, java.util.List<PathPrivilege> privilegeList) throws AuthException
Get privileges- Parameters:
path- The seriesPath on which the privileges take effect. If seriesPath-free privileges are desired, this should be null- Returns:
- The privileges granted to the role
- Throws:
AuthException- throw if path is invalid or path in privilege is invalid
-
hasPrivilege
public static boolean hasPrivilege(PartialPath path, int privilegeId, java.util.List<PathPrivilege> privilegeList)
Check if series path has this privilege- Parameters:
path- series pathprivilegeId- privilege IdprivilegeList- privileges in List structure- Returns:
- True if series path has this privilege
-
addPrivilege
public static void addPrivilege(PartialPath path, int privilegeId, java.util.List<PathPrivilege> privilegeList)
Add privilege- Parameters:
path- series pathprivilegeId- privilege IdprivilegeList- privileges in List structure of user or role
-
removePrivilege
public static void removePrivilege(PartialPath path, int privilegeId, java.util.List<PathPrivilege> privilegeList)
Remove privilege- Parameters:
path- series pathprivilegeId- privilege IdprivilegeList- privileges in List structure of user or role
-
generateEmptyPermissionInfoResp
public static org.apache.iotdb.confignode.rpc.thrift.TPermissionInfoResp generateEmptyPermissionInfoResp()
Generate empty permission response when failed
-
strToPermissions
public static java.util.Set<java.lang.Integer> strToPermissions(java.lang.String[] authorizationList) throws AuthExceptionTransform permission from name to privilegeId- Parameters:
authorizationList- the list of privilege name- Returns:
- the list of privilege Ids
- Throws:
AuthException- throws if there are no privilege matched
-
serializePartialPathList
public static java.nio.ByteBuffer serializePartialPathList(java.util.List<PartialPath> paths)
-
deserializePartialPathList
public static java.util.List<PartialPath> deserializePartialPathList(java.nio.ByteBuffer buffer)
-
-