This project has retired. For details please refer to its Attic page.
RoleManagementService xref
View Javadoc

1   package org.apache.archiva.redback.rest.api.services;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  import org.apache.archiva.redback.authorization.RedbackAuthorization;
22  import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
23  import org.apache.archiva.redback.rest.api.model.Application;
24  import org.apache.archiva.redback.rest.api.model.ApplicationRoles;
25  import org.apache.archiva.redback.rest.api.model.Role;
26  import org.apache.archiva.redback.rest.api.model.User;
27  
28  import javax.ws.rs.Consumes;
29  import javax.ws.rs.GET;
30  import javax.ws.rs.POST;
31  import javax.ws.rs.Path;
32  import javax.ws.rs.PathParam;
33  import javax.ws.rs.Produces;
34  import javax.ws.rs.QueryParam;
35  import javax.ws.rs.core.MediaType;
36  import java.util.List;
37  
38  /**
39   * @author Olivier Lamy
40   */
41  @Path( "/roleManagementService/" )
42  public interface RoleManagementService
43  {
44  
45      @Path( "createTemplatedRole" )
46      @GET
47      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
48      @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
49      Boolean createTemplatedRole( @QueryParam( "templateId" ) String templateId,
50                                   @QueryParam( "resource" ) String resource )
51          throws RedbackServiceException;
52  
53      /**
54       * removes a role corresponding to the role Id that was manufactured with the given resource
55       * <p/>
56       * it also removes any user assignments for that role
57       *
58       * @param templateId
59       * @param resource
60       * @throws Exception
61       */
62      @Path( "removeTemplatedRole" )
63      @GET
64      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
65      @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
66      Boolean removeTemplatedRole( @QueryParam( "templateId" ) String templateId,
67                                   @QueryParam( "resource" ) String resource )
68          throws RedbackServiceException;
69  
70  
71      /**
72       * allows for a role coming from a template to be renamed effectively swapping out the bits of it that
73       * were labeled with the oldResource with the newResource
74       * <p/>
75       * it also manages any user assignments for that role
76       *
77       * @param templateId
78       * @param oldResource
79       * @param newResource
80       * @throws Exception
81       */
82      @Path( "updateRole" )
83      @GET
84      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
85      @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
86      Boolean updateRole( @QueryParam( "templateId" ) String templateId, @QueryParam( "oldResource" ) String oldResource,
87                          @QueryParam( "newResource" ) String newResource )
88          throws RedbackServiceException;
89  
90  
91      /**
92       * Assigns the role indicated by the roleId to the given principal
93       *
94       * @param roleId
95       * @param principal
96       * @throws Exception
97       */
98      @Path( "assignRole" )
99      @GET
100     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
101     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
102     Boolean assignRole( @QueryParam( "roleId" ) String roleId, @QueryParam( "principal" ) String principal )
103         throws RedbackServiceException;
104 
105     /**
106      * Assigns the role indicated by the roleName to the given principal
107      *
108      * @param roleName
109      * @param principal
110      * @throws Exception
111      */
112     @Path( "assignRoleByName" )
113     @GET
114     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
115     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
116     Boolean assignRoleByName( @QueryParam( "roleName" ) String roleName, @QueryParam( "principal" ) String principal )
117         throws RedbackServiceException;
118 
119     /**
120      * Assigns the templated role indicated by the templateId
121      * <p/>
122      * fails if the templated role has not been created
123      *
124      * @param templateId
125      * @param resource
126      * @param principal
127      */
128     @Path( "assignTemplatedRole" )
129     @GET
130     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
131     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
132     Boolean assignTemplatedRole( @QueryParam( "templateId" ) String templateId,
133                                  @QueryParam( "resource" ) String resource,
134                                  @QueryParam( "principal" ) String principal )
135         throws RedbackServiceException;
136 
137     /**
138      * Unassigns the role indicated by the role id from the given principal
139      *
140      * @param roleId
141      * @param principal
142      * @throws Exception
143      */
144     @Path( "unassignRole" )
145     @GET
146     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
147     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
148     Boolean unassignRole( @QueryParam( "roleId" ) String roleId, @QueryParam( "principal" ) String principal )
149         throws RedbackServiceException;
150 
151     /**
152      * Unassigns the role indicated by the role name from the given principal
153      *
154      * @param roleName
155      * @param principal
156      * @throws Exception
157      */
158     @Path( "unassignRoleByName" )
159     @GET
160     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
161     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
162     Boolean unassignRoleByName( @QueryParam( "roleName" ) String roleName, @QueryParam( "principal" ) String principal )
163         throws RedbackServiceException;
164 
165     /**
166      * true of a role exists with the given roleId
167      *
168      * @param roleId
169      * @return
170      * @throws Exception
171      */
172     @Path( "roleExists" )
173     @GET
174     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
175     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
176     Boolean roleExists( @QueryParam( "roleId" ) String roleId )
177         throws RedbackServiceException;
178 
179     /**
180      * true of a role exists with the given roleId
181      *
182      * @param templateId
183      * @param resource
184      * @return
185      * @throws Exception
186      */
187     @Path( "templatedRoleExists" )
188     @GET
189     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
190     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
191     Boolean templatedRoleExists( @QueryParam( "templateId" ) String templateId,
192                                  @QueryParam( "resource" ) String resource )
193         throws RedbackServiceException;
194 
195 
196     /**
197      * Check a role template is complete in the RBAC store.
198      *
199      * @param templateId the templated role
200      * @param resource   the resource to verify
201      * @throws Exception
202      */
203     @Path( "verifyTemplatedRole" )
204     @GET
205     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
206     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
207     Boolean verifyTemplatedRole( @QueryParam( "templateId" ) String templateId,
208                                  @QueryParam( "resource" ) String resource )
209         throws RedbackServiceException;
210 
211     /**
212      * @since 1.4
213      */
214     @Path( "getEffectivelyAssignedRoles/{username}" )
215     @GET
216     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
217     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
218     List<Role> getEffectivelyAssignedRoles( @PathParam( "username" ) String username )
219         throws RedbackServiceException;
220 
221 
222     /**
223      * @since 2.0
224      */
225     @Path( "allRoles" )
226     @GET
227     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
228     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
229     List<Role> getAllRoles()
230         throws RedbackServiceException;
231 
232     /**
233      * @since 2.0
234      */
235     @Path( "detailledAllRoles" )
236     @GET
237     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
238     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
239     List<Role> getDetailedAllRoles()
240         throws RedbackServiceException;
241 
242 
243     /**
244      * @since 2.0
245      */
246     @Path( "getApplications/{username}" )
247     @GET
248     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
249     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
250     List<Application> getApplications( @PathParam( "username" ) String username )
251         throws RedbackServiceException;
252 
253 
254     /**
255      * @since 2.0
256      */
257     @Path( "getRole/{roleName}" )
258     @GET
259     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
260     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
261     Role getRole( @PathParam( "roleName" ) String roleName )
262         throws RedbackServiceException;
263 
264     /**
265      * @since 2.0
266      */
267     @Path( "updateRoleDescription" )
268     @GET
269     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
270     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
271     Boolean updateRoleDescription( @QueryParam( "roleName" ) String roleName,
272                                    @QueryParam( "roleDescription" ) String description )
273         throws RedbackServiceException;
274 
275     /**
276      * update users assigned to a role
277      * @since 2.0
278      */
279     @Path( "updateRoleUsers" )
280     @POST
281     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
282     @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
283     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
284     Boolean updateRoleUsers( Role role )
285         throws RedbackServiceException;
286 
287     /**
288      * @since 2.0
289      */
290     @Path( "getApplicationRoles/{username}" )
291     @GET
292     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
293     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
294     List<ApplicationRoles> getApplicationRoles( @PathParam( "username" ) String username )
295         throws RedbackServiceException;
296 
297     /**
298      * update roles assigned to a user
299      * @since 2.0
300      */
301     @Path( "updateUserRoles" )
302     @POST
303     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
304     @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
305     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
306     Boolean updateUserRoles( User user )
307         throws RedbackServiceException;
308 
309 }