1 package org.apache.archiva.redback.rest.api.services;
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.authorization.RedbackAuthorization;
23 import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
24 import org.apache.archiva.redback.rest.api.model.Operation;
25 import org.apache.archiva.redback.rest.api.model.Permission;
26 import org.apache.archiva.redback.rest.api.model.RegistrationKey;
27 import org.apache.archiva.redback.rest.api.model.User;
29 import javax.ws.rs.Consumes;
30 import javax.ws.rs.GET;
31 import javax.ws.rs.POST;
32 import javax.ws.rs.Path;
33 import javax.ws.rs.PathParam;
34 import javax.ws.rs.Produces;
35 import javax.ws.rs.core.MediaType;
36 import java.util.Collection;
37 import java.util.List;
39 @Path( "/userService/" )
40 public interface UserService
42 @Path( "getUser/{userName}" )
44 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
45 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
46 User getUser( @PathParam( "userName" ) String username )
47 throws RedbackServiceException;
52 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
53 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_LIST_OPERATION )
55 throws RedbackServiceException;
59 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
60 @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
61 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_CREATE_OPERATION )
62 Boolean createUser( User user )
63 throws RedbackServiceException;
67 * will create admin user only if not exists !! if exists will return false
69 @Path( "createAdminUser" )
71 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
72 @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
73 @RedbackAuthorization( noRestriction = true )
74 Boolean createAdminUser( User user )
75 throws RedbackServiceException;
77 @Path( "isAdminUserExists" )
79 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
80 @RedbackAuthorization( noRestriction = true )
81 Boolean isAdminUserExists()
82 throws RedbackServiceException;
85 @Path( "deleteUser/{userName}" )
87 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
88 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_DELETE_OPERATION )
89 Boolean deleteUser( @PathParam( "userName" ) String username )
90 throws RedbackServiceException;
94 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
95 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
96 Boolean updateUser( User user )
97 throws RedbackServiceException;
99 @Path( "lockUser/{username}" )
101 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
102 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
106 Boolean lockUser( @PathParam( "username" ) String username )
107 throws RedbackServiceException;
109 @Path( "unlockUser/{username}" )
111 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
112 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
116 Boolean unlockUser( @PathParam( "username" ) String username )
117 throws RedbackServiceException;
120 @Path( "passwordChangeRequired/{username}" )
122 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
123 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
127 Boolean passwordChangeRequired( @PathParam( "username" ) String username )
128 throws RedbackServiceException;
130 @Path( "passwordChangeNotRequired/{username}" )
132 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
133 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
137 Boolean passwordChangeNotRequired( @PathParam( "username" ) String username )
138 throws RedbackServiceException;
143 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
144 @RedbackAuthorization( noRestriction = false, noPermission = true )
146 * update only the current user and this fields: fullname, email, password.
147 * the service verify the curent logged user with the one passed in the method
150 Boolean updateMe( User user )
151 throws RedbackServiceException;
155 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
156 @RedbackAuthorization( noRestriction = true )
158 throws RedbackServiceException;
160 @Path( "removeFromCache/{userName}" )
162 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
163 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
164 int removeFromCache( @PathParam( "userName" ) String username )
165 throws RedbackServiceException;
167 @Path( "getGuestUser" )
169 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
170 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
172 throws RedbackServiceException;
174 @Path( "createGuestUser" )
176 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
177 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
178 User createGuestUser()
179 throws RedbackServiceException;
181 @Path( "registerUser" )
183 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
184 @RedbackAuthorization( noRestriction = true, noPermission = true )
186 * if redback is not configured for email validation is required, -1 is returned as key
189 RegistrationKey registerUser( User user )
190 throws RedbackServiceException;
193 @Path( "validateKey/{key}" )
195 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
196 @RedbackAuthorization( noRestriction = true, noPermission = true )
198 * validate the key and the user with forcing a password change for next login.
199 * http session is created.
200 * @param key authentication key
203 Boolean validateUserFromKey( @PathParam( "key" ) String key )
204 throws RedbackServiceException;
206 @Path( "resetPassword/{user}" )
208 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
209 @RedbackAuthorization( noRestriction = true, noPermission = true )
212 * @param user username for send a password reset email
215 Boolean resetPassword( @PathParam( "user" ) String user )
216 throws RedbackServiceException;
218 @Path( "getUserPermissions/{userName}" )
220 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
221 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_LIST_OPERATION )
225 Collection<Permission> getUserPermissions( @PathParam( "userName" ) String userName )
226 throws RedbackServiceException;
228 @Path( "getUserOperations/{userName}" )
230 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
231 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_LIST_OPERATION )
235 Collection<Operation> getUserOperations( @PathParam( "userName" ) String userName )
236 throws RedbackServiceException;
238 @Path( "getCurrentUserPermissions" )
240 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
241 @RedbackAuthorization( noRestriction = true, noPermission = true )
243 * return the current logged user permissions, if no logged user guest permissions are returned
246 Collection<Permission> getCurrentUserPermissions()
247 throws RedbackServiceException;
249 @Path( "getCurrentUserOperations" )
251 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
252 @RedbackAuthorization( noRestriction = true, noPermission = true )
254 * return the current logged user operations, if no logged user guest operations are returned
257 Collection<Operation> getCurrentUserOperations()
258 throws RedbackServiceException;