Class PermissionUser.Builder
java.lang.Object
eu.cloudnetservice.driver.permission.PermissionUser.Builder
- All Implemented Interfaces:
DefaultedDocPropertyHolder,DefaultedDocPropertyHolder.Mutable<PermissionUser.Builder>,DefaultedDocPropertyHolder.Mutable.WithDirectModifier<PermissionUser.Builder>,DocPropertyHolder,DocPropertyHolder.Mutable<PermissionUser.Builder>
- Enclosing class:
- PermissionUser
public static final class PermissionUser.Builder
extends Object
implements DefaultedDocPropertyHolder.Mutable.WithDirectModifier<PermissionUser.Builder>
A builder for permission users.
- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface eu.cloudnetservice.driver.document.property.DefaultedDocPropertyHolder
DefaultedDocPropertyHolder.Mutable<S extends DocPropertyHolder.Mutable<S>>Nested classes/interfaces inherited from interface eu.cloudnetservice.driver.document.property.DefaultedDocPropertyHolder.Mutable
DefaultedDocPropertyHolder.Mutable.WithDirectModifier<S extends DocPropertyHolder.Mutable<S>>Nested classes/interfaces inherited from interface eu.cloudnetservice.driver.document.property.DocPropertyHolder
DocPropertyHolder.Mutable<S extends DocPropertyHolder.Mutable<S>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<String,Set<Permission>> private Set<PermissionUserGroupInfo>private Stringprivate Stringprivate Set<Permission>private intprivate Document.Mutableprivate 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 Document properties) Sets the properties of the new permission user.Get the underlying document that all read and write operations are delegated to.Sets the unique id of the new permission user.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.cloudnetservice.driver.document.property.DefaultedDocPropertyHolder
propertyAbsent, propertyPresent, readProperty, readPropertyOrDefault, readPropertyOrGet, readPropertyOrThrow, readPropertyOrThrowMethods inherited from interface eu.cloudnetservice.driver.document.property.DefaultedDocPropertyHolder.Mutable
removeProperty, writeProperty, writePropertyIfAbsent, writePropertyIfAbsent, writePropertyIfPresent, writePropertyIfPresentMethods inherited from interface eu.cloudnetservice.driver.document.property.DefaultedDocPropertyHolder.Mutable.WithDirectModifier
modifyAndSetProperties, modifyProperties
-
Field Details
-
name
-
uniqueId
-
hashedPassword
-
potency
private int potency -
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
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.
-
propertyHolder
Get the underlying document that all read and write operations are delegated to.- Specified by:
propertyHolderin interfaceDocPropertyHolder- Specified by:
propertyHolderin interfaceDocPropertyHolder.Mutable<PermissionUser.Builder>- Returns:
- the underlying document.
-
build
Constructs the new permission user from this builder.- Returns:
- the new permission user.
- Throws:
NullPointerException- if the name or unique id is missing.
-