1 package org.apache.archiva.redback.rest.api.services;
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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
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;
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;
39 * @author Olivier Lamy
41 @Path( "/roleManagementService/" )
42 public interface RoleManagementService
45 @Path( "createTemplatedRole" )
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;
54 * removes a role corresponding to the role Id that was manufactured with the given resource
56 * it also removes any user assignments for that role
62 @Path( "removeTemplatedRole" )
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;
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
75 * it also manages any user assignments for that role
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;
92 * Assigns the role indicated by the roleId to the given principal
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;
106 * Assigns the role indicated by the roleName to the given principal
112 @Path( "assignRoleByName" )
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;
120 * Assigns the templated role indicated by the templateId
122 * fails if the templated role has not been created
128 @Path( "assignTemplatedRole" )
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;
138 * Unassigns the role indicated by the role id from the given principal
144 @Path( "unassignRole" )
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;
152 * Unassigns the role indicated by the role name from the given principal
158 @Path( "unassignRoleByName" )
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;
166 * true of a role exists with the given roleId
172 @Path( "roleExists" )
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;
180 * true of a role exists with the given roleId
187 @Path( "templatedRoleExists" )
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;
197 * Check a role template is complete in the RBAC store.
199 * @param templateId the templated role
200 * @param resource the resource to verify
203 @Path( "verifyTemplatedRole" )
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;
211 @Path( "getEffectivelyAssignedRoles/{username}" )
213 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
214 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
218 List<Role> getEffectivelyAssignedRoles( @PathParam( "username" ) String username )
219 throws RedbackServiceException;
224 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
225 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
229 List<Role> getAllRoles()
230 throws RedbackServiceException;
232 @Path( "detailledAllRoles" )
234 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
235 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
239 List<Role> getDetailedAllRoles()
240 throws RedbackServiceException;
243 @Path( "getApplications/{username}" )
245 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
246 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
250 List<Application> getApplications( @PathParam( "username" ) String username )
251 throws RedbackServiceException;
254 @Path( "getRole/{roleName}" )
256 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
257 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
261 Role getRole( @PathParam( "roleName" ) String roleName )
262 throws RedbackServiceException;
264 @Path( "updateRoleDescription" )
266 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
267 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
271 Boolean updateRoleDescription( @QueryParam( "roleName" ) String roleName,
272 @QueryParam( "roleDescription" ) String description )
273 throws RedbackServiceException;
275 @Path( "updateRoleUsers" )
277 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
278 @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
279 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
281 * update users assigned to a role
284 Boolean updateRoleUsers( Role role )
285 throws RedbackServiceException;
287 @Path( "getApplicationRoles/{username}" )
289 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
290 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
294 List<ApplicationRoles> getApplicationRoles( @PathParam( "username" ) String username )
295 throws RedbackServiceException;
297 @Path( "updateUserRoles" )
299 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
300 @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
301 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION )
303 * update roles assigned to a user
306 Boolean updateUserRoles( User user )
307 throws RedbackServiceException;