- How to add this library to your project
- Getting started
- PermissionOwner
- DefaultPermissionManager customization
<dependency>
<groupId>io.github.edmondantes</groupId>
<artifactId>simple-permissions</artifactId>
<version>0.1.0</version>
</dependency>
implementation("io.github.edmondantes:simple-permissions:0.1.0")
implementation "io.github.edmondantes:simple-permissions:0.1.0"
The main class for managing is PermissionManager
. You can use default implementation: DefaultPermissionManager
.
val supportPermissions = listOf("permission.one", "permission.two")
val permissionManager = DefaultPermissionManager(
InMemoryPermissionGroupStorage(),
InMemoryPermissionNodeStorage(),
ConstantPermissionStorage(supportPermissions),
defaultGroupName = "default",
superAdminGroupName = "admin"
)
permissionManager.grant("default", "permission.one")
// ...
permissionManager.group("default").checkPermission("permission.one")
Method group
and groupOrDefault
in PermissionManager
return object of class PermissionOwner
. This class helps to
check which permissions was granted to specified group.
DefaultPermissionManager
has 7 arguments in constructor, so you can customize they.
Store information about groups Default implementation: InMemoryPermissionGroupStorage
- store data in variables
Store information about permissions in groups Default implementation: InMemoryPermissionNodeStorage
- store data in
variables
Store information about support permissions Default implementation: ConstantPermissionStorage
- It is created from
list of permissions and store it.
It will be called if user want to replace groups. GroupReplacer
should replace one group to another. Default
implementation: EmptyGroupReplacer
- It doesn't do anything
It helps to transform string to permissions parts. Default implementation: DefaultPermissionMapperToNodeValue
- It
transforms string with default format to permissions parts
You can set default group name. For default this feature is disabled.
WARNING!!! This group has been granted all permissions!!! You can set admin group name. For default this feature is disabled.