-
Notifications
You must be signed in to change notification settings - Fork 34
Custom permission handlers #105
base: main
Are you sure you want to change the base?
Custom permission handlers #105
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some ideas so these changes are less breaking. Some code may expect getPermission
, getAllPermissions
, removePermission
, hasPermission
, addPermission
by implementing these in the DefaultPermissionHandler existing code can expect the same behaviour.
I like the changes so far, this makes it easier to sync permissions with a database.
* @return the permissions of this handler. | ||
*/ | ||
@NotNull | ||
Set<Permission> getAllPermissions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be readded (to this interface) and implemented in DefaultPermissionHandler.
* | ||
* @param permissionName the permission name | ||
*/ | ||
default void removePermission(@NotNull String permissionName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be readded (to this interface) and implemented in DefaultPermissionHandler.
* @return the permission from its name, null if not found | ||
*/ | ||
@Nullable | ||
default Permission getPermission(@NotNull String permissionName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be readded (to this interface) and implemented in DefaultPermissionHandler.
* null means that only the permission name will be used | ||
* @return true if the handler has the permission, false otherwise | ||
*/ | ||
default boolean hasPermission(@NotNull String permissionName, @Nullable PermissionVerifier permissionVerifier) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be readded (to this interface) and implemented in DefaultPermissionHandler.
/** | ||
* A default permission handler. Used when no custom permission handler is set. | ||
*/ | ||
public final class DefaultPermissionHandler implements PermissionHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class should implement the changes suggested in PermissionHandler. The implementations should have the same behaviour as before.
Adds a way to add custom permission handlers.
It's api breaking, however it's useful for me and may be useful for others who create their own permission system.