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;
28 import org.apache.archiva.redback.rest.api.model.UserRegistrationRequest;
30 import javax.ws.rs.Consumes;
31 import javax.ws.rs.GET;
32 import javax.ws.rs.POST;
33 import javax.ws.rs.Path;
34 import javax.ws.rs.PathParam;
35 import javax.ws.rs.Produces;
36 import javax.ws.rs.core.MediaType;
37 import java.util.Collection;
38 import java.util.List;
40 @Path( "/userService/" )
41 public interface UserService
43 @Path( "getUser/{userName}" )
45 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
46 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
47 User getUser( @PathParam( "userName" ) String username )
48 throws RedbackServiceException;
53 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
54 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_LIST_OPERATION )
56 throws RedbackServiceException;
60 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
61 @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
62 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_CREATE_OPERATION )
63 Boolean createUser( User user )
64 throws RedbackServiceException;
68 * will create admin user only if not exists !! if exists will return false
70 @Path( "createAdminUser" )
72 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
73 @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
74 @RedbackAuthorization( noRestriction = true )
75 Boolean createAdminUser( User user )
76 throws RedbackServiceException;
78 @Path( "isAdminUserExists" )
80 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
81 @RedbackAuthorization( noRestriction = true )
82 Boolean isAdminUserExists()
83 throws RedbackServiceException;
86 @Path( "deleteUser/{userName}" )
88 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
89 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_DELETE_OPERATION )
90 Boolean deleteUser( @PathParam( "userName" ) String username )
91 throws RedbackServiceException;
95 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
96 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
97 Boolean updateUser( User user )
98 throws RedbackServiceException;
100 @Path( "lockUser/{username}" )
102 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
103 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
107 Boolean lockUser( @PathParam( "username" ) String username )
108 throws RedbackServiceException;
110 @Path( "unlockUser/{username}" )
112 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
113 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
117 Boolean unlockUser( @PathParam( "username" ) String username )
118 throws RedbackServiceException;
121 @Path( "passwordChangeRequired/{username}" )
123 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
124 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
128 Boolean passwordChangeRequired( @PathParam( "username" ) String username )
129 throws RedbackServiceException;
131 @Path( "passwordChangeNotRequired/{username}" )
133 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
134 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
138 Boolean passwordChangeNotRequired( @PathParam( "username" ) String username )
139 throws RedbackServiceException;
144 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
145 @RedbackAuthorization( noRestriction = false, noPermission = true )
147 * update only the current user and this fields: fullname, email, password.
148 * the service verify the curent logged user with the one passed in the method
151 Boolean updateMe( User user )
152 throws RedbackServiceException;
156 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
157 @RedbackAuthorization( noRestriction = true )
159 throws RedbackServiceException;
161 @Path( "removeFromCache/{userName}" )
163 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
164 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
165 int removeFromCache( @PathParam( "userName" ) String username )
166 throws RedbackServiceException;
168 @Path( "getGuestUser" )
170 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
171 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
173 throws RedbackServiceException;
175 @Path( "createGuestUser" )
177 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
178 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
179 User createGuestUser()
180 throws RedbackServiceException;
182 @Path( "registerUser" )
184 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
185 @RedbackAuthorization( noRestriction = true, noPermission = true )
187 * if redback is not configured for email validation is required, -1 is returned as key
190 RegistrationKey registerUser( UserRegistrationRequest userRegistrationRequest )
191 throws RedbackServiceException;
194 @Path( "validateKey/{key}" )
196 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
197 @RedbackAuthorization( noRestriction = true, noPermission = true )
199 * validate the key and the user with forcing a password change for next login.
200 * http session is created.
201 * @param key authentication key
204 Boolean validateUserFromKey( @PathParam( "key" ) String key )
205 throws RedbackServiceException;
207 @Path( "resetPassword/{user}" )
209 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
210 @RedbackAuthorization( noRestriction = true, noPermission = true )
213 * @param user username for send a password reset email
216 Boolean resetPassword( @PathParam( "user" ) String user )
217 throws RedbackServiceException;
219 @Path( "getUserPermissions/{userName}" )
221 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
222 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_LIST_OPERATION )
226 Collection<Permission> getUserPermissions( @PathParam( "userName" ) String userName )
227 throws RedbackServiceException;
229 @Path( "getUserOperations/{userName}" )
231 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
232 @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_LIST_OPERATION )
236 Collection<Operation> getUserOperations( @PathParam( "userName" ) String userName )
237 throws RedbackServiceException;
239 @Path( "getCurrentUserPermissions" )
241 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
242 @RedbackAuthorization( noRestriction = true, noPermission = true )
244 * return the current logged user permissions, if no logged user guest permissions are returned
247 Collection<Permission> getCurrentUserPermissions()
248 throws RedbackServiceException;
250 @Path( "getCurrentUserOperations" )
252 @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
253 @RedbackAuthorization( noRestriction = true, noPermission = true )
255 * return the current logged user operations, if no logged user guest operations are returned
258 Collection<Operation> getCurrentUserOperations()
259 throws RedbackServiceException;