1 package com.atlassian.user.impl.ldap;
2
3 import com.atlassian.user.Entity;
4 import com.atlassian.user.EntityException;
5 import com.atlassian.user.Group;
6 import com.atlassian.user.User;
7 import com.atlassian.user.impl.ReadOnlyGroupManager;
8 import com.atlassian.user.impl.ldap.adaptor.LDAPGroupAdaptor;
9 import com.atlassian.user.repository.RepositoryIdentifier;
10 import com.atlassian.user.search.page.DefaultPager;
11 import com.atlassian.user.search.page.Pager;
12
13 public class LDAPGroupManagerReadOnly extends ReadOnlyGroupManager
14 {
15 private final RepositoryIdentifier repositoryIdentifier;
16 private final LDAPGroupAdaptor groupAdaptor;
17
18 public LDAPGroupManagerReadOnly(RepositoryIdentifier repositoryIdentifier, LDAPGroupAdaptor groupAdaptor)
19 {
20 this.repositoryIdentifier = repositoryIdentifier;
21 this.groupAdaptor = groupAdaptor;
22 }
23
24
25
26
27 public RepositoryIdentifier getIdentifier()
28 {
29 return repositoryIdentifier;
30 }
31
32 public RepositoryIdentifier getRepository(Entity entity) throws EntityException
33 {
34 if (getGroup(entity.getName()) == null)
35 return null;
36
37 return repositoryIdentifier;
38
39 }
40
41 public Pager<Group> getGroups() throws EntityException
42 {
43 return groupAdaptor.getGroups();
44 }
45
46 public Group getGroup(String groupName) throws EntityException
47 {
48 return groupAdaptor.getGroup(groupName);
49 }
50
51 public Pager<Group> getGroups(User user) throws EntityException
52 {
53 if (!LDAPValidator.validateLDAPEntity(user))
54 return DefaultPager.emptyPager();
55
56 return groupAdaptor.getGroups(user);
57 }
58
59 public Pager<String> getMemberNames(Group group) throws EntityException
60 {
61 if (!LDAPValidator.validateLDAPEntity(group))
62 return DefaultPager.emptyPager();
63
64 return groupAdaptor.findMemberNames(group);
65 }
66
67 public Pager<String> getLocalMemberNames(Group group) throws EntityException
68 {
69 if (!LDAPValidator.validateLDAPEntity(group))
70 return DefaultPager.emptyPager();
71
72 return groupAdaptor.findMembers(group);
73 }
74
75 public Pager<String> getExternalMemberNames(Group group) throws EntityException
76 {
77 throw new UnsupportedOperationException("External membership is not supported.");
78 }
79
80 public boolean hasMembership(Group group, User user) throws EntityException
81 {
82 return groupAdaptor.hasMembership(group, user);
83 }
84
85 public boolean supportsExternalMembership() throws EntityException
86 {
87 return false;
88 }
89 }