1 package org.apache.archiva.redback.struts2.action.admin;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.redback.rbac.Resource;
23 import org.apache.archiva.redback.rbac.Role;
24 import org.apache.archiva.redback.rbac.RbacManagerException;
25 import org.apache.archiva.redback.struts2.action.AbstractUserCredentialsAction;
26 import org.apache.archiva.redback.integration.interceptor.SecureActionBundle;
27 import org.apache.archiva.redback.integration.interceptor.SecureActionException;
28 import org.apache.archiva.redback.integration.role.RoleConstants;
29 import org.springframework.context.annotation.Scope;
30 import org.springframework.stereotype.Controller;
32 import java.util.ArrayList;
33 import java.util.Collections;
34 import java.util.List;
39 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
42 @Controller( "redback-roles" )
44 public class RolesAction
45 extends AbstractUserCredentialsAction
47 private static final String LIST = "list";
49 private List<Role> allRoles;
55 allRoles = getFilteredRolesForCurrentUserAccess();
57 catch ( RbacManagerException e )
59 List<Object> list = new ArrayList<Object>();
60 list.add( e.getMessage() );
61 addActionError( getText( "cannot.list.all.roles", list ) );
62 log.error( "System error:", e );
63 allRoles = Collections.emptyList();
69 public List<Role> getAllRoles()
74 public void setAllRoles( List<Role> allRoles )
76 this.allRoles = allRoles;
79 public SecureActionBundle initSecureActionBundle()
80 throws SecureActionException
82 SecureActionBundle bundle = new SecureActionBundle();
83 bundle.setRequiresAuthentication( true );
84 bundle.addRequiredAuthorization( RoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION, Resource.GLOBAL );
85 bundle.addRequiredAuthorization( RoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION, Resource.GLOBAL );
86 bundle.addRequiredAuthorization( RoleConstants.USER_MANAGEMENT_ROLE_GRANT_OPERATION, Resource.GLOBAL );
87 bundle.addRequiredAuthorization( RoleConstants.USER_MANAGEMENT_ROLE_DROP_OPERATION, Resource.GLOBAL );
88 bundle.addRequiredAuthorization( RoleConstants.USER_MANAGEMENT_USER_ROLE_OPERATION, Resource.GLOBAL );