本文整理汇总了Java中org.apache.wicket.authorization.Action类的典型用法代码示例。如果您正苦于以下问题:Java Action类的具体用法?Java Action怎么用?Java Action使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Action类属于org.apache.wicket.authorization包,在下文中一共展示了Action类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isActionAuthorized
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
public boolean isActionAuthorized(Component component, Action action) {
boolean ret ;
String path = component.getPage().getClass().getSimpleName()+"."+component.getId()+"."+action.getName();
String superPath = component.getPage().getClass().getSuperclass().getSimpleName()+"."+component.getId()+"."+action.getName();
Properties securityProperties = loadSecurityProperties();
if(isInSecurityPath(path, securityProperties)) {
ret = isComponentAllowed(path, securityProperties);
} else if(isInSecurityPath(superPath, securityProperties)) {
ret = isComponentAllowed(superPath, securityProperties);
} else if (component.getClass().isAnnotationPresent(Secured.class)) {
ret = SecurityUtils.isComponentVisible(component.getClass());
} else if (component instanceof BookmarkablePageLink<?>) {
BookmarkablePageLink<?> link = (BookmarkablePageLink<?>) component;
ret = SecurityUtils.isComponentVisible(link.getPageClass());
} else {
ret = true;
}
return ret;
}
示例2: isActionAuthorized
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
@Override
public boolean isActionAuthorized(Component component, Action action) {
boolean ret ;
String path = component.getPage().getClass().getSimpleName()+"."+component.getId()+"."+action.getName();
String superPath = component.getPage().getClass().getSuperclass().getSimpleName()+"."+component.getId()+"."+action.getName();
Properties securityProperties = loadSecurityProperties();
if(isInSecurityPath(path, securityProperties)) {
ret = isComponentAllowed(path, securityProperties);
} else if(isInSecurityPath(superPath, securityProperties)) {
ret = isComponentAllowed(superPath, securityProperties);
} else if (component.getClass().isAnnotationPresent(Secured.class)) {
ret = SecurityUtils.isComponentVisible(component.getClass());
} else if (component instanceof BookmarkablePageLink<?>) {
BookmarkablePageLink<?> link = (BookmarkablePageLink<?>) component;
ret = SecurityUtils.isComponentVisible(link.getPageClass());
} else {
ret = true;
}
return ret;
}
示例3: isActionAuthorized
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
private boolean isActionAuthorized(final Class<?> componentClass, final Action action) {
// Check for a single action
if (!check(action, componentClass.getAnnotation(AuthorizeAction.class))) {
return false;
}
// Check for multiple actions
final AuthorizeActions authorizeActionsAnnotation = componentClass.getAnnotation(AuthorizeActions.class);
if (authorizeActionsAnnotation != null) {
for (final AuthorizeAction authorizeActionAnnotation : authorizeActionsAnnotation.actions()) {
if (!check(action, authorizeActionAnnotation)) {
return false;
}
}
}
return true;
}
示例4: check
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
/**
* @param action
* The action to check
* @param authorizeActionAnnotation
* The annotations information
* @return False if the action is not authorized
*/
private boolean check(final Action action, final AuthorizeAction authorizeActionAnnotation) {
if (authorizeActionAnnotation != null) {
if (action.getName().equals(authorizeActionAnnotation.action())) {
Role[] deniedRoles = authorizeActionAnnotation.deny();
if ((!isEmpty(deniedRoles)) && hasAny(deniedRoles)) {
return false;
}
Role[] acceptedRoles = authorizeActionAnnotation.roles();
if (!(isEmpty(acceptedRoles) || hasAny(acceptedRoles))) {
return false;
}
}
}
return true;
}
示例5: isActionAuthorized
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
/**
* Uses component level meta data to match levels for component action
* execution.
*
* @see
* org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
* org.apache.wicket.authorization.Action)
*/
@Override
public boolean isActionAuthorized(final Component component, final Action action) {
if (component == null) {
throw new IllegalArgumentException("argument component has to be not null");
}
if (action == null) {
throw new IllegalArgumentException("argument action has to be not null");
}
final EnumSet<Role> roles = levelsAuthorizedToPerformAction(component, action);
if (roles != null) {
return hasAny(roles);
}
return true;
}
示例6: authorize
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
/**
* Gives permission for the given roles to perform the given action
*
* @param action The action
* @param rolesToAuthorize The roles that will be authorized to perform the
* action
*/
public final void authorize(final Action action, Role... rolesToAuthorize) {
if (action == null) {
throw new IllegalArgumentException("Argument action cannot be null");
}
if (rolesToAuthorize == null) {
throw new IllegalArgumentException("Argument rolesToAuthorize cannot be null");
}
EnumSet<Role> roleslevels = authorizedRolesForAction.get(action);
if (roleslevels == null) {
roleslevels = EnumSet.noneOf(Role.class);
}
roleslevels.addAll(Arrays.asList(rolesToAuthorize));
authorizedRolesForAction.put(action, roleslevels);
}
示例7: unauthorize
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
/**
* Remove the given authorized roles from an action. Note that this is only
* relevant if a role was previously authorized for that action. If no roles
* where previously authorized the effect of the unauthorize call is that no
* roles at all will be authorized for that action.
*
* @param action The action
* @param rolesToUnauthorize The list of roles that will no longer be
* authorized to perform the action
*/
public final void unauthorize(final Action action, final Role... rolesToUnauthorize) {
if (action == null) {
throw new IllegalArgumentException("Argument action cannot be null");
}
if (rolesToUnauthorize == null) {
throw new IllegalArgumentException("Argument rolesToUnauthorize cannot be null");
}
EnumSet<Role> roleslevels = authorizedRolesForAction.get(action);
if (roleslevels != null) {
roleslevels.removeAll(Arrays.asList(rolesToUnauthorize));
} else {
roleslevels = EnumSet.noneOf(Role.class);
}
// If we removed the last authorized role, we authorize the empty role
// so that removing authorization can't suddenly open something up to
// everyone.
if (roleslevels.size() == 0) {
roleslevels.add(Role.NoRole);
}
authorizedRolesForAction.put(action, roleslevels);
}
示例8: isActionAuthorized
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
@Override
public boolean isActionAuthorized(Component component, Action action) {
RequiredOrientResource[] resources = getRequiredOrientResources(component.getClass());
if(resources!=null)
{
if(!checkResources(resources, action)) return false;
}
Map<String, OrientPermission[]> dynamicResources = component.getMetaData(OrientPermission.REQUIRED_ORIENT_RESOURCES_KEY);
if(dynamicResources!=null)
{
if(!checkResources(dynamicResources, action)) return false;
}
if(component instanceof ISecuredComponent)
{
resources = ((ISecuredComponent)component).getRequiredResources();
if(resources!=null)
{
if(!checkResources(resources, action)) return false;
}
}
return true;
}
示例9: checkResource
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
/**
* Check that current user has access to mentioned resource
* @param resource {@link RequiredOrientResource} to check
* @param action {@link Action} to check for
* @return true if access is allowed
*/
public boolean checkResource(RequiredOrientResource resource, Action action)
{
if(!resource.action().equals(action.getName())) return true;
OSecurityUser user = OrientDbWebSession.get().getUser();
if(user==null) return false;
int iOperation = OrientPermission.combinedPermission(resource.permissions());
ORule.ResourceGeneric value = OSecurityHelper.getResourceGeneric(resource.value());
String specific = resource.specific();
if(Strings.isEmpty(specific)) specific = null;
if(user.checkIfAllowed(value, specific, iOperation)!=null) return true;
while(!Strings.isEmpty(specific=Strings.beforeLastPathComponent(specific, '.')))
{
if(user.checkIfAllowed(value, specific+"."+ODatabaseSecurityResources.ALL, iOperation)!=null) return true;
}
return false;
}
示例10: authorize
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
/**
* Gives permission for the given roles to perform the given action
*
* @param action
* The action
* @param rolesToAdd
* The roles
*/
public final void authorize(final Action action, final Roles rolesToAdd) {
if (action == null) {
throw new IllegalArgumentException("Argument action cannot be null");
}
if (rolesToAdd == null) {
throw new IllegalArgumentException("Argument rolesToAdd cannot be null");
}
Roles roles = rolesForAction.get(action);
if (roles == null) {
roles = new Roles();
rolesForAction.put(action, roles);
}
roles.addAll(rolesToAdd);
}
示例11: unauthorize
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
/**
* Remove the given authorized role from an action. Note that this is only
* relevant if a role was previously authorized for that action. If no roles
* where previously authorized the effect of the unauthorize call is that no
* roles at all will be authorized for that action.
*
* @param action
* The action
* @param rolesToRemove
* The comma separated list of roles to remove
*/
public final void unauthorize(final Action action, final Roles rolesToRemove) {
if (action == null) {
throw new IllegalArgumentException("Argument action cannot be null");
}
if (rolesToRemove == null) {
throw new IllegalArgumentException("Argument rolesToRemove cannot be null");
}
Roles roles = rolesForAction.get(action);
if (roles != null) {
roles.removeAll(rolesToRemove);
} else {
roles = new Roles();
rolesForAction.put(action, roles);
}
// If we removed the last authorized role, we authorize the empty role
// so that removing authorization can't suddenly open something up to
// everyone.
if (roles.size() == 0) {
roles.add(MetaDataRoleAuthorizationStrategy.NO_ROLE);
}
}
示例12: isActionAuthorized
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
/**
* Uses component level meta data to match roles for component action
* execution.
*
* @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
* org.apache.wicket.authorization.Action)
*/
@Override
public boolean isActionAuthorized(final Component component, final Action action) {
if (component == null) {
throw new IllegalArgumentException("argument component has to be not null");
}
if (action == null) {
throw new IllegalArgumentException("argument action has to be not null");
}
final Roles roles = rolesAuthorizedToPerformAction(component, action);
if (roles != null) {
return hasAny(roles);
}
return true;
}
示例13: isActionAuthorized
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
protected boolean isActionAuthorized(final Class<?> componentClass, final Action action) {
// Check for a single action
if (!check(action, componentClass.getAnnotation(AuthorizeAction.class))) {
return false;
}
// Check for multiple actions
final AuthorizeActions authorizeActionsAnnotation = componentClass.getAnnotation(AuthorizeActions.class);
if (authorizeActionsAnnotation != null) {
for (final AuthorizeAction authorizeActionAnnotation : authorizeActionsAnnotation.actions()) {
if (!check(action, authorizeActionAnnotation)) {
return false;
}
}
}
return true;
}
示例14: check
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
/**
* @param action
* The action to check
* @param authorizeActionAnnotation
* The annotations information
* @return False if the action is not authorized
*/
private boolean check(final Action action, final AuthorizeAction authorizeActionAnnotation) {
if (authorizeActionAnnotation != null) {
if (action.getName().equals(authorizeActionAnnotation.action())) {
List<String> roles = new ArrayList<String>();
for (Role role : authorizeActionAnnotation.roles()) {
roles.add(role.name());
}
Roles acceptedRoles = new Roles(roles.toArray(new String[roles.size()]));
if (!(isEmpty(acceptedRoles) || hasAny(acceptedRoles))) {
return false;
}
}
}
return true;
}
示例15: setAuthorizationStrategy
import org.apache.wicket.authorization.Action; //导入依赖的package包/类
/**
* Initializes the authorization strategy for the web application. Pages,
* which implement the {@link AuthenticatedWebPage} interface, are only
* accessible for authenticated users.
*/
private void setAuthorizationStrategy() {
this.getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy() {
@Override
public boolean isActionAuthorized(final Component component, final Action action) {
// authorize everything
return true;
}
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(final Class<T> componentClass) {
// Check if the new Page requires authentication
// (implements the marker interface)
if (AuthenticatedWebPage.class.isAssignableFrom(componentClass)) {
// Is user signed in?
if (((AuthenticatedSession) Session.get()).isSignedIn()) {
// okay to proceed
return true;
}
// Intercept the request, but remember the target
// for later.
// Invoke Component.continueToOriginalDestination()
// after successful logon to
// continue with the target remembered.
throw new RestartResponseAtInterceptPageException(LoginPage.class);
}
// okay to proceed
return true;
}
});
}