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
47 public class MgnlGroup implements Group {
48 private static final Logger log = LoggerFactory.getLogger(MgnlGroup.class);
49
50 private final String name;
51 private final Collection<String> groups;
52 private final Collection<String> roles;
53 private final String id;
54
55 public MgnlGroup(String id, String groupName, Collection<String> subgroupNames, Collection<String> roleNames) {
56 this.id = id;
57 this.name = groupName;
58 this.groups = Collections.unmodifiableCollection(subgroupNames);
59 this.roles = Collections.unmodifiableCollection(roleNames);
60 }
61
62 @Override
63 public String getName() {
64 return this.name;
65 }
66
67 @Override
68 public void addRole(String roleName) throws UnsupportedOperationException, AccessDeniedException {
69 throw new UnsupportedOperationException("Use manager to modify this group");
70 }
71
72
73
74
75 @Override
76 public void addGroup(String groupName) throws UnsupportedOperationException, AccessDeniedException {
77 throw new UnsupportedOperationException("Use manager to modify this group");
78 }
79
80 @Override
81 public void removeRole(String roleName) throws UnsupportedOperationException, AccessDeniedException {
82 throw new UnsupportedOperationException("Use manager to modify this group");
83 }
84
85
86
87
88 @Override
89 public void removeGroup(String groupName) throws UnsupportedOperationException, AccessDeniedException {
90 throw new UnsupportedOperationException("Use manager to modify this group");
91 }
92
93 @Override
94 public boolean hasRole(String roleName) throws UnsupportedOperationException, AccessDeniedException {
95 return this.roles.contains(roleName);
96 }
97
98
99
100
101
102
103 @Override
104 public String getProperty(String propertyName) {
105 throw new UnsupportedOperationException("Use manager to retrieve arbitrary group properties");
106 }
107
108 @Override
109 public void setProperty(String propertyName, String value) {
110 throw new UnsupportedOperationException("Use manager to modify this group");
111 }
112
113
114
115
116
117 @Override
118 public Collection<String> getRoles() {
119 return Collections.unmodifiableCollection(this.roles);
120 }
121
122
123
124
125
126 @Override
127 public Collection<String> getGroups() {
128 return this.groups;
129 }
130
131 @Override
132 public Collection<String> getAllGroups() {
133 throw new UnsupportedOperationException("Use manager to modify this group");
134 }
135
136 @Override
137 public String getId() {
138 return id;
139 }
140 }