1 10 package org.mmbase.security.implementation.context; 11 12 import org.mmbase.security.Rank; 13 import java.util.Map ; 14 15 import org.mmbase.util.logging.Logger; 16 import org.mmbase.util.logging.Logging; 17 18 25 26 public class ClassLogin extends ContextLoginModule { 27 private static final Logger log = Logging.getLoggerInstance(ClassLogin.class); 28 29 public ContextUserContext login(Map userLoginInfo, Object [] userParameters) throws org.mmbase.security.SecurityException { 30 31 org.mmbase.security.classsecurity.ClassAuthentication.Login li = org.mmbase.security.classsecurity.ClassAuthentication.classCheck("class"); 32 if (li == null) { 33 throw new SecurityException ("Class authentication failed '" + userLoginInfo + "' (class not authorized)"); 34 } 35 String userName = (String ) li.getMap().get("username"); 37 String reqRank = (String ) li.getMap().get("rank"); 38 if(userName == null && reqRank == null) throw new org.mmbase.security.SecurityException("expected the property 'username' and/or 'rank' with login"); 39 40 if ("anonymous".equals(reqRank) && userName == null) { 41 return getValidUserContext("anonymous", Rank.ANONYMOUS); 42 } 43 44 org.w3c.dom.Element node = getAccount(userName, null, reqRank); 45 if(node == null) { 46 log.info("No user with name '" + userName + "' and rank '" + reqRank + "'"); 47 return null; 48 } 49 userName = node.getAttribute("name"); 50 51 Rank rank= getRank(userName, null); 52 if(rank == null) { 53 log.warn( "expected a rank for user with name '" + userName + "', canceling a valid login due to the fact that the rank attribute was not set"); 54 return null; 55 56 } 57 return getValidUserContext(userName, rank); 58 } 59 } 60 | Popular Tags |