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
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe result of a permission evaluation. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaskPermission(Permission permission) Ask the guard for a specific permission.booleanaskPermission(String expression) Ask the guard for a specific permission.voidcheckPermission(Permission permission) Ask the guard for a specific permission throwing an exception, if the permission is denied.voidcheckPermission(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.Decisionproviding 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()
-