|
SPT Core API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sptci.jdo.JDOObject
com.sptci.jdo.User
public class User
The base class for all objects representing a user in a data store.
This is usually used to provide data store based authentication and
authorisation. Sub-classes must use an inheritance strategy 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| Field Summary | |
|---|---|
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. |
| Fields inherited from class com.sptci.jdo.JDOObject |
|---|
hash, HASH, logger, startLetter |
| Constructor Summary | |
|---|---|
User()
Default constructor. |
|
User(String userName)
Create a new instance of the bean with the specified userName. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class com.sptci.jdo.JDOObject |
|---|
clone, createXStream, fromXML, getObjectId, getPersistenceManager, getStartLetter, jdoPostLoad, jdoPreClear, jdoPreDelete, jdoPreStore, resetHash, toString, toXML |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public 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
| Constructor Detail |
|---|
public User()
public User(String userName)
userName.
userName - The userName value to use to create the new
instance| Method Detail |
|---|
public boolean equals(Object object)
ObjectId.
equals in class JDOObjectobject - The object that is to be checked for equality with
this object.
true if the specied object
is the same as this object.public int hashCode()
ObjectId.
- Overrides:
hashCode in class JDOObject
- Returns:
- int The hash code value for the object.
public int compareTo(JDOObject object)
userName value.
compareTo in interface Comparable<JDOObject>compareTo in class JDOObjectobject - That object that is to be compared with this instance.
userName.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.
|
SPT Core API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||