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