beginJsp2.0外文书籍源代码

源代码在线查看: user4.java

软件大小: 228 K
上传用户: GUAIGUAICHENGTI
关键词: beginJsp 2.0 书籍 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				package com.wrox.except;
				
				import org.apache.log4j.Logger;
				import org.apache.log4j.PropertyConfigurator;
				
				public class User4
				{
				  static Logger logger = Logger.getLogger("com.wrox.except.User");
				  private String username;
				  private String password;
				
				  static
				  {
				    PropertyConfigurator.configure("C:\\java\\tomcat50\\webapps"
				                         + "\\Exceptions\\WEB-INF\\config.properties");
				  }
				
				  public User4()
				  {
				  }
				
				  public void setUsername(String username)
				  {
				    logger.debug("Username set: " + username);
				    this.username = username;
				  }
				
				  public String getUsername()
				  {
				    return this.username;
				  }
				
				  public void setPassword(String password)
				  {
				    this.password = password;
				  }
				
				  public void validate() throws UserException, Exception
				  {
				    if(this.username == null)
				    {
				      throw new UserException("UserName must be supplied !!");
				    }
				    if(this.password == null)
				    {
				      logger.error("Password is null for " + username);
				      throw new UserException("Password must be supplied !!",
				                              this.username);
				    }    
				    if (!(this.username.equals("Dougal")
				       && this.password.equals("roundabout")))
				    {
				      Exception trouble = new Exception("Couldn't validate your"
				                                      + " password!");
				      throw trouble;
				    }
				  logger.info("Validation successful for: " + this.username);
				  }
				}
							

相关资源