Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

IUserService.java 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /*
  2. * Copyright 2011 gitblit.com.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.gitblit;
  17. import java.util.Collection;
  18. import java.util.List;
  19. import com.gitblit.manager.IRuntimeManager;
  20. import com.gitblit.models.TeamModel;
  21. import com.gitblit.models.UserModel;
  22. /**
  23. * Implementations of IUserService control all aspects of UserModel objects and
  24. * user authentication.
  25. *
  26. * @author James Moger
  27. *
  28. */
  29. public interface IUserService {
  30. /**
  31. * Setup the user service. This method allows custom implementations to
  32. * retrieve settings from gitblit.properties or the web.xml file without
  33. * relying on the GitBlit static singleton.
  34. *
  35. * @param runtimeManager
  36. * @since 1.4.0
  37. */
  38. void setup(IRuntimeManager runtimeManager);
  39. /**
  40. * Returns the cookie value for the specified user.
  41. *
  42. * @param model
  43. * @return cookie value
  44. */
  45. String getCookie(UserModel model);
  46. /**
  47. * Retrieve a user object for the specified cookie.
  48. *
  49. * @param cookie
  50. * @return a user object or null
  51. */
  52. UserModel getUserModel(char[] cookie);
  53. /**
  54. * Retrieve the user object for the specified username.
  55. *
  56. * @param username
  57. * @return a user object or null
  58. */
  59. UserModel getUserModel(String username);
  60. /**
  61. * Updates/writes a complete user object.
  62. *
  63. * @param model
  64. * @return true if update is successful
  65. */
  66. boolean updateUserModel(UserModel model);
  67. /**
  68. * Updates/writes all specified user objects.
  69. *
  70. * @param models a list of user models
  71. * @return true if update is successful
  72. * @since 1.2.0
  73. */
  74. boolean updateUserModels(Collection<UserModel> models);
  75. /**
  76. * Adds/updates a user object keyed by username. This method allows for
  77. * renaming a user.
  78. *
  79. * @param username
  80. * the old username
  81. * @param model
  82. * the user object to use for username
  83. * @return true if update is successful
  84. */
  85. boolean updateUserModel(String username, UserModel model);
  86. /**
  87. * Deletes the user object from the user service.
  88. *
  89. * @param model
  90. * @return true if successful
  91. */
  92. boolean deleteUserModel(UserModel model);
  93. /**
  94. * Delete the user object with the specified username
  95. *
  96. * @param username
  97. * @return true if successful
  98. */
  99. boolean deleteUser(String username);
  100. /**
  101. * Returns the list of all users available to the login service.
  102. *
  103. * @return list of all usernames
  104. */
  105. List<String> getAllUsernames();
  106. /**
  107. * Returns the list of all users available to the login service.
  108. *
  109. * @return list of all users
  110. * @since 0.8.0
  111. */
  112. List<UserModel> getAllUsers();
  113. /**
  114. * Returns the list of all teams available to the login service.
  115. *
  116. * @return list of all teams
  117. * @since 0.8.0
  118. */
  119. List<String> getAllTeamNames();
  120. /**
  121. * Returns the list of all teams available to the login service.
  122. *
  123. * @return list of all teams
  124. * @since 0.8.0
  125. */
  126. List<TeamModel> getAllTeams();
  127. /**
  128. * Returns the list of all users who are allowed to bypass the access
  129. * restriction placed on the specified repository.
  130. *
  131. * @param role
  132. * the repository name
  133. * @return list of all usernames that can bypass the access restriction
  134. * @since 0.8.0
  135. */
  136. List<String> getTeamNamesForRepositoryRole(String role);
  137. /**
  138. * Retrieve the team object for the specified team name.
  139. *
  140. * @param teamname
  141. * @return a team object or null
  142. * @since 0.8.0
  143. */
  144. TeamModel getTeamModel(String teamname);
  145. /**
  146. * Updates/writes a complete team object.
  147. *
  148. * @param model
  149. * @return true if update is successful
  150. * @since 0.8.0
  151. */
  152. boolean updateTeamModel(TeamModel model);
  153. /**
  154. * Updates/writes all specified team objects.
  155. *
  156. * @param models a list of team models
  157. * @return true if update is successful
  158. * @since 1.2.0
  159. */
  160. boolean updateTeamModels(Collection<TeamModel> models);
  161. /**
  162. * Updates/writes and replaces a complete team object keyed by teamname.
  163. * This method allows for renaming a team.
  164. *
  165. * @param teamname
  166. * the old teamname
  167. * @param model
  168. * the team object to use for teamname
  169. * @return true if update is successful
  170. * @since 0.8.0
  171. */
  172. boolean updateTeamModel(String teamname, TeamModel model);
  173. /**
  174. * Deletes the team object from the user service.
  175. *
  176. * @param model
  177. * @return true if successful
  178. * @since 0.8.0
  179. */
  180. boolean deleteTeamModel(TeamModel model);
  181. /**
  182. * Delete the team object with the specified teamname
  183. *
  184. * @param teamname
  185. * @return true if successful
  186. * @since 0.8.0
  187. */
  188. boolean deleteTeam(String teamname);
  189. /**
  190. * Returns the list of all users who are allowed to bypass the access
  191. * restriction placed on the specified repository.
  192. *
  193. * @param role
  194. * the repository name
  195. * @return list of all usernames that can bypass the access restriction
  196. * @since 0.8.0
  197. */
  198. List<String> getUsernamesForRepositoryRole(String role);
  199. /**
  200. * Renames a repository role.
  201. *
  202. * @param oldRole
  203. * @param newRole
  204. * @return true if successful
  205. */
  206. boolean renameRepositoryRole(String oldRole, String newRole);
  207. /**
  208. * Removes a repository role from all users.
  209. *
  210. * @param role
  211. * @return true if successful
  212. */
  213. boolean deleteRepositoryRole(String role);
  214. /**
  215. * @See java.lang.Object.toString();
  216. * @return string representation of the login service
  217. */
  218. @Override
  219. String toString();
  220. }