public class User extends JDOObject
InheritanceStrategy.SUPERCLASS_TABLE since this
class maintains a Discriminator.
Note: Password values are stored encrypted in the data
store. By default passwords are encrypted using the password
itself as the key. This behaviour can be changed to use a standard
key by setting a system property with name PROPERTY_NAME to
false. You can always explicitly specify the key to use to
encrypt the password by using setPassword( String, String ) method
instead of setPassword( String ).
The following shows sample use of this class:
import com.sptci.jdo.User;
import com.sptci.jdo.UserFactory;
...
User u1 = new User( "joeuser" );
u1.setPassword( "mysecretkey", "mypassword" );
...
String password = u1.getPassword( "mysecretkey" );
User u2 = new User( "anotherone" );
u2.setPassword( "securepassword" );
...
u2.getPassword( "securepassword" );
© Copyright 2006 Sans Pareil Technologies, Inc.
,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected Collection<Group> |
groups
The collection of groups to which the user belongs.
|
protected byte[] |
password
The password for the user.
|
static String |
PROPERTY_NAME
The system property used to indicate whether to use secure password
or less secure password.
|
static boolean |
USE_SECURE_PASSWORD
A flag used to track whether we are using secure passwords or not.
|
protected String |
userName
The user name used as part of the login credential pair.
|
hash, HASH, logger, startLetter| Constructor and Description |
|---|
User()
Default constructor.
|
User(String userName)
Create a new instance of the bean with the specified
userName. |
| Modifier and Type | Method and Description |
|---|---|
void |
addGroup(Group group)
Add this user as a member of the specified group.
|
int |
compareTo(JDOObject object)
Compare the specified object with this instance.
|
boolean |
equals(Object object)
Check to see if the specified object is equivalent to this object.
|
Collection<Group> |
getGroups()
Returns
groups. |
String |
getPassword()
Deprecated.
Use
getPassword( String ) for proper results.
This method still has to be used if used in non-secure mode. |
String |
getPassword(String key)
Returns
password. |
String |
getUserName()
Returns
userName. |
int |
hashCode()
Return a hash code for this object.
|
void |
removeGroup(Group group)
Remove this user from being a member of the specified group.
|
void |
setGroups(Collection<Group> groups)
Update the
groups with the objects specified in the
collection. |
void |
setPassword(String password)
Set
password. |
void |
setPassword(String key,
String password)
Set
password. |
void |
setUserName(String userName)
Set
userName. |
clone, createXStream, fromXML, getObjectId, getPersistenceManager, getStartLetter, jdoPostLoad, jdoPreClear, jdoPreDelete, jdoPreStore, resetHash, toString, toXMLpublic static final String PROPERTY_NAME
PASSWORD_KEY as the key.public static final boolean USE_SECURE_PASSWORD
Note: Changing this with an existing data store will lead to passwords not being properly decrypted. This property should be set for the lifetime of a data store.
protected String userName
protected transient byte[] password
protected Collection<Group> groups
public boolean equals(Object object)
ObjectId.public int hashCode()
public int compareTo(JDOObject object)
userName value.public final String getUserName()
userName.public final void setUserName(String userName)
userName.userName - The value to set.IllegalArgumentException - If the userName value specified is
null or empty.@Deprecated public final String getPassword()
getPassword( String ) for proper results.
This method still has to be used if used in non-secure mode.password. This method works only if the class
is configured to use non-secure passwords.public final String getPassword(String key)
password.key - The secret key used to encrypt the password. The original
password value itself is used to encrypt the password. Hence the
key specified must be the same as the users password.null
if the specified key cannot be used to decrypt the password.Encrypt.decrypt(java.lang.String, byte[])public final void setPassword(String password) throws javax.jdo.JDOFatalUserException
password.password - The value to set.javax.jdo.JDOFatalUserException - If exceptions are raised when
encrypting the password.setPassword( String, String )public final void setPassword(String key, String password) throws javax.jdo.JDOFatalUserException
password.key - The key to use to encrypt the password.password - The value to set.javax.jdo.JDOFatalUserException - If NoSuchAlgorithmException, InvalidKeyException, or IllegalBlockSizeException exceptions are raised when
encrypting the password.Encrypt.encrypt(java.lang.String, java.lang.String)public Collection<Group> getGroups()
groups.public void setGroups(Collection<Group> groups)
groups with the objects specified in the
collection.groups - The new collection of values to set.public void addGroup(Group group)
group - The group to which this user is being added.public void removeGroup(Group group)
group - The group from which membership is being removed.