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

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addRole​(Role r)` |
    `static String` | `buildCodeId​(String prefix, Date now)` | Creates a more or less unique ID that can be used as a "secret ID" for a User object
    `void` | `encryptAndSetPassword​(String clearPassword)` | Encrypts the passed password, and stores the encrypted value.
    `static User` | `findByName​(javax.persistence.EntityManager em, String nickname)` | Can be used instead of (User)em.find(User.class, un);
    `Date` | `getDate()` |
    `String` | `getDigest()` | Encrypted password (or, more precisely, the MD5 digest of the password).
    `String` | `getEmail()` |
    `long` | `getId()` |
    `String` | `getIdCode()` |
    `String` | `getNickname()` |
    `Set<Role>` | `getRoles()` |
    `boolean` | `hasAnyRole​(Role.Name[] names)` | Does this user have any of the roles in the specifed list?
    `boolean` | `hasRole​(Role.Name name)` |
    `boolean` | `isMlc()` | Does this user have the "researcher" role?
    `String` | `listRoles()` |
    `boolean` | `passwordMatches​(String clearPassword)` |
    `void` | `removeRole​(Role r)` |
    `void` | `setDate​(Date _date)` |
    `void` | `setDigest​(String x)` |
    `void` | `setEmail​(String _email)` |
    `void` | `setId​(long _id)` |
    `void` | `setIdCode​(String _idCode)` |
    `void` | `setNickname​(String _nickname)` |
    `String` | `toString()` |

    - ### Methods inherited from class edu.wisc.game.reflect.OurTable

      `fetchVecs, getLongId, ignores, reflectToString, validate`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### User

          public User()

  - ### Method Detail

    - #### getId

          public long getId()

    - #### setId

          public void setId​(long _id)

    - #### getNickname

          public String getNickname()

    - #### setNickname

          public void setNickname​(String _nickname)

    - #### getEmail

          public String getEmail()

    - #### setEmail

          public void setEmail​(String _email)

    - #### getIdCode

          public String getIdCode()

    - #### setIdCode

          public void setIdCode​(String _idCode)

    - #### getDate

          public Date getDate()

    - #### setDate

          public void setDate​(Date _date)

    - #### getDigest

          public String 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

          public void setDigest​(String x)

    - #### encryptAndSetPassword

          public void encryptAndSetPassword​(String clearPassword)

      Encrypts the passed password, and stores the encrypted value. This enables the user for logging in

    - #### passwordMatches

          public boolean passwordMatches​(String clearPassword)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### findByName

          public static User findByName​(javax.persistence.EntityManager em,
                                        String nickname)

      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

          public Set<Role> getRoles()

    - #### addRole

          public void addRole​(Role r)

    - #### removeRole

          public void removeRole​(Role r)

    - #### hasRole

          public boolean hasRole​(Role.Name name)

    - #### hasAnyRole

          public boolean hasAnyRole​(Role.Name[] names)

      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

          public String listRoles()

    - #### buildCodeId

          public static String buildCodeId​(String prefix,
                                           Date now)

      Creates a more or less unique ID that can be used as a "secret ID" for a User object