1 package info.magnolia.cms.security; 2 3 import java.util.Collection ; 4 import java.util.Collections ; 5 6 import org.apache.commons.lang.StringUtils; 7 import org.slf4j.Logger; 8 import org.slf4j.LoggerFactory; 9 10 11 16 public class DummyUser implements User { 17 18 21 private static Logger log = LoggerFactory.getLogger(DummyUser.class); 22 23 26 private static final String DEFAULT_LANGUAGE = "en"; 27 28 31 DummyUser() { 32 log.info("Initializing dummy user - Anonymous"); 33 log.info("This area and/or instance is not secured"); 34 } 35 36 41 public boolean hasRole(String roleName) { 42 return true; 43 } 44 45 49 public void removeRole(String roleName) throws UnsupportedOperationException { 50 log.debug("User [ Anonymous ] has no roles"); 51 } 52 53 57 public void addRole(String roleName) throws UnsupportedOperationException { 58 log.debug("No roles can be attached to user [ Anonymous ]"); 59 } 60 61 66 public boolean inGroup(String groupName) { 67 return true; 68 } 69 70 74 public void removeGroup(String groupName) throws UnsupportedOperationException { 75 log.debug("User [ Anonymous ] has no groups"); 76 } 77 78 82 public void addGroup(String groupName) throws UnsupportedOperationException { 83 log.debug("No groups can be attached to user [ Anonymous ]"); 84 } 85 86 90 91 public String getLanguage() { 92 return DEFAULT_LANGUAGE; 93 } 94 95 99 public String getName() { 100 return UserManager.ANONYMOUS_USER; 101 } 102 103 public String getPassword() { 104 return StringUtils.EMPTY; 105 } 106 107 110 public Collection getGroups() { 111 return Collections.EMPTY_LIST; 112 } 113 114 117 public Collection getRoles() { 118 return Collections.EMPTY_LIST; 119 } 120 } 121 | Popular Tags |