1 /*
2 * Licensed to The Apereo Foundation under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work for additional
4 * information regarding copyright ownership.
5 *
6 *
7 * The Apereo Foundation licenses this file to you under the Educational
8 * Community License, Version 2.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of the License
10 * at:
11 *
12 * http://opensource.org/licenses/ecl2.txt
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 * License for the specific language governing permissions and limitations under
18 * the License.
19 *
20 */
21
22 package org.opencastproject.userdirectory.api;
23
24 import org.opencastproject.security.api.Group;
25 import org.opencastproject.security.api.GroupProvider;
26 import org.opencastproject.security.api.Role;
27 import org.opencastproject.security.api.RoleProvider;
28 import org.opencastproject.security.api.UnauthorizedException;
29 import org.opencastproject.security.impl.jpa.JpaGroup;
30 import org.opencastproject.util.NotFoundException;
31
32 import java.util.Iterator;
33 import java.util.List;
34
35 public interface GroupRoleProvider extends GroupProvider, RoleProvider {
36
37
38 /**
39 * {@inheritDoc}
40 *
41 * @see org.opencastproject.security.api.RoleProvider#getRolesForUser(String)
42 */
43 List<Role> getRolesForUser(String userName);
44
45 /**
46 * {@inheritDoc}
47 *
48 * @see org.opencastproject.security.api.RoleProvider#getRolesForUser(String)
49 */
50 List<Role> getRolesForGroup(String groupName);
51
52 /**
53 * {@inheritDoc}
54 *
55 * @see org.opencastproject.security.api.RoleProvider#getOrganization()
56 */
57 String getOrganization();
58
59 /**
60 * Updates a user's group membership
61 *
62 * @param userName
63 * the username
64 * @param orgId
65 * the user's organization
66 * @param roleList
67 * the list of group role names
68 */
69 void updateGroupMembershipFromRoles(String userName,
70 String orgId, List<String> roleList);
71
72 /**
73 * Adds or updates a group to the persistence.
74 *
75 * @param group
76 * the group to add
77 */
78 void addGroup(JpaGroup group) throws UnauthorizedException;
79
80 /**
81 * Getting all groups
82 *
83 * @return Iterator<Group> persisted groups
84 */
85 Iterator<Group> getGroups();
86
87 /**
88 * Update a group
89 *
90 * @param groupId
91 * the id of the group to update
92 * @param name
93 * the name to update
94 * @param description
95 * the description to update
96 * @param roles
97 * the roles to update
98 * @param users
99 * the users to update
100 * @throws NotFoundException
101 * if the group is not found
102 * @throws UnauthorizedException
103 * if the user does not have rights to update the group
104 */
105 void updateGroup(String groupId, String name,
106 String description, String roles, String users)
107 throws NotFoundException, UnauthorizedException;
108
109 }