1 package org.apache.archiva.redback.role;
2
3 /*
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
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
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
19 * under the License.
20 */
21
22 import org.apache.archiva.redback.role.model.RedbackRoleModel;
23
24 import java.net.URL;
25
26 /**
27 * RoleProfileManager:
28 *
29 * @author: Jesse McConnell <jesse@codehaus.org>
30 *
31 */
32 public interface RoleManager
33 {
34
35 /**
36 * load the model and create/verify operations, resources, etc exist and make static roles
37 *
38 * @param resourceLocation
39 * @throws RoleManagerException
40 */
41 void loadRoleModel( URL resourceLocation )
42 throws RoleManagerException;
43
44 void loadRoleModel( RedbackRoleModel model )
45 throws RoleManagerException;
46
47 /**
48 * locate a role with the corresponding name and generate it with the given resource, ${resource}
49 * in the model will be replaced with this resource string, if this resource does not exist, it
50 * will be created.
51 *
52 * @param templateId
53 * @param resource
54 * @throws RoleManagerException
55 */
56 void createTemplatedRole( String templateId, String resource )
57 throws RoleManagerException;
58
59 /**
60 * removes a role corresponding to the role Id that was manufactured with the given resource
61 * <p/>
62 * it also removes any user assignments for that role
63 *
64 * @param templateId
65 * @param resource
66 * @throws RoleManagerException
67 */
68 void removeTemplatedRole( String templateId, String resource )
69 throws RoleManagerException;
70
71
72 /**
73 * allows for a role coming from a template to be renamed effectively swapping out the bits of it that
74 * were labeled with the oldResource with the newResource
75 * <p/>
76 * it also manages any user assignments for that role
77 *
78 * @param templateId
79 * @param oldResource
80 * @param newResource
81 * @throws RoleManagerException
82 */
83 void updateRole( String templateId, String oldResource, String newResource )
84 throws RoleManagerException;
85
86
87 /**
88 * Assigns the role indicated by the roleId to the given principal
89 *
90 * @param roleId
91 * @param principal
92 * @throws RoleManagerException
93 */
94 void assignRole( String roleId, String principal )
95 throws RoleManagerException;
96
97 /**
98 * Assigns the role indicated by the roleName to the given principal
99 *
100 * @param roleName
101 * @param principal
102 * @throws RoleManagerException
103 */
104 void assignRoleByName( String roleName, String principal )
105 throws RoleManagerException;
106
107 /**
108 * Assigns the templated role indicated by the templateId
109 * <p/>
110 * fails if the templated role has not been created
111 *
112 * @param templateId
113 * @param resource
114 * @param principal
115 */
116 void assignTemplatedRole( String templateId, String resource, String principal )
117 throws RoleManagerException;
118
119 /**
120 * Unassigns the role indicated by the role id from the given principal
121 *
122 * @param roleId
123 * @param principal
124 * @throws RoleManagerException
125 */
126 void unassignRole( String roleId, String principal )
127 throws RoleManagerException;
128
129 /**
130 * Unassigns the role indicated by the role name from the given principal
131 *
132 * @param roleName
133 * @param principal
134 * @throws RoleManagerException
135 */
136 void unassignRoleByName( String roleName, String principal )
137 throws RoleManagerException;
138
139 /**
140 * true of a role exists with the given roleId
141 *
142 * @param roleId
143 * @return
144 * @throws RoleManagerException
145 */
146 boolean roleExists( String roleId )
147 throws RoleManagerException;
148
149 /**
150 * true of a role exists with the given roleId
151 *
152 * @param templateId
153 * @param resource
154 * @return
155 * @throws RoleManagerException
156 */
157 boolean templatedRoleExists( String templateId, String resource )
158 throws RoleManagerException;
159
160 /**
161 * get the blessed model, the current operating instructions for all things role management
162 */
163 RedbackRoleModel getModel();
164
165 /**
166 * Check a role template is complete in the RBAC store.
167 *
168 * @param templateID the templated role
169 * @param resource the resource to verify
170 * @throws RoleManagerException
171 */
172 void verifyTemplatedRole( String templateID, String resource )
173 throws RoleManagerException;
174
175 /**
176 * intialize the role manager
177 * @since 2.1
178 */
179 void initialize();
180 }