You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IUserService.java 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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.List;
  18. import com.gitblit.models.TeamModel;
  19. import com.gitblit.models.UserModel;
  20. /**
  21. * Implementations of IUserService control all aspects of UserModel objects and
  22. * user authentication.
  23. *
  24. * @author James Moger
  25. *
  26. */
  27. public interface IUserService {
  28. /**
  29. * Setup the user service. This method allows custom implementations to
  30. * retrieve settings from gitblit.properties or the web.xml file without
  31. * relying on the GitBlit static singleton.
  32. *
  33. * @param settings
  34. * @since 0.7.0
  35. */
  36. void setup(IStoredSettings settings);
  37. /**
  38. * Does the user service support changes to credentials?
  39. *
  40. * @return true or false
  41. * @since 1.0.0
  42. */
  43. boolean supportsCredentialChanges();
  44. /**
  45. * Does the user service support changes to user display name?
  46. *
  47. * @return true or false
  48. * @since 1.0.0
  49. */
  50. boolean supportsDisplayNameChanges();
  51. /**
  52. * Does the user service support changes to user email address?
  53. *
  54. * @return true or false
  55. * @since 1.0.0
  56. */
  57. boolean supportsEmailAddressChanges();
  58. /**
  59. * Does the user service support changes to team memberships?
  60. *
  61. * @return true or false
  62. * @since 1.0.0
  63. */
  64. boolean supportsTeamMembershipChanges();
  65. /**
  66. * Does the user service support cookie authentication?
  67. *
  68. * @return true or false
  69. */
  70. boolean supportsCookies();
  71. /**
  72. * Returns the cookie value for the specified user.
  73. *
  74. * @param model
  75. * @return cookie value
  76. */
  77. String getCookie(UserModel model);
  78. /**
  79. * Authenticate a user based on their cookie.
  80. *
  81. * @param cookie
  82. * @return a user object or null
  83. */
  84. UserModel authenticate(char[] cookie);
  85. /**
  86. * Authenticate a user based on a username and password.
  87. *
  88. * @param username
  89. * @param password
  90. * @return a user object or null
  91. */
  92. UserModel authenticate(String username, char[] password);
  93. /**
  94. * Logout a user.
  95. *
  96. * @param user
  97. */
  98. void logout(UserModel user);
  99. /**
  100. * Retrieve the user object for the specified username.
  101. *
  102. * @param username
  103. * @return a user object or null
  104. */
  105. UserModel getUserModel(String username);
  106. /**
  107. * Updates/writes a complete user object.
  108. *
  109. * @param model
  110. * @return true if update is successful
  111. */
  112. boolean updateUserModel(UserModel model);
  113. /**
  114. * Adds/updates a user object keyed by username. This method allows for
  115. * renaming a user.
  116. *
  117. * @param username
  118. * the old username
  119. * @param model
  120. * the user object to use for username
  121. * @return true if update is successful
  122. */
  123. boolean updateUserModel(String username, UserModel model);
  124. /**
  125. * Deletes the user object from the user service.
  126. *
  127. * @param model
  128. * @return true if successful
  129. */
  130. boolean deleteUserModel(UserModel model);
  131. /**
  132. * Delete the user object with the specified username
  133. *
  134. * @param username
  135. * @return true if successful
  136. */
  137. boolean deleteUser(String username);
  138. /**
  139. * Returns the list of all users available to the login service.
  140. *
  141. * @return list of all usernames
  142. */
  143. List<String> getAllUsernames();
  144. /**
  145. * Returns the list of all users available to the login service.
  146. *
  147. * @return list of all users
  148. * @since 0.8.0
  149. */
  150. List<UserModel> getAllUsers();
  151. /**
  152. * Returns the list of all teams available to the login service.
  153. *
  154. * @return list of all teams
  155. * @since 0.8.0
  156. */
  157. List<String> getAllTeamNames();
  158. /**
  159. * Returns the list of all teams available to the login service.
  160. *
  161. * @return list of all teams
  162. * @since 0.8.0
  163. */
  164. List<TeamModel> getAllTeams();
  165. /**
  166. * Returns the list of all users who are allowed to bypass the access
  167. * restriction placed on the specified repository.
  168. *
  169. * @param role
  170. * the repository name
  171. * @return list of all usernames that can bypass the access restriction
  172. * @since 0.8.0
  173. */
  174. List<String> getTeamnamesForRepositoryRole(String role);
  175. /**
  176. * Sets the list of all teams who are allowed to bypass the access
  177. * restriction placed on the specified repository.
  178. *
  179. * @param role
  180. * the repository name
  181. * @param teamnames
  182. * @return true if successful
  183. * @since 0.8.0
  184. */
  185. boolean setTeamnamesForRepositoryRole(String role, List<String> teamnames);
  186. /**
  187. * Retrieve the team object for the specified team name.
  188. *
  189. * @param teamname
  190. * @return a team object or null
  191. * @since 0.8.0
  192. */
  193. TeamModel getTeamModel(String teamname);
  194. /**
  195. * Updates/writes a complete team object.
  196. *
  197. * @param model
  198. * @return true if update is successful
  199. * @since 0.8.0
  200. */
  201. boolean updateTeamModel(TeamModel model);
  202. /**
  203. * Updates/writes and replaces a complete team object keyed by teamname.
  204. * This method allows for renaming a team.
  205. *
  206. * @param teamname
  207. * the old teamname
  208. * @param model
  209. * the team object to use for teamname
  210. * @return true if update is successful
  211. * @since 0.8.0
  212. */
  213. boolean updateTeamModel(String teamname, TeamModel model);
  214. /**
  215. * Deletes the team object from the user service.
  216. *
  217. * @param model
  218. * @return true if successful
  219. * @since 0.8.0
  220. */
  221. boolean deleteTeamModel(TeamModel model);
  222. /**
  223. * Delete the team object with the specified teamname
  224. *
  225. * @param teamname
  226. * @return true if successful
  227. * @since 0.8.0
  228. */
  229. boolean deleteTeam(String teamname);
  230. /**
  231. * Returns the list of all users who are allowed to bypass the access
  232. * restriction placed on the specified repository.
  233. *
  234. * @param role
  235. * the repository name
  236. * @return list of all usernames that can bypass the access restriction
  237. * @since 0.8.0
  238. */
  239. List<String> getUsernamesForRepositoryRole(String role);
  240. /**
  241. * Sets the list of all uses who are allowed to bypass the access
  242. * restriction placed on the specified repository.
  243. *
  244. * @param role
  245. * the repository name
  246. * @param usernames
  247. * @return true if successful
  248. */
  249. boolean setUsernamesForRepositoryRole(String role, List<String> usernames);
  250. /**
  251. * Renames a repository role.
  252. *
  253. * @param oldRole
  254. * @param newRole
  255. * @return true if successful
  256. */
  257. boolean renameRepositoryRole(String oldRole, String newRole);
  258. /**
  259. * Removes a repository role from all users.
  260. *
  261. * @param role
  262. * @return true if successful
  263. */
  264. boolean deleteRepositoryRole(String role);
  265. /**
  266. * @See java.lang.Object.toString();
  267. * @return string representation of the login service
  268. */
  269. String toString();
  270. }