Package ch.tocco.nice2.security.spi
Class DefaultGuard
java.lang.Object
ch.tocco.nice2.security.spi.DefaultGuard
- All Implemented Interfaces:
Guard
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.security.api.Guard
Guard.Decision
-
Constructor Summary
ModifierConstructorDescriptionprotected
DefaultGuard
(SecurityManager securityManager, ListGuard delegate) -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
askPermission
(Permission permission) Ask the guard for a specific permission.final boolean
askPermission
(String expression) Ask the guard for a specific permission.final void
checkPermission
(Permission permission) Ask the guard for a specific permission throwing an exception, if the permission is denied.final void
checkPermission
(String expression) Ask the guard for a specific permission throwing an exception, if the permission is denied.final Guard.Decision
evaluatePermission
(Permission permission) Evaluates a permission.Get the object this guard is protectingprotected abstract String
protected Permission
readPermission
(String expression)
-
Constructor Details
-
DefaultGuard
-
-
Method Details
-
askPermission
Description copied from interface:Guard
Ask the guard for a specific permission. This method is usually used by the user interface, e.g. to disable buttons.- Specified by:
askPermission
in interfaceGuard
- Parameters:
permission
- The permission to check.- Returns:
true
, if the permission is granted,false
, if it's denied.
-
askPermission
Description copied from interface:Guard
Ask the guard for a specific permission. This method is usually used by the user interface, e.g. to disable buttons.- Specified by:
askPermission
in interfaceGuard
- 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
Description copied from interface:Guard
Ask the guard for a specific permission throwing an exception, if the permission is denied. This method is usually used by the protected object.- Specified by:
checkPermission
in interfaceGuard
- Parameters:
permission
- The permission to check.- Throws:
UnauthorizedException
- If the permission is denied.
-
checkPermission
public final void checkPermission(String expression) throws UnauthorizedException, InvalidPermissionException Description copied from interface:Guard
Ask the guard for a specific permission throwing an exception, if the permission is denied. This method is usually used by the protected object.- Specified by:
checkPermission
in interfaceGuard
- 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.
-
evaluatePermission
Description copied from interface:Guard
Evaluates a permission. This method returns anGuard.Decision
providing some more information about *why* a permission is granted or denied.- Specified by:
evaluatePermission
in interfaceGuard
- Parameters:
permission
- The permission to evaluate.- Returns:
- An
Guard.Decision
.
-
readPermission
-
getSecurityDomainName
-
getPrincipal
- Specified by:
getPrincipal
in interfaceGuard
-
getSecured
Description copied from interface:Guard
Get the object this guard is protecting- Specified by:
getSecured
in interfaceGuard
- Returns:
- The object this guard is protecting.
-
getSecurityContext
- Specified by:
getSecurityContext
in interfaceGuard
-