public class MetaDataRoleAuthorizationStrategy extends AbstractRoleAuthorizationStrategy
authorize methods are for authorizing component actions and component instantiation
by role. This class is the main entry point for users wanting to use the roles-based
authorization of the wicket-auth-roles package based on wicket metadata.
For instance, use like:
MetaDataRoleAuthorizationStrategy.authorize(myPanel, RENDER, "ADMIN");for actions on component instances, or:
MetaDataRoleAuthorizationStrategy.authorize(AdminBookmarkablePage.class, "ADMIN");for doing role based authorization for component instantation.
MetaDataKey| Modifier and Type | Field and Description |
|---|---|
static MetaDataKey<ActionPermissions> |
ACTION_PERMISSIONS
Component meta data key for actions/roles information.
|
static MetaDataKey<InstantiationPermissions> |
INSTANTIATION_PERMISSIONS
Application meta data key for actions/roles information.
|
static String |
NO_ROLE
Special role string for denying access to all
|
ALLOW_ALL| Constructor and Description |
|---|
MetaDataRoleAuthorizationStrategy(IRoleCheckingStrategy roleCheckingStrategy)
Construct.
|
| Modifier and Type | Method and Description |
|---|---|
static <T extends Component> |
authorize(Class<T> componentClass,
String roles)
Authorizes the given role to create component instances of type componentClass.
|
static void |
authorize(Component component,
Action action,
String roles)
Authorizes the given role to perform the given action on the given component.
|
static <T extends Component> |
authorizeAll(Class<T> componentClass)
Grants permission to all roles to create instances of the given component class.
|
static void |
authorizeAll(Component component,
Action action)
Grants permission to all roles to perform the given action on the given component.
|
boolean |
isActionAuthorized(Component component,
Action action)
Uses component level meta data to match roles for component action execution.
|
<T extends IRequestableComponent> |
isInstantiationAuthorized(Class<T> componentClass)
Uses application level meta data to match roles for component instantiation.
|
static <T extends Component> |
unauthorize(Class<T> componentClass,
String roles)
Removes permission for the given roles to create instances of the given component class.
|
static void |
unauthorize(Component component,
Action action,
String roles)
Removes permission for the given role to perform the given action on the given component.
|
static <T extends Component> |
unauthorizeAll(Class<T> componentClass)
Grants authorization to instantiate the given class to just the role NO_ROLE, effectively
denying all other roles.
|
static void |
unauthorizeAll(Component component,
Action action)
Grants authorization to perform the given action to just the role NO_ROLE, effectively
denying all other roles.
|
hasAny, isEmptypublic static final MetaDataKey<ActionPermissions> ACTION_PERMISSIONS
public static final MetaDataKey<InstantiationPermissions> INSTANTIATION_PERMISSIONS
public static final String NO_ROLE
public MetaDataRoleAuthorizationStrategy(IRoleCheckingStrategy roleCheckingStrategy)
roleCheckingStrategy - the authorizer objectpublic static final <T extends Component> void authorize(Class<T> componentClass, String roles)
T - componentClass - The component type that is subject for the authorizationroles - The comma separated roles that are authorized to create component instances of
type componentClasspublic static final void authorize(Component component, Action action, String roles)
component - The component that is subject to the authorizationaction - The action to authorizeroles - The comma separated roles to authorizepublic static final <T extends Component> void authorizeAll(Class<T> componentClass)
T - componentClass - The component classpublic static final void authorizeAll(Component component, Action action)
component - The component that is subject to the authorizationaction - The action to authorizepublic static final <T extends Component> void unauthorize(Class<T> componentClass, String roles)
T - componentClass - The component typeroles - The comma separated list of roles that are no longer to be authorized to create
instances of type componentClasspublic static final void unauthorize(Component component, Action action, String roles)
component - The componentaction - The actionroles - The comma separated list of roles that are no longer allowed to perform the given
actionpublic static final <T extends Component> void unauthorizeAll(Class<T> componentClass)
T - componentClass - The component classpublic static final void unauthorizeAll(Component component, Action action)
component - the component that is subject to the authorizationaction - the action to authorizepublic boolean isActionAuthorized(Component component, Action action)
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass)
Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.