1 17 18 package org.apache.lenya.ac.impl; 19 20 import org.apache.lenya.ac.AccessControlException; 21 import org.apache.lenya.ac.Password; 22 import org.apache.lenya.ac.User; 23 import org.apache.log4j.Category; 24 25 29 public abstract class AbstractUser extends AbstractGroupable implements User { 30 31 private static Category log = Category.getInstance(AbstractUser.class); 32 private String email; 33 private String encryptedPassword; 34 35 38 public AbstractUser() { 39 } 40 41 49 public AbstractUser(String id, String fullName, String email, String password) { 50 setId(id); 51 setName(fullName); 52 this.email = email; 53 setPassword(password); 54 } 55 56 61 public String getEmail() { 62 return email; 63 } 64 65 71 public String getFullName() { 72 return getName(); 73 } 74 75 80 public void setEmail(String email) { 81 this.email = email; 82 } 83 84 90 public void setFullName(String name) { 91 setName(name); 92 } 93 94 98 public void setPassword(String plainTextPassword) { 99 encryptedPassword = Password.encrypt(plainTextPassword); 100 } 101 102 109 protected void setEncryptedPassword(String encryptedPassword) { 110 this.encryptedPassword = encryptedPassword; 111 } 112 113 118 protected String getEncryptedPassword() { 119 return encryptedPassword; 120 } 121 122 127 public abstract void save() throws AccessControlException; 128 129 134 public void delete() throws AccessControlException { 135 removeFromAllGroups(); 136 } 137 138 146 public boolean authenticate(String password) { 147 log.debug("Password: " + password); 148 log.debug("pw encypted: " + Password.encrypt(password)); 149 log.debug("orig encrypted pw: " + this.encryptedPassword); 150 151 return this.encryptedPassword.equals(Password.encrypt(password)); 152 } 153 154 } 155 | Popular Tags |