X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=security%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fusermgt%2FUser.java;h=41cf83282a054a8bfb860a06411e8debf509f93f;hb=8de36ff0206c996baf3ee4adc3e2293b12ff5f39;hp=53e95537943ef576934d7a3ebb81d88f9ebd8a7e;hpb=89c06d4d52b46c154128c97d6e758fa1f4fc7a6e;p=utils diff --git a/security/src/main/java/org/wamblee/usermgt/User.java b/security/src/main/java/org/wamblee/usermgt/User.java index 53e95537..41cf8328 100644 --- a/security/src/main/java/org/wamblee/usermgt/User.java +++ b/security/src/main/java/org/wamblee/usermgt/User.java @@ -26,10 +26,9 @@ import java.io.Serializable; import java.util.Set; import java.util.TreeSet; - /** * Represents a user. The methods for managing the groups of the user have - * package scope. Managing the groups of the user should be done through the + * package scope. Managing the groups of the user should be done through the * {@link org.wamblee.usermgt.UserAdministration} interface. */ public class User extends AbstractPersistent implements Serializable, @@ -59,11 +58,15 @@ public class User extends AbstractPersistent implements Serializable, */ private MessageDigester passwordEncoder; -/** - * Constructs the user. - * @param aName User name. - * @param aPassword Password. - * @param aGroup Group the user belongs to. + /** + * Constructs the user. + * + * @param aName + * User name. + * @param aPassword + * Password. + * @param aGroup + * Group the user belongs to. */ User(String aName, String aPassword, Group aGroup, NameValidator aPasswordValidator, MessageDigester aPasswordEncoder) @@ -71,48 +74,48 @@ public class User extends AbstractPersistent implements Serializable, super(); name = aName; aPasswordValidator.validate(aPassword); - password = aPasswordEncoder.hash(aPassword); - groups = new TreeSet(); + password = aPasswordEncoder.hash(aPassword); + groups = new TreeSet(); groups.add(aGroup); - passwordValidator = aPasswordValidator; - passwordEncoder = aPasswordEncoder; + passwordValidator = aPasswordValidator; + passwordEncoder = aPasswordEncoder; } -/** + /** * Creates a new User object. - * - * @param aUser DOCUMENT ME! + * */ public User(User aUser) { super(aUser); - name = aUser.name; - password = aUser.password; - groups = new TreeSet(); + name = aUser.name; + password = aUser.password; + groups = new TreeSet(); for (Group group : aUser.groups) { groups.add(new Group(group)); } - passwordValidator = aUser.passwordValidator; - passwordEncoder = aUser.passwordEncoder; + passwordValidator = aUser.passwordValidator; + passwordEncoder = aUser.passwordEncoder; } -/** + /** * Creates a new User object. */ User() { super(); - name = null; - password = null; - groups = null; - passwordValidator = null; - passwordEncoder = null; + name = null; + password = null; + groups = null; + passwordValidator = null; + passwordEncoder = null; } /** * Sets the password validator. - * - * @param aPasswordValidator Validator. + * + * @param aPasswordValidator + * Validator. */ public void setPasswordValidator(NameValidator aPasswordValidator) { passwordValidator = aPasswordValidator; @@ -120,16 +123,16 @@ public class User extends AbstractPersistent implements Serializable, /** * Sets the password encoder. - * - * @param aPasswordEncoder Encoder. + * + * @param aPasswordEncoder + * Encoder. */ public void setPasswordEncoder(MessageDigester aPasswordEncoder) { passwordEncoder = aPasswordEncoder; } /** - * DOCUMENT ME! - * + * * @return Returns the password. */ String getPassword() { @@ -138,10 +141,12 @@ public class User extends AbstractPersistent implements Serializable, /** * Checks the password. - * - * @param aPassword Password to check. - * - * @throws UserMgtException In case the password is incorrect. + * + * @param aPassword + * Password to check. + * + * @throws UserMgtException + * In case the password is incorrect. */ public void checkPassword(String aPassword) throws UserMgtException { String encoded = passwordEncoder.hash(aPassword); @@ -153,11 +158,14 @@ public class User extends AbstractPersistent implements Serializable, /** * Changes the password. - * - * @param aOldPassword Old password. - * @param aNewPassword New password. - * - * @throws UserMgtException In case the old password is incorrect. + * + * @param aOldPassword + * Old password. + * @param aNewPassword + * New password. + * + * @throws UserMgtException + * In case the old password is incorrect. */ public void changePassword(String aOldPassword, String aNewPassword) throws UserMgtException { @@ -167,11 +175,10 @@ public class User extends AbstractPersistent implements Serializable, } /** - * DOCUMENT ME! - * - * @param aPassword The password to set. - * - * @throws UserMgtException DOCUMENT ME! + * + * @param aPassword + * The password to set. + * */ public void setPassword(String aPassword) throws UserMgtException { passwordValidator.validate(aPassword); @@ -180,7 +187,7 @@ public class User extends AbstractPersistent implements Serializable, /** * For OR mapping. - * + * * @return Password. */ protected String getPasswordString() { @@ -189,16 +196,16 @@ public class User extends AbstractPersistent implements Serializable, /** * For OR mapping. - * - * @param aPassword Password. + * + * @param aPassword + * Password. */ protected void setPasswordString(String aPassword) { password = aPassword; } /** - * DOCUMENT ME! - * + * * @return Returns the _user. */ public String getName() { @@ -206,9 +213,9 @@ public class User extends AbstractPersistent implements Serializable, } /** - * DOCUMENT ME! - * - * @param aName The username to set. + * + * @param aName + * The username to set. */ void setName(String aName) { name = aName; @@ -216,7 +223,7 @@ public class User extends AbstractPersistent implements Serializable, /** * Gets the groups the user belongs to. - * + * * @return Groups. */ public Set getGroups() { @@ -228,9 +235,10 @@ public class User extends AbstractPersistent implements Serializable, /** * Checks whether the user belongs to the given group. - * - * @param aGroup Group. - * + * + * @param aGroup + * Group. + * * @return True if the user belongs to the group. */ public boolean isInGroup(Group aGroup) { @@ -239,9 +247,10 @@ public class User extends AbstractPersistent implements Serializable, /** * Checks whether the user belongs to the given group. - * - * @param aGroup Group. - * + * + * @param aGroup + * Group. + * * @return True if the user belongs to the group. */ public boolean isInGroup(String aGroup) { @@ -249,18 +258,9 @@ public class User extends AbstractPersistent implements Serializable, } /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ -/** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ -/** - * Gets the group set. For OR mapping. - * @return set of groups. + * Gets the group set. For OR mapping. + * + * @return set of groups. */ Set getGroupSet() { return groups; @@ -268,8 +268,9 @@ public class User extends AbstractPersistent implements Serializable, /** * Sets the groups the user belongs to, for OR mapping. - * - * @param aGroups Groups. + * + * @param aGroups + * Groups. */ void setGroupSet(Set aGroups) { groups = aGroups; @@ -277,10 +278,12 @@ public class User extends AbstractPersistent implements Serializable, /** * Adds the user to a group. - * - * @param aGroup Group to add the user to. - * - * @throws UserMgtException In case the user already belongs to the group. + * + * @param aGroup + * Group to add the user to. + * + * @throws UserMgtException + * In case the user already belongs to the group. */ void addGroup(Group aGroup) throws UserMgtException { if (groups.contains(aGroup)) { @@ -292,10 +295,12 @@ public class User extends AbstractPersistent implements Serializable, /** * Removes the user from a group. - * - * @param aGroup Group. - * - * @throws UserMgtException In case the user does not belong to the group. + * + * @param aGroup + * Group. + * + * @throws UserMgtException + * In case the user does not belong to the group. */ void removeGroup(Group aGroup) throws UserMgtException { if (!groups.contains(aGroup)) { @@ -310,16 +315,11 @@ public class User extends AbstractPersistent implements Serializable, groups.remove(aGroup); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#equals(java.lang.Object) */ - /** - * DOCUMENT ME! - * - * @param aUser DOCUMENT ME! - * - * @return DOCUMENT ME! - */ @Override public boolean equals(Object aUser) { if (!(aUser instanceof User)) { @@ -331,27 +331,21 @@ public class User extends AbstractPersistent implements Serializable, return name.equals(user.name); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ @Override public int hashCode() { return name.hashCode(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ @Override public String toString() { String result = "User(name=" + name + ", password=" + password; @@ -363,16 +357,11 @@ public class User extends AbstractPersistent implements Serializable, return result + ")"; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Comparable#compareTo(T) */ - /** - * DOCUMENT ME! - * - * @param aUser DOCUMENT ME! - * - * @return DOCUMENT ME! - */ public int compareTo(Object aUser) { return name.compareTo(((User) aUser).name); }