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 org.apache.wicket.MetaDataKey<ActionPermissions> |
ACTION_PERMISSIONS
Component meta data key for actions/roles information.
|
static org.apache.wicket.MetaDataKey<InstantiationPermissions> |
INSTANTIATION_PERMISSIONS
Application meta data key for actions/roles information.
|
static String |
NO_ROLE
Special role string for denying access to all
|
| Constructor and Description |
|---|
MetaDataRoleAuthorizationStrategy(IRoleCheckingStrategy roleCheckingStrategy)
Construct.
|
| Modifier and Type | Method and Description |
|---|---|
static <T extends org.apache.wicket.Component> |
authorize(Class<T> componentClass,
String roles)
Authorizes the given role to create component instances of type componentClass.
|
static void |
authorize(org.apache.wicket.Component component,
org.apache.wicket.authorization.Action action,
String roles)
Authorizes the given role to perform the given action on the given component.
|
static <T extends org.apache.wicket.Component> |
authorizeAll(Class<T> componentClass)
Grants permission to all roles to create instances of the given component class.
|
static void |
authorizeAll(org.apache.wicket.Component component,
org.apache.wicket.authorization.Action action)
Grants permission to all roles to perform the given action on the given component.
|
boolean |
isActionAuthorized(org.apache.wicket.Component component,
org.apache.wicket.authorization.Action action)
Uses component level meta data to match roles for component action execution.
|
<T extends org.apache.wicket.request.component.IRequestableComponent> |
isInstantiationAuthorized(Class<T> componentClass)
Uses application level meta data to match roles for component instantiation.
|
static <T extends org.apache.wicket.Component> |
unauthorize(Class<T> componentClass,
String roles)
Removes permission for the given roles to create instances of the given component class.
|
static void |
unauthorize(org.apache.wicket.Component component,
org.apache.wicket.authorization.Action action,
String roles)
Removes permission for the given role to perform the given action on the given component.
|
static <T extends org.apache.wicket.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(org.apache.wicket.Component component,
org.apache.wicket.authorization.Action action)
Grants authorization to perform the given action to just the role NO_ROLE, effectively
denying all other roles.
|
hasAny, isEmptypublic static final org.apache.wicket.MetaDataKey<ActionPermissions> ACTION_PERMISSIONS
public static final org.apache.wicket.MetaDataKey<InstantiationPermissions> INSTANTIATION_PERMISSIONS
public static final String NO_ROLE
public MetaDataRoleAuthorizationStrategy(IRoleCheckingStrategy roleCheckingStrategy)
roleCheckingStrategy - the authorizer objectpublic static <T extends org.apache.wicket.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 void authorize(org.apache.wicket.Component component,
org.apache.wicket.authorization.Action action,
String roles)
component - The component that is subject to the authorizationaction - The action to authorizeroles - The comma separated roles to authorizepublic static <T extends org.apache.wicket.Component> void authorizeAll(Class<T> componentClass)
T - componentClass - The component classpublic static void authorizeAll(org.apache.wicket.Component component,
org.apache.wicket.authorization.Action action)
component - The component that is subject to the authorizationaction - The action to authorizepublic static <T extends org.apache.wicket.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 void unauthorize(org.apache.wicket.Component component,
org.apache.wicket.authorization.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 <T extends org.apache.wicket.Component> void unauthorizeAll(Class<T> componentClass)
T - componentClass - The component classpublic static void unauthorizeAll(org.apache.wicket.Component component,
org.apache.wicket.authorization.Action action)
component - the component that is subject to the authorizationaction - the action to authorizepublic boolean isActionAuthorized(org.apache.wicket.Component component,
org.apache.wicket.authorization.Action action)
isActionAuthorized in interface org.apache.wicket.authorization.IAuthorizationStrategyisActionAuthorized in class org.apache.wicket.authorization.IAuthorizationStrategy.AllowAllAuthorizationStrategyIAuthorizationStrategy.isActionAuthorized(org.apache.wicket.Component,
org.apache.wicket.authorization.Action)public <T extends org.apache.wicket.request.component.IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass)
isInstantiationAuthorized in interface org.apache.wicket.authorization.IAuthorizationStrategyisInstantiationAuthorized in class org.apache.wicket.authorization.IAuthorizationStrategy.AllowAllAuthorizationStrategyIAuthorizationStrategy.isInstantiationAuthorized(java.lang.Class)Copyright © 2006–2021 Apache Software Foundation. All rights reserved.