Package com.codingchili.core.protocol
Class SimpleAuthorizationHandler<T>
java.lang.Object
com.codingchili.core.protocol.SimpleAuthorizationHandler<T>
- All Implemented Interfaces:
AuthorizationHandler<T>
Maps roles to routes.
A route with an access level of 25 is not accessible by other roles with the same access level. To share a single route with multiple roles with the same access level assign multiple roles to a route.
A role with a higher access level may execute any route protected by a role with a weaker access level.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Retrieves the RequestHandler of a route matching the route id and that any of the given roles have permission to.list()
void
Adds a new route to the handler.
-
Constructor Details
-
SimpleAuthorizationHandler
public SimpleAuthorizationHandler()
-
-
Method Details
-
use
Description copied from interface:AuthorizationHandler
Adds a new route to the handler.- Specified by:
use
in interfaceAuthorizationHandler<T>
- Parameters:
route
- the route to add
-
get
public RequestHandler<T> get(String route, RoleType role) throws AuthorizationRequiredException, HandlerMissingExceptionDescription copied from interface:AuthorizationHandler
Retrieves the RequestHandler of a route matching the route id and that any of the given roles have permission to.- Specified by:
get
in interfaceAuthorizationHandler<T>
- Parameters:
route
- the id of the route to retrieverole
- the role used in the authorization check- Returns:
- a request handler used for the route.
- Throws:
AuthorizationRequiredException
- when a route exists but none of the given roles has permission to execute it.HandlerMissingException
- when the requested route is missing.
-
contains
- Specified by:
contains
in interfaceAuthorizationHandler<T>
- Parameters:
route
- id of the route to check if it is contained in the handler.- Returns:
- true if the route is registered.
-
list
- Specified by:
list
in interfaceAuthorizationHandler<T>
- Returns:
- all routes that has been added to the handler.
-