1 13 package info.magnolia.cms.security; 14 15 import info.magnolia.cms.beans.config.ContentRepository; 16 import info.magnolia.cms.core.HierarchyManager; 17 18 import java.util.Collection ; 19 20 import javax.security.auth.Subject ; 21 22 import org.slf4j.Logger; 23 import org.slf4j.LoggerFactory; 24 25 26 31 public class ExternalUserManager implements UserManager { 32 33 36 public static Logger log = LoggerFactory.getLogger(MgnlUserManager.class); 37 38 public User getUser(String name) throws UnsupportedOperationException { 39 throw new UnsupportedOperationException ("not implemented yet"); 40 } 41 42 public Collection getAllUsers() throws UnsupportedOperationException { 43 throw new UnsupportedOperationException ("not implemented yet"); 44 } 45 46 public User createUser(String name, String pw) throws UnsupportedOperationException { 47 throw new UnsupportedOperationException ("not implemented yet"); 48 } 49 50 55 public User getUser(Subject subject) throws UnsupportedOperationException { 56 return new ExternalUser(subject); 57 } 58 59 63 public User getSystemUser() { 64 try { 65 return new MgnlUser(getHierarchyManager().getContent(UserManager.SYSTEM_USER)); 66 } 67 catch (Exception e) { 68 log.error("can't find System user", e); 69 log.info("Try to create new system user with default password"); 70 return this.createUser(UserManager.SYSTEM_USER, UserManager.SYSTEM_PSWD); 71 } 72 } 73 74 78 public User getAnonymousUser() { 79 try { 80 return new MgnlUser(getHierarchyManager().getContent(UserManager.ANONYMOUS_USER)); 81 } 82 catch (Exception e) { 83 log.error("can't find Anonymous user", e); 84 log.info("Try to create new system user with default password"); 85 return this.createUser(UserManager.ANONYMOUS_USER, ""); 86 } 87 } 88 89 92 protected HierarchyManager getHierarchyManager() { 93 return ContentRepository.getHierarchyManager(ContentRepository.USERS); 94 } 95 96 } 97 | Popular Tags |