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 java.util.Collection;
37 import java.util.Collections;
38 import java.util.ArrayList;
39
40 import org.apache.commons.lang.StringUtils;
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
43
44
45
46
47
48
49
50
51
52
53 public class DummyUser extends AbstractUser {
54
55 private static final Logger log = LoggerFactory.getLogger(DummyUser.class);
56
57 private static final String DEFAULT_LANGUAGE = "en";
58
59 DummyUser() {
60 log.info("Initializing dummy user - Anonymous");
61 log.info("This area and/or instance is not secured");
62 }
63
64
65
66
67 public boolean hasRole(String roleName) {
68 return true;
69 }
70
71
72
73
74 public void removeRole(String roleName) throws UnsupportedOperationException {
75 log.debug("User [ Anonymous ] has no roles");
76 }
77
78
79
80
81
82 public void addRole(String roleName) throws UnsupportedOperationException {
83 log.debug("No roles can be attached to user [ Anonymous ]");
84 }
85
86
87
88
89 public boolean inGroup(String groupName) {
90 return true;
91 }
92
93 public void removeGroup(String groupName) throws UnsupportedOperationException {
94 log.debug("User [ Anonymous ] has no groups");
95 }
96
97 public void addGroup(String groupName) throws UnsupportedOperationException {
98 log.debug("No groups can be attached to user [ Anonymous ]");
99 }
100
101 public boolean isEnabled() {
102 return true;
103 }
104
105 public void setEnabled(boolean enabled) {
106 }
107
108 public String getLanguage() {
109 return DEFAULT_LANGUAGE;
110 }
111
112 public String getName() {
113 return UserManager.ANONYMOUS_USER;
114 }
115
116 public String getPassword() {
117 return StringUtils.EMPTY;
118 }
119
120 public String getProperty(String propertyName) {
121 return null;
122 }
123
124 public void setProperty(String propertyName, String value) {
125 log.debug("Can not set properties on dummy user (name: {}, value: {})", propertyName, value);
126 }
127
128 public Collection<String> getGroups() {
129 return Collections.emptyList();
130 }
131
132 public Collection<String> getAllGroups() {
133 return new ArrayList<String>();
134 }
135
136 public Collection<String> getRoles() {
137 return Collections.emptyList();
138 }
139
140 public Collection<String> getAllRoles() {
141 return new ArrayList<String>();
142 }
143 }