1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.cms.security;
35
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38
39 import java.util.Collection;
40 import java.util.Collections;
41
42
43
44
45
46 public class MgnlGroup implements Group {
47 private static final Logger log = LoggerFactory.getLogger(MgnlGroup.class);
48
49 private final String name;
50 private final Collection<String> groups;
51 private final Collection<String> roles;
52 private final String id;
53
54 public MgnlGroup(String id, String groupName, Collection<String> subgroupNames, Collection<String> roleNames) {
55 this.id = id;
56 this.name = groupName;
57 this.groups = Collections.unmodifiableCollection(subgroupNames);
58 this.roles = Collections.unmodifiableCollection(roleNames);
59 }
60
61 @Override
62 public String getName() {
63 return this.name;
64 }
65
66 @Override
67 public void addRole(String roleName) throws UnsupportedOperationException, AccessDeniedException {
68 throw new UnsupportedOperationException("Use manager to modify this group");
69 }
70
71
72
73
74 @Override
75 public void addGroup(String groupName) throws UnsupportedOperationException, AccessDeniedException {
76 throw new UnsupportedOperationException("Use manager to modify this group");
77 }
78
79 @Override
80 public void removeRole(String roleName) throws UnsupportedOperationException, AccessDeniedException {
81 throw new UnsupportedOperationException("Use manager to modify this group");
82 }
83
84
85
86
87 @Override
88 public void removeGroup(String groupName) throws UnsupportedOperationException, AccessDeniedException {
89 throw new UnsupportedOperationException("Use manager to modify this group");
90 }
91
92 @Override
93 public boolean hasRole(String roleName) throws UnsupportedOperationException, AccessDeniedException {
94 return this.roles.contains(roleName);
95 }
96
97
98
99
100
101
102 @Override
103 public String getProperty(String propertyName) {
104 throw new UnsupportedOperationException("Use manager to retrieve arbitrary group properties");
105 }
106
107 @Override
108 public void setProperty(String propertyName, String value) {
109 throw new UnsupportedOperationException("Use manager to modify this group");
110 }
111
112
113
114
115
116 @Override
117 public Collection<String> getRoles() {
118 return Collections.unmodifiableCollection(this.roles);
119 }
120
121
122
123
124
125 @Override
126 public Collection<String> getGroups() {
127 return this.groups;
128 }
129
130 @Override
131 public Collection<String> getAllGroups() {
132 throw new UnsupportedOperationException("Use manager to modify this group");
133 }
134
135 @Override
136 public String getId() {
137 return id;
138 }
139 }