/src/main/java/com/atlassian/crowd/service/client/CrowdClient.java

https://bitbucket.org/atlassian/crowd-rest-client · Java · 726 lines · 136 code · 56 blank · 534 comment · 0 complexity · 403bd2ea63f529899c8fb7157aa52e04 MD5 · raw file

  1. /*
  2. * Copyright © 2010 - 2015 Atlassian Corporation Pty Ltd.
  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. * https://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.atlassian.crowd.service.client;
  17. import com.atlassian.crowd.embedded.api.PasswordCredential;
  18. import com.atlassian.crowd.embedded.api.SearchRestriction;
  19. import com.atlassian.crowd.event.EventTokenExpiredException;
  20. import com.atlassian.crowd.event.Events;
  21. import com.atlassian.crowd.event.IncrementalSynchronisationNotAvailableException;
  22. import com.atlassian.crowd.exception.ApplicationAccessDeniedException;
  23. import com.atlassian.crowd.exception.ApplicationPermissionException;
  24. import com.atlassian.crowd.exception.ExpiredCredentialException;
  25. import com.atlassian.crowd.exception.GroupNotFoundException;
  26. import com.atlassian.crowd.exception.InactiveAccountException;
  27. import com.atlassian.crowd.exception.InvalidAuthenticationException;
  28. import com.atlassian.crowd.exception.InvalidCredentialException;
  29. import com.atlassian.crowd.exception.InvalidEmailAddressException;
  30. import com.atlassian.crowd.exception.InvalidGroupException;
  31. import com.atlassian.crowd.exception.InvalidTokenException;
  32. import com.atlassian.crowd.exception.InvalidUserException;
  33. import com.atlassian.crowd.exception.MembershipAlreadyExistsException;
  34. import com.atlassian.crowd.exception.MembershipNotFoundException;
  35. import com.atlassian.crowd.exception.OperationFailedException;
  36. import com.atlassian.crowd.exception.UnsupportedCrowdApiException;
  37. import com.atlassian.crowd.exception.UserNotFoundException;
  38. import com.atlassian.crowd.exception.WebhookNotFoundException;
  39. import com.atlassian.crowd.model.authentication.CookieConfiguration;
  40. import com.atlassian.crowd.model.authentication.Session;
  41. import com.atlassian.crowd.model.authentication.UserAuthenticationContext;
  42. import com.atlassian.crowd.model.authentication.ValidationFactor;
  43. import com.atlassian.crowd.model.group.Group;
  44. import com.atlassian.crowd.model.group.GroupWithAttributes;
  45. import com.atlassian.crowd.model.group.Membership;
  46. import com.atlassian.crowd.model.user.User;
  47. import com.atlassian.crowd.model.user.UserWithAttributes;
  48. import java.util.List;
  49. import java.util.Map;
  50. import java.util.Set;
  51. import javax.annotation.Nullable;
  52. /**
  53. * Atlassian Crowd client interface.
  54. */
  55. public interface CrowdClient
  56. {
  57. /**
  58. * Gets a User by user name.
  59. * @param name Name of the user to retrieve
  60. * @return A User.
  61. * @throws UserNotFoundException if the user is not found
  62. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  63. * @throws InvalidAuthenticationException if the application and password are not valid
  64. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  65. */
  66. User getUser(String name)
  67. throws UserNotFoundException, OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException;
  68. /**
  69. * Gets a User with Attributes by user name.
  70. * @param name Name of the user to retrieve
  71. * @return A User.
  72. * @throws UserNotFoundException if the user is not found
  73. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  74. * @throws InvalidAuthenticationException if the application and password are not valid
  75. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  76. */
  77. UserWithAttributes getUserWithAttributes(String name)
  78. throws UserNotFoundException, OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException;
  79. /**
  80. * Gets a User by key.
  81. * @param key Name of the user to retrieve
  82. * @return A User.
  83. * @throws UserNotFoundException if the user is not found
  84. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  85. * @throws InvalidAuthenticationException if the application and password are not valid
  86. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  87. */
  88. User getUserByKey(String key)
  89. throws UserNotFoundException, OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException;
  90. /**
  91. * Authenticates a user with the server.
  92. *
  93. * @param username Name of the user to authenticate.
  94. * @param password Password of the user to authenticate.
  95. * @return user if the user is correctly authenticated
  96. * @throws UserNotFoundException if the user could not be found
  97. * @throws InactiveAccountException if the user account is not active
  98. * @throws ExpiredCredentialException if the user credentials have expired
  99. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  100. * @throws InvalidAuthenticationException if the application and password are not valid
  101. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  102. */
  103. User authenticateUser(String username, String password)
  104. throws UserNotFoundException, InactiveAccountException, ExpiredCredentialException, ApplicationPermissionException, InvalidAuthenticationException, OperationFailedException;
  105. /**
  106. * Adds a new User to the remote Crowd server.
  107. * @param user The user to add
  108. * @param passwordCredential user password
  109. * @throws InvalidUserException if the user is invalid. This may be because a user of the same name
  110. * already exists, or does not pass the server side validation rules.
  111. * @throws InvalidCredentialException if the password is invalid. It must conform to the rules set on the server
  112. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  113. * @throws InvalidAuthenticationException if the application and password are not valid
  114. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  115. */
  116. void addUser(User user, PasswordCredential passwordCredential)
  117. throws InvalidUserException, InvalidCredentialException, OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  118. /**
  119. * Updates a user on the remote Crowd server.
  120. * @param user The user to update
  121. * @throws InvalidUserException the details of the user to be updated are invalid. This may be because the user details
  122. * do not pass the server side validation rules.
  123. * @throws UserNotFoundException if the user does not exist on the remote Crowd server
  124. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  125. * @throws InvalidAuthenticationException if the application and password are not valid
  126. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  127. */
  128. void updateUser(User user)
  129. throws InvalidUserException, UserNotFoundException, OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException;
  130. /**
  131. * Updates the user's password on the remote Crowd server.
  132. * @param username Name of the user to update.
  133. * @param password New password. A null value indicates that the user's password should be cleared.
  134. * @throws UserNotFoundException if the user does not exist on the remote Crowd server
  135. * @throws InvalidCredentialException if the password is invalid. It must conform to the rules set on the server
  136. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  137. * @throws InvalidAuthenticationException if the application and password are not valid
  138. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  139. */
  140. void updateUserCredential(String username, @Nullable String password)
  141. throws UserNotFoundException, InvalidCredentialException, OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException;
  142. /**
  143. * Stores the user's attributes on the remote Crowd server.
  144. * @param username Name of the user.
  145. * @param attributes Set of Attributes to store. Attributes will be added or if an attribute with the
  146. * same key exists will be replaced.
  147. * @throws UserNotFoundException if the user does not exist on the remote Crowd server
  148. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  149. * @throws InvalidAuthenticationException if the application and password are not valid
  150. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  151. */
  152. void storeUserAttributes(String username, Map<String, Set<String>> attributes)
  153. throws UserNotFoundException, OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException;
  154. /**
  155. * Removes a user attribute from the server.
  156. * If the attribute to be removed does not exist, no error is reported.
  157. * @param username Name of the user
  158. * @param attributeName Attribute key.
  159. * @throws UserNotFoundException if the user does not exist on the remote Crowd server
  160. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  161. * @throws InvalidAuthenticationException if the application and password are not valid
  162. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  163. */
  164. void removeUserAttributes(String username, String attributeName)
  165. throws UserNotFoundException, OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  166. /**
  167. * Removes a user from the remote Crowd server
  168. * @param username Name of the user to remove.
  169. * @throws UserNotFoundException if the user does not exist on the remote Crowd server
  170. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  171. * @throws InvalidAuthenticationException if the application and password are not valid
  172. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  173. */
  174. void removeUser(String username)
  175. throws UserNotFoundException, OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  176. /**
  177. * Requests a password reset.
  178. *
  179. * @param username name of the user
  180. * @throws UserNotFoundException if the user does not exist
  181. * @throws InvalidEmailAddressException if the user does not have a valid email to send the reset password link to
  182. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  183. * @throws InvalidAuthenticationException if the application and password are not valid
  184. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  185. */
  186. public void requestPasswordReset(final String username) throws UserNotFoundException, InvalidEmailAddressException, OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  187. /**
  188. * Sends the usernames associated with the given email address. No email will be sent if there are no usernames
  189. * associated with a given <code>email</code>.
  190. *
  191. * @param email email address of the user
  192. * @throws InvalidEmailAddressException if the <code>email</code> is not valid
  193. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  194. * @throws InvalidAuthenticationException if the application and password are not valid
  195. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  196. */
  197. public void requestUsernames(final String email) throws InvalidEmailAddressException, OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  198. /**
  199. * Gets a group by name.
  200. * @param name name of the group to retrieve.
  201. * @return A Group
  202. * @throws GroupNotFoundException if the group does not exist on the remote server
  203. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  204. * @throws InvalidAuthenticationException if the application and password are not valid
  205. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  206. */
  207. Group getGroup(String name)
  208. throws GroupNotFoundException, OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  209. /**
  210. * Gets a group with attributes by name.
  211. * @param name name of the group to retrieve.
  212. * @return A Group with attributes.
  213. * @throws GroupNotFoundException if the group does not exist on the remote server
  214. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  215. * @throws InvalidAuthenticationException if the application and password are not valid
  216. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  217. */
  218. GroupWithAttributes getGroupWithAttributes(String name)
  219. throws GroupNotFoundException, OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  220. /**
  221. * Adds a group to the remote Crowd server.
  222. * @param group Group to add.
  223. * @throws InvalidGroupException if the group is invalid. This may be because a group of the same name already exists, or
  224. * does not pass the server side validation rules
  225. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  226. * @throws InvalidAuthenticationException if the application and password are not valid
  227. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  228. */
  229. void addGroup(Group group)
  230. throws InvalidGroupException, ApplicationPermissionException, InvalidAuthenticationException, OperationFailedException;
  231. /**
  232. * Updates a group on the remote Crowd server.
  233. * @param group Group to update.
  234. * @throws InvalidGroupException The group is invalid. This may be because the group
  235. * does not pass the server side validation rules.
  236. * @throws GroupNotFoundException if the group does not exist on the remote server
  237. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  238. * @throws InvalidAuthenticationException if the application and password are not valid
  239. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  240. */
  241. void updateGroup(Group group)
  242. throws InvalidGroupException, GroupNotFoundException, OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException;
  243. /**
  244. * Stores the group's attributes on the remote Crowd server.
  245. * @param groupName Name of the group.
  246. * @param attributes Set of Attributes to store. Attributes will be added or if an attribute with the
  247. * same key exists will be replaced.
  248. * @throws GroupNotFoundException if the group does not exist on the remote Crowd server
  249. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  250. * @throws InvalidAuthenticationException if the application and password are not valid
  251. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  252. */
  253. void storeGroupAttributes(String groupName, Map<String, Set<String>> attributes)
  254. throws GroupNotFoundException, OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException;
  255. /**
  256. * Removes a group attribute (set) from the server.
  257. * If the attribute to be removed does not exist, no error is reported.
  258. * @param groupName Name of the group
  259. * @param attributeName Attribute key.
  260. * @throws GroupNotFoundException the group does not exist on the remote Crowd server
  261. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  262. * @throws InvalidAuthenticationException if the application and password are not valid
  263. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  264. */
  265. void removeGroupAttributes(String groupName, String attributeName)
  266. throws GroupNotFoundException, OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException;
  267. /**
  268. * Removes a group from the remote Crowd server
  269. * @param groupName Name of the group to remove.
  270. * @throws GroupNotFoundException the group does not exist on the remote Crowd server
  271. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  272. * @throws InvalidAuthenticationException if the application and password are not valid
  273. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  274. */
  275. void removeGroup(String groupName)
  276. throws GroupNotFoundException, OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException;
  277. /**
  278. * Tests if a user is a direct member of a group.
  279. * @param username User name
  280. * @param groupName Group Name
  281. * @return true if the member is a direct member of the group.
  282. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  283. * @throws InvalidAuthenticationException if the application and password are not valid
  284. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  285. */
  286. boolean isUserDirectGroupMember(String username, String groupName)
  287. throws OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException;
  288. /**
  289. * Tests if a user is a nested member of a group.
  290. * @param username User name
  291. * @param groupName Group Name
  292. * @return true if the member is a nested member of the group.
  293. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  294. * @throws InvalidAuthenticationException if the application and password are not valid
  295. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  296. */
  297. boolean isUserNestedGroupMember(String username, String groupName)
  298. throws OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException;
  299. /**
  300. * Tests if a group is a direct member of a group.
  301. * @param childName Name of the child group
  302. * @param parentName Name of the Parent group
  303. * @return true if the child group is a direct member of the parent group.
  304. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  305. * @throws InvalidAuthenticationException if the application and password are not valid
  306. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  307. */
  308. boolean isGroupDirectGroupMember(String childName, String parentName)
  309. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  310. /**
  311. * Adds a user to a group.
  312. * @param username Name of the user to add to the group.
  313. * @param groupName Name of the group to be added to.
  314. * @throws GroupNotFoundException if the group does not exist.
  315. * @throws UserNotFoundException if the user does not exist.
  316. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  317. * @throws InvalidAuthenticationException if the application and password are not valid
  318. * @throws MembershipAlreadyExistsException if the user is already a member fo the group
  319. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  320. */
  321. void addUserToGroup(String username, String groupName)
  322. throws GroupNotFoundException, UserNotFoundException, OperationFailedException,
  323. MembershipAlreadyExistsException, InvalidAuthenticationException, ApplicationPermissionException;
  324. /**
  325. * Adds a group to a group.
  326. * @param childGroup Name of the group to add to the parent group.
  327. * @param parentGroup Name of the group the child will be added to.
  328. * @throws GroupNotFoundException if either group does not exist
  329. * @throws UserNotFoundException if the user does not exist
  330. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  331. * @throws InvalidAuthenticationException if the application and password are not valid
  332. * @throws MembershipAlreadyExistsException if the child group is already a member of the parent group
  333. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  334. */
  335. void addGroupToGroup(String childGroup, String parentGroup)
  336. throws GroupNotFoundException, UserNotFoundException, OperationFailedException,
  337. InvalidAuthenticationException, ApplicationPermissionException, MembershipAlreadyExistsException;
  338. /**
  339. * Removes a user from a group.
  340. * @param username Name of the user to add to the group.
  341. * @param groupName Name of the group to be added to.
  342. * @throws MembershipNotFoundException if the membership does not exist
  343. * @throws GroupNotFoundException if the group does not exist.
  344. * @throws UserNotFoundException if the user does not exist.
  345. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  346. * @throws InvalidAuthenticationException if the application and password are not valid
  347. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  348. */
  349. void removeUserFromGroup(String username, String groupName)
  350. throws MembershipNotFoundException, GroupNotFoundException, UserNotFoundException, ApplicationPermissionException, InvalidAuthenticationException, OperationFailedException;
  351. /**
  352. * Removes a group to a group.
  353. * @param childGroup Name of the group to be removed from the parent group.
  354. * @param parentGroup Name of the group the child group will be removed from.
  355. * @throws GroupNotFoundException if either group does not exist.
  356. * @throws MembershipNotFoundException if there is not parent-child relationship between the specified groups
  357. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  358. * @throws InvalidAuthenticationException if the application and password are not valid
  359. * @throws OperationFailedException if for some reason the operation has failed
  360. */
  361. void removeGroupFromGroup(String childGroup, String parentGroup)
  362. throws MembershipNotFoundException, GroupNotFoundException, OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  363. /**
  364. * Tests if the connection is OK. This test uses a user search to validate the connection.
  365. * It will fail if the application does not have permission to perform this very basic operation.
  366. *
  367. * @throws InvalidAuthenticationException if the application and password are not valid
  368. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  369. * @throws OperationFailedException if the test fails
  370. */
  371. void testConnection()
  372. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  373. /**
  374. * Searches for users matching the following criteria.
  375. *
  376. * @param searchRestriction restriction on the search
  377. * @param startIndex starting index of the search results
  378. * @param maxResults maximum number of results returned from the search
  379. * @return List of users satisfying the search restriction.
  380. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  381. * @throws InvalidAuthenticationException if the application and password are not valid
  382. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  383. */
  384. List<User> searchUsers(final SearchRestriction searchRestriction, int startIndex, int maxResults)
  385. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  386. /**
  387. * Searches for usernames matching the <tt>searchRestriction</tt> criteria.
  388. *
  389. * @param searchRestriction restriction on the search
  390. * @param startIndex starting index of the search results
  391. * @param maxResults maximum number of results returned from the search
  392. * @return List of usernames satisfying the search restriction.
  393. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  394. * @throws InvalidAuthenticationException if the application and password are not valid
  395. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  396. */
  397. List<String> searchUserNames(final SearchRestriction searchRestriction, final int startIndex, final int maxResults)
  398. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  399. /**
  400. * Searches for groups matching the following criteria.
  401. *
  402. * @param searchRestriction restriction on the search
  403. * @param startIndex starting index of the search results
  404. * @param maxResults maximum number of results returned from the search
  405. * @return List of groups satisfying the search restriction.
  406. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  407. * @throws InvalidAuthenticationException if the application and password are not valid
  408. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  409. */
  410. List<Group> searchGroups(final SearchRestriction searchRestriction, int startIndex, int maxResults)
  411. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  412. List<GroupWithAttributes> searchGroupsWithAttributes(final SearchRestriction searchRestriction, int startIndex, int maxResults)
  413. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  414. /**
  415. * Searches for group names matching the <tt>searchRestriction</tt> criteria.
  416. *
  417. * @param searchRestriction restriction on the search
  418. * @param startIndex starting index of the search results
  419. * @param maxResults maximum number of results returned from the search
  420. * @return List of group names satisfying the search restriction.
  421. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  422. * @throws InvalidAuthenticationException if the application and password are not valid
  423. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  424. */
  425. List<String> searchGroupNames(final SearchRestriction searchRestriction, final int startIndex, final int maxResults)
  426. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException;
  427. /**
  428. * Searches for users who are direct members of a group.
  429. *
  430. * @param groupName restriction on the search
  431. * @param startIndex starting index of the search results
  432. * @param maxResults maximum number of results returned from the search
  433. * @return List of users satisfying the search restriction.
  434. * @throws GroupNotFoundException if the group could not be found
  435. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  436. * @throws InvalidAuthenticationException if the application and password are not valid
  437. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  438. */
  439. List<User> getUsersOfGroup(final String groupName, final int startIndex, final int maxResults)
  440. throws GroupNotFoundException, ApplicationPermissionException, InvalidAuthenticationException, OperationFailedException;
  441. /**
  442. * Searches for users who are direct members of a group, returning the user names.
  443. *
  444. * @param groupName restriction on the search
  445. * @param startIndex starting index of the search results
  446. * @param maxResults maximum number of results returned from the search
  447. * @return List of user names satisfying the search restriction.
  448. * @throws GroupNotFoundException if the group could not be found
  449. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  450. * @throws InvalidAuthenticationException if the application and password are not valid
  451. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  452. */
  453. List<String> getNamesOfUsersOfGroup(final String groupName, final int startIndex, final int maxResults)
  454. throws GroupNotFoundException, ApplicationPermissionException, InvalidAuthenticationException, OperationFailedException;
  455. /**
  456. * Searches for groups who are direct members of a group.
  457. *
  458. * @param groupName restriction on the search
  459. * @param startIndex starting index of the search results
  460. * @param maxResults maximum number of results returned from the search
  461. * @return List of groups satisfying the search restrictions
  462. * @throws GroupNotFoundException if the group could not be found
  463. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  464. * @throws InvalidAuthenticationException if the application and password are not valid
  465. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  466. */
  467. List<Group> getChildGroupsOfGroup(final String groupName, final int startIndex, final int maxResults)
  468. throws GroupNotFoundException, ApplicationPermissionException, InvalidAuthenticationException, OperationFailedException;
  469. /**
  470. * Searches for groups who are direct members of a group, returning the group names.
  471. *
  472. * @param groupName restriction on the search
  473. * @param startIndex starting index of the search results
  474. * @param maxResults maximum number of results returned from the search
  475. * @return List of group names satisfying the search restriction.
  476. * @throws GroupNotFoundException if the group could not be found
  477. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  478. * @throws InvalidAuthenticationException if the application and password are not valid
  479. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  480. */
  481. List<String> getNamesOfChildGroupsOfGroup(final String groupName, final int startIndex, final int maxResults)
  482. throws OperationFailedException, GroupNotFoundException, InvalidAuthenticationException, ApplicationPermissionException;
  483. /**
  484. * Searches for groups that a user is a direct member of.
  485. *
  486. * @param userName restriction on the search
  487. * @param startIndex starting index of the search results
  488. * @param maxResults maximum number of results returned from the search
  489. * @return List of groups satisfying the search restriction.
  490. * @throws UserNotFoundException if the user could not be found
  491. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  492. * @throws InvalidAuthenticationException if the application and password are not valid
  493. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  494. */
  495. List<Group> getGroupsForUser(final String userName, final int startIndex, final int maxResults)
  496. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, UserNotFoundException;
  497. /**
  498. * Searches for groups that a user is a direct member of, returning the group names.
  499. *
  500. * @param userName restriction on the search
  501. * @param startIndex starting index of the search results
  502. * @param maxResults maximum number of results returned from the search
  503. * @return List of group names satisfying the search restriction.
  504. * @throws UserNotFoundException if the user could not be found
  505. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  506. * @throws InvalidAuthenticationException if the application and password are not valid
  507. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  508. */
  509. List<String> getNamesOfGroupsForUser(final String userName, final int startIndex, final int maxResults)
  510. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, UserNotFoundException;
  511. /**
  512. * Searches for groups that a group is a direct member of.
  513. *
  514. * @param groupName restriction on the search
  515. * @param startIndex starting index of the search results
  516. * @param maxResults maximum number of results returned from the search
  517. * @return List of groups satisfying the search restriction.
  518. * @throws GroupNotFoundException if the group could not be found
  519. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  520. * @throws InvalidAuthenticationException if the application and password are not valid
  521. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  522. */
  523. List<Group> getParentGroupsForGroup(final String groupName, final int startIndex, final int maxResults)
  524. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, GroupNotFoundException;
  525. /**
  526. * Searches for groups that a group is a direct member of, returning the group names.
  527. *
  528. * @param groupName restriction on the search
  529. * @param startIndex starting index of the search results
  530. * @param maxResults maximum number of results returned from the search
  531. * @return List of group names satisfying the search restriction
  532. * @throws GroupNotFoundException if the group could not be found
  533. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  534. * @throws InvalidAuthenticationException if the application and password are not valid
  535. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  536. */
  537. List<String> getNamesOfParentGroupsForGroup(final String groupName, final int startIndex, final int maxResults)
  538. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, GroupNotFoundException;
  539. /**
  540. * Searches for users who are nested members of a group.
  541. *
  542. * @param groupName restriction on the search
  543. * @param startIndex starting index of the search results
  544. * @param maxResults maximum number of results returned from the search
  545. * @return List of users satisfying the search restriction.
  546. * @throws GroupNotFoundException if the group could not be found
  547. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  548. * @throws InvalidAuthenticationException if the application and password are not valid
  549. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  550. */
  551. List<User> getNestedUsersOfGroup(final String groupName, final int startIndex, final int maxResults)
  552. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, GroupNotFoundException;
  553. /**
  554. * Searches for users who are nested members of a group, returning the user names.
  555. *
  556. * @param groupName restriction on the search
  557. * @param startIndex starting index of the search results
  558. * @param maxResults maximum number of results returned from the search
  559. * @return List of user names satisfying the search restriction.
  560. * @throws GroupNotFoundException if the group could not be found
  561. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  562. * @throws InvalidAuthenticationException if the application and password are not valid
  563. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  564. */
  565. List<String> getNamesOfNestedUsersOfGroup(final String groupName, final int startIndex, final int maxResults)
  566. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, GroupNotFoundException;
  567. /**
  568. * Searches for groups who are nested members of a group.
  569. *
  570. * @param groupName restriction on the search
  571. * @param startIndex starting index of the search results
  572. * @param maxResults maximum number of results returned from the search
  573. * @return List of groups satisfying the search restriction.
  574. * @throws GroupNotFoundException if the group could not be found
  575. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  576. * @throws InvalidAuthenticationException if the application and password are not valid
  577. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  578. */
  579. List<Group> getNestedChildGroupsOfGroup(final String groupName, final int startIndex, final int maxResults)
  580. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, GroupNotFoundException;
  581. /**
  582. * Searches for groups who are nested members of a group, returning the group names.
  583. *
  584. * @param groupName restriction on the search
  585. * @param startIndex starting index of the search results
  586. * @param maxResults maximum number of results returned from the search
  587. * @return List of group names satisfying the search restriction.
  588. * @throws GroupNotFoundException if the group could not be found
  589. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  590. * @throws InvalidAuthenticationException if the application and password are not valid
  591. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  592. */
  593. List<String> getNamesOfNestedChildGroupsOfGroup(final String groupName, final int startIndex, final int maxResults)
  594. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, GroupNotFoundException;
  595. /**
  596. * Searches for groups that a user is a nested member of.
  597. *
  598. * @param userName restriction on the search
  599. * @param startIndex starting index of the search results
  600. * @param maxResults maximum number of results returned from the search
  601. * @return List of groups satisfying the search restriction.
  602. * @throws UserNotFoundException if the user could not be found
  603. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  604. * @throws InvalidAuthenticationException if the application and password are not valid
  605. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  606. */
  607. List<Group> getGroupsForNestedUser(final String userName, final int startIndex, final int maxResults)
  608. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, UserNotFoundException;
  609. /**
  610. * Searches for groups that a user is a nested member of, returning the group names.
  611. *
  612. * @param userName restriction on the search
  613. * @param startIndex starting index of the search results
  614. * @param maxResults maximum number of results returned from the search
  615. * @return List of group names satisfying the search restriction.
  616. * @throws UserNotFoundException if the user could not be found
  617. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  618. * @throws InvalidAuthenticationException if the application and password are not valid
  619. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  620. */
  621. List<String> getNamesOfGroupsForNestedUser(final String userName, final int startIndex, final int maxResults)
  622. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, UserNotFoundException;
  623. /**
  624. * Searches for groups that a group is a nested member of.
  625. *
  626. * @param groupName restriction on the search
  627. * @param startIndex starting index of the search results
  628. * @param maxResults maximum number of results returned from the search
  629. * @return List of groups satisfying the search restriction.
  630. * @throws GroupNotFoundException if the group could not be found
  631. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  632. * @throws InvalidAuthenticationException if the application and password are not valid
  633. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  634. */
  635. List<Group> getParentGroupsForNestedGroup(final String groupName, final int startIndex, final int maxResults)
  636. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, GroupNotFoundException;
  637. /**
  638. * Searches for groups that a group is a nested member of, returning the group names.
  639. *
  640. * @param groupName restriction on the search
  641. * @param startIndex starting index of the search results
  642. * @param maxResults maximum number of results returned from the search
  643. * @return List of group names satisfying the search restriction.
  644. * @throws GroupNotFoundException if the group could not be found
  645. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server.
  646. * @throws InvalidAuthenticationException if the application and password are not valid.
  647. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  648. */
  649. List<String> getNamesOfParentGroupsForNestedGroup(final String groupName, final int startIndex, final int maxResults)
  650. throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, GroupNotFoundException;
  651. /**
  652. * <p>Gets the full group membership details for all groups with all direct user members and child groups. The result
  653. * may be large and this operation may be slow.</p>
  654. *
  655. * <p>This method is only supported when the server supports version 1.1 of the user management API. Clients
  656. * should be ready to catch {@link UnsupportedCrowdApiException} and fall back to another technique
  657. * if they need to remain backwards compatible.</p>
  658. *
  659. * @return an {@link Iterable} of the memberships for all groups
  660. * @throws UnsupportedCrowdApiException if the server does not support version 1.1 of the user management API
  661. * @throws ApplicationPermissionException if the application is not permitted to perform the requested operation on the server
  662. * @throws InvalidAuthenticationException if the application and password are not valid
  663. * @throws OperationFailedException if the operation has failed for any other reason, including invalid arguments and the operation not being supported on the server.
  664. */
  665. Iterable<Membership> getMemberships()
  666. throws OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException, UnsupportedCrowdApiException;
  667. /**
  668. * Returns the user from the specified user token.
  669. *