Package ch.tocco.nice2.security.api
Interface Guard
- All Known Implementing Classes:
DefaultGuard
public interface Guard
The
Guard
protects a single object.- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The result of a permission evaluation. -
Method Summary
Modifier and TypeMethodDescriptionboolean
askPermission
(Permission permission) Ask the guard for a specific permission.boolean
askPermission
(String expression) Ask the guard for a specific permission.void
checkPermission
(Permission permission) Ask the guard for a specific permission throwing an exception, if the permission is denied.void
checkPermission
(String expression) Ask the guard for a specific permission throwing an exception, if the permission is denied.evaluatePermission
(Permission permission) Evaluates a permission.Get the object this guard is protecting
-
Method Details
-
getPrincipal
Principal getPrincipal() -
getSecured
Object getSecured()Get the object this guard is protecting- Returns:
- The object this guard is protecting.
-
evaluatePermission
Evaluates a permission. This method returns anGuard.Decision
providing some more information about *why* a permission is granted or denied.- Parameters:
permission
- The permission to evaluate.- Returns:
- An
Guard.Decision
.
-
askPermission
Ask the guard for a specific permission. This method is usually used by the user interface, e.g. to disable buttons.- Parameters:
permission
- The permission to check.- Returns:
true
, if the permission is granted,false
, if it's denied.
-
askPermission
Ask the guard for a specific permission. This method is usually used by the user interface, e.g. to disable buttons.- Parameters:
expression
- The permission to check as permission string.- Returns:
true
, if the permission is granted,false
, if it's denied.- Throws:
InvalidPermissionException
- If the permission string cannot be parsed or mapped to a permission object.
-
checkPermission
Ask the guard for a specific permission throwing an exception, if the permission is denied. This method is usually used by the protected object.- Parameters:
permission
- The permission to check.- Throws:
UnauthorizedException
- If the permission is denied.
-
checkPermission
Ask the guard for a specific permission throwing an exception, if the permission is denied. This method is usually used by the protected object.- Parameters:
expression
- The permission to check as permission string.- Throws:
UnauthorizedException
- If the permission is denied.InvalidPermissionException
- If the permission string cannot be parsed or mapped to a permission object.
-
getSecurityContext
SecurityContext getSecurityContext()
-