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

1   package org.apache.archiva.redback.rest.api.services;
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.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.ResetPasswordRequest;
28  import org.apache.archiva.redback.rest.api.model.User;
29  import org.apache.archiva.redback.rest.api.model.UserRegistrationRequest;
30  
31  import javax.ws.rs.Consumes;
32  import javax.ws.rs.GET;
33  import javax.ws.rs.POST;
34  import javax.ws.rs.Path;
35  import javax.ws.rs.PathParam;
36  import javax.ws.rs.Produces;
37  import javax.ws.rs.core.MediaType;
38  import java.util.Collection;
39  import java.util.List;
40  
41  @Path( "/userService/" )
42  public interface UserService
43  {
44      @Path( "getUser/{userName}" )
45      @GET
46      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
47      @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
48      User getUser( @PathParam( "userName" ) String username )
49          throws RedbackServiceException;
50  
51  
52      @Path( "getUsers" )
53      @GET
54      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
55      @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_LIST_OPERATION )
56      List<User> getUsers()
57          throws RedbackServiceException;
58  
59      @Path( "createUser" )
60      @POST
61      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
62      @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
63      @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_CREATE_OPERATION )
64      Boolean createUser( User user )
65          throws RedbackServiceException;
66  
67  
68      /**
69       * will create admin user only if not exists !! if exists will return false
70       */
71      @Path( "createAdminUser" )
72      @POST
73      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
74      @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
75      @RedbackAuthorization( noRestriction = true )
76      Boolean createAdminUser( User user )
77          throws RedbackServiceException;
78  
79      @Path( "isAdminUserExists" )
80      @GET
81      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
82      @RedbackAuthorization( noRestriction = true )
83      Boolean isAdminUserExists()
84          throws RedbackServiceException;
85  
86  
87      @Path( "deleteUser/{userName}" )
88      @GET
89      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
90      @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_DELETE_OPERATION )
91      Boolean deleteUser( @PathParam( "userName" ) String username )
92          throws RedbackServiceException;
93  
94      @Path( "updateUser" )
95      @POST
96      @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
97      @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
98      Boolean updateUser( User user )
99          throws RedbackServiceException;
100 
101     /**
102      * @since 2.0
103      */
104     @Path( "lockUser/{username}" )
105     @GET
106     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
107     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
108     Boolean lockUser( @PathParam( "username" ) String username )
109         throws RedbackServiceException;
110 
111     /**
112      * @since 2.0
113      */
114     @Path( "unlockUser/{username}" )
115     @GET
116     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
117     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
118     Boolean unlockUser( @PathParam( "username" ) String username )
119         throws RedbackServiceException;
120 
121 
122     /**
123      * @since 2.0
124      */
125     @Path( "passwordChangeRequired/{username}" )
126     @GET
127     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
128     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
129     Boolean passwordChangeRequired( @PathParam( "username" ) String username )
130         throws RedbackServiceException;
131 
132     /**
133      * @since 2.0
134      */
135     @Path( "passwordChangeNotRequired/{username}" )
136     @GET
137     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
138     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
139     Boolean passwordChangeNotRequired( @PathParam( "username" ) String username )
140         throws RedbackServiceException;
141 
142 
143     /**
144      * update only the current user and this fields: fullname, email, password.
145      * the service verify the curent logged user with the one passed in the method
146      * @since 1.4
147      */
148     @Path( "updateMe" )
149     @POST
150     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
151     @RedbackAuthorization( noRestriction = false, noPermission = true )
152     Boolean updateMe( User user )
153         throws RedbackServiceException;
154 
155     @Path( "ping" )
156     @GET
157     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
158     @RedbackAuthorization( noRestriction = true )
159     Boolean ping()
160         throws RedbackServiceException;
161 
162     @Path( "removeFromCache/{userName}" )
163     @GET
164     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
165     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
166     int removeFromCache( @PathParam( "userName" ) String username )
167         throws RedbackServiceException;
168 
169     @Path( "getGuestUser" )
170     @GET
171     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
172     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
173     User getGuestUser()
174         throws RedbackServiceException;
175 
176     @Path( "createGuestUser" )
177     @GET
178     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
179     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION )
180     User createGuestUser()
181         throws RedbackServiceException;
182 
183     /**
184      * if redback is not configured for email validation is required, -1 is returned as key
185      * @since 1.4
186      */
187     @Path( "registerUser" )
188     @POST
189     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
190     @RedbackAuthorization( noRestriction = true, noPermission = true )
191     RegistrationKey registerUser( UserRegistrationRequest userRegistrationRequest )
192         throws RedbackServiceException;
193 
194 
195     /**
196      * validate the key and the user with forcing a password change for next login.
197      * http session is created.
198      * @param key authentication key
199      * @since 1.4
200      */
201     @Path( "validateKey/{key}" )
202     @GET
203     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
204     @RedbackAuthorization( noRestriction = true, noPermission = true )
205     Boolean validateUserFromKey( @PathParam( "key" ) String key )
206         throws RedbackServiceException;
207 
208     /**
209      *
210      * @param resetPasswordRequest contains username for send a password reset email
211      * @since 1.4
212      */
213     @Path( "resetPassword" )
214     @POST
215     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
216     @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
217     @RedbackAuthorization( noRestriction = true, noPermission = true )
218     Boolean resetPassword( ResetPasswordRequest resetPasswordRequest )
219         throws RedbackServiceException;
220 
221     /**
222      * @since 1.4
223      */
224     @Path( "getUserPermissions/{userName}" )
225     @GET
226     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
227     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_LIST_OPERATION )
228     Collection<Permission> getUserPermissions( @PathParam( "userName" ) String userName )
229         throws RedbackServiceException;
230 
231     /**
232      * @since 1.4
233      */
234     @Path( "getUserOperations/{userName}" )
235     @GET
236     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
237     @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_LIST_OPERATION )
238     Collection<Operation> getUserOperations( @PathParam( "userName" ) String userName )
239         throws RedbackServiceException;
240 
241     /**
242      * @return  the current logged user permissions, if no logged user guest permissions are returned
243      * @since 1.4
244      */
245     @Path( "getCurrentUserPermissions" )
246     @GET
247     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
248     @RedbackAuthorization( noRestriction = true, noPermission = true )
249     Collection<Permission> getCurrentUserPermissions()
250         throws RedbackServiceException;
251 
252     /**
253      * @return the current logged user operations, if no logged user guest operations are returned
254      * @since 1.4
255      */
256     @Path( "getCurrentUserOperations" )
257     @GET
258     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
259     @RedbackAuthorization( noRestriction = true, noPermission = true )
260     Collection<Operation> getCurrentUserOperations()
261         throws RedbackServiceException;
262 
263 }