Class PermissionUser.Builder
java.lang.Object
eu.cloudnetservice.driver.permission.PermissionUser.Builder
- Enclosing class:
- PermissionUser
A builder for permission users.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<String,Set<Permission>> private Set<PermissionUserGroupInfo>private Stringprivate Stringprivate Set<Permission>private intprivate eu.cloudnetservice.common.document.gson.JsonDocumentprivate UUID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds the given group to the groups of the new user.addPermission(@NonNull Permission permission) Adds the given permission to the permissions of the new user.build()Constructs the new permission user from this builder.groupPermissions(@NonNull Map<String, Set<Permission>> groupPermissions) Sets the group permissions of the new permission user.groups(@NonNull Collection<PermissionUserGroupInfo> groups) Sets the groups of the new permission user.hashedPassword(@Nullable String hashedPassword) Sets the already hashed password for the new permission user.Sets the name of the new permission user.Sets the raw password of the new permission user.permissions(@NonNull Collection<Permission> permissions) Sets the permissions of the new permission user.potency(int potency) Sets the potency of the new permission user.properties(@NonNull eu.cloudnetservice.common.document.gson.JsonDocument properties) Sets the properties of the new permission user.Sets the unique id of the new permission user.
-
Field Details
-
name
-
uniqueId
-
hashedPassword
-
potency
private int potency -
properties
private eu.cloudnetservice.common.document.gson.JsonDocument properties -
permissions
-
groups
-
groupPermissions
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
name
Sets the name of the new permission user.- Parameters:
name- the name for the new user.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given name is null.
-
uniqueId
Sets the unique id of the new permission user.- Parameters:
uniqueId- the unique id for the new user.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given unique id is null.
-
password
Sets the raw password of the new permission user. The given input is hashed using SHA-256 and encoded using Base64.- Parameters:
password- the password for the new user.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given password is null.
-
hashedPassword
@NonNull public @NonNull PermissionUser.Builder hashedPassword(@Nullable @Nullable String hashedPassword) Sets the already hashed password for the new permission user. The password should be hashed using SHA-256 and encoded using Base64.- Parameters:
hashedPassword- the hashed password for the new user.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given hashed password is null.
-
potency
Sets the potency of the new permission user.- Parameters:
potency- the potency for the new user.- Returns:
- the same instance as used to call the method, for chaining.
-
permissions
@NonNull public @NonNull PermissionUser.Builder permissions(@NonNull @NonNull Collection<Permission> permissions) Sets the permissions of the new permission user.- Parameters:
permissions- the permissions for the new user.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given permission collection is null.
-
addPermission
@NonNull public @NonNull PermissionUser.Builder addPermission(@NonNull @NonNull Permission permission) Adds the given permission to the permissions of the new user.- Parameters:
permission- the permission to add to the new user.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given permission is null.
-
groups
@NonNull public @NonNull PermissionUser.Builder groups(@NonNull @NonNull Collection<PermissionUserGroupInfo> groups) Sets the groups of the new permission user.- Parameters:
groups- the groups for the new user.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given group collection is null.
-
addGroup
@NonNull public @NonNull PermissionUser.Builder addGroup(@NonNull @NonNull PermissionUserGroupInfo group) Adds the given group to the groups of the new user.- Parameters:
group- the group to add to the new user.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given group is null.
-
groupPermissions
@NonNull public @NonNull PermissionUser.Builder groupPermissions(@NonNull @NonNull Map<String, Set<Permission>> groupPermissions) Sets the group permissions of the new permission user.- Parameters:
groupPermissions- the group specific permissions for the new user.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given group permissions are null.
-
properties
@NonNull public @NonNull PermissionUser.Builder properties(@NonNull @NonNull eu.cloudnetservice.common.document.gson.JsonDocument properties) Sets the properties of the new permission user.- Parameters:
properties- the properties for the new user.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given properties are null.
-
build
Constructs the new permission user from this builder.- Returns:
- the new permission user.
- Throws:
NullPointerException- if the name or unique id is missing.
-