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 PasswordLogin extends ContextLoginModule { 27 private static Logger log = Logging.getLoggerInstance(PasswordLogin.class); 28 29 public ContextUserContext login(Map userLoginInfo, Object [] userParameters) throws org.mmbase.security.SecurityException { 30 31 String userName = (String )userLoginInfo.get("username"); 33 if(userName == null) throw new org.mmbase.security.SecurityException("expected the property 'username' with login"); 34 35 String password = (String )userLoginInfo.get("password"); 37 if(password == null) throw new org.mmbase.security.SecurityException("expected the property 'password' with login"); 38 39 log.debug("request for user: '"+userName+"' with pass: '"+password+"'"); 40 41 org.w3c.dom.Element node = getAccount(userName); 42 if(node == null) { 43 log.info("user with name:" + userName + " doesnt have a value for this module"); 44 return null; 45 } 46 org.w3c.dom.Element identify = (org.w3c.dom.Element ) node.getElementsByTagName("identify").item(0); 47 String configPassword = org.mmbase.util.xml.DocumentReader.getNodeTextValue(identify); 48 if(!configPassword.equals(password)) { 49 log.debug("user with name:" + userName + " used pass:" + password + " but needed :" + configPassword); 50 log.info("user with name:" + userName + " didnt give the right password"); 51 return null; 52 } 53 54 Rank rank= getRank(userName); 55 if(rank == null) { 56 log.warn( "expected a rank for user with the name:" + userName + ", canceling a valid login due to the fact that the rank attribute wasnt set"); 57 return null; 58 59 } 60 return getValidUserContext(userName, rank); 61 } 62 } 63 | Popular Tags |