Package edu.wisc.game.sql
Class User
java.lang.Object
edu.wisc.game.reflect.OurTable
edu.wisc.game.sql.User
@Entity public class User extends OurTable
Information about a repeat user (who may own multiple playerId) stored in the SQL database.
-
Constructor Summary
Constructors Constructor Description User() -
Method Summary
Modifier and Type Method Description voidaddRole(Role r)static StringbuildCodeId(String prefix, Date now)Creates a more or less unique ID that can be used as a "secret ID" for a User objectvoidencryptAndSetPassword(String clearPassword)Encrypts the passed password, and stores the encrypted value.static UserfindByName(javax.persistence.EntityManager em, String nickname)Can be used instead of (User)em.find(User.class, un);DategetDate()StringgetDigest()Encrypted password (or, more precisely, the MD5 digest of the password).StringgetEmail()longgetId()StringgetIdCode()StringgetNickname()Set<Role>getRoles()booleanhasAnyRole(Role.Name[] names)Does this user have any of the roles in the specifed list?booleanhasRole(Role.Name name)booleanisMlc()Does this user have the "researcher" role?StringlistRoles()booleanpasswordMatches(String clearPassword)voidremoveRole(Role r)voidsetDate(Date _date)voidsetDigest(String x)voidsetEmail(String _email)voidsetId(long _id)voidsetIdCode(String _idCode)voidsetNickname(String _nickname)StringtoString()
-
Constructor Details
-
User
public User()
-
-
Method Details
-
getId
public long getId() -
setId
public void setId(long _id) -
getNickname
-
setNickname
-
getEmail
-
setEmail
-
getIdCode
-
setIdCode
-
getDate
-
setDate
-
getDigest
Encrypted password (or, more precisely, the MD5 digest of the password). If an empty string is stored here, AND the user has roles that require a password, it means that the entry is disabled, because the digest of any string is a non-empty string. -
setDigest
-
encryptAndSetPassword
Encrypts the passed password, and stores the encrypted value. This enables the user for logging in -
passwordMatches
-
toString
-
findByName
Can be used instead of (User)em.find(User.class, un);- Returns:
- The User object with the matching name, or null if none is found
-
getRoles
-
addRole
-
removeRole
-
hasRole
-
hasAnyRole
Does this user have any of the roles in the specifed list?- Parameters:
names- An array of roles. It must be non-null, but may be empty (in which case, of course, false will be returned).- Returns:
- True if the user has any of the listed roles.
-
isMlc
public boolean isMlc()Does this user have the "researcher" role? -
listRoles
-
buildCodeId
Creates a more or less unique ID that can be used as a "secret ID" for a User object
-