Class UserRecord

java.lang.Object
uk.ac.manchester.spinnaker.alloc.model.UserRecord

public final class UserRecord
extends Object
The description and model of a user. POJO class. Some things are stated to be not settable despite having setters; they're settable in instances of this class but the service itself will not respect being asked to change them.
  • Constructor Details

    • UserRecord

      public UserRecord()
      Create an empty instance.
    • UserRecord

      public UserRecord​(Row row)
      Inflate the result of a SQLQueries.GET_USER_DETAILS query (or anything else that includes the same columns) into an object. Doesn't include inflating the groups that the user is a member of.
      Parameters:
      row - The row with the result.
  • Method Details

    • getUserId

      @Null public @Null Integer getUserId()
      Returns:
      The user identifier. Read-only; cannot be set by the service.
    • setUserId

      public void setUserId​(Integer userId)
      Parameters:
      userId - The user identifier. Read-only within the administration interface; cannot be set by the service.
    • getUserName

      @NotBlank public @NotBlank String getUserName()
      Returns:
      The user's username.
    • setUserName

      public void setUserName​(String userName)
      Parameters:
      userName - The user's username.
    • getPassword

      public String getPassword()
      Returns:
      The user's unencrypted password. Never returned by the service, but may be written.
    • setPassword

      public void setPassword​(String password)
      Parameters:
      password - The user's unencrypted password. Never returned by the service, but may be written.
    • getHasPassword

      public Boolean getHasPassword()
      Returns:
      Whether the user has a password set. If they don't, they'll have to log in by other mechanisms (e.g., HBP/EBRAINS OpenID Connect).
    • setHasPassword

      public void setHasPassword​(Boolean hasPassword)
      Parameters:
      hasPassword - Whether the user has a password set. If they don't, they'll have to log in by other mechanisms (e.g., HBP/EBRAINS OpenID Connect).
    • getEnabled

      public Boolean getEnabled()
      Returns:
      Whether this account is enabled. Disabled accounts cannot log into the service until explicitly enabled.
    • setEnabled

      public void setEnabled​(Boolean enabled)
      Parameters:
      enabled - Whether this account is enabled. Disabled accounts cannot log into the service until explicitly enabled.
    • getLocked

      public Boolean getLocked()
      Returns:
      Whether this account is temporarily locked. Locked accounts should unlock automatically after 24 hours. Can be explicitly set to false to force an unlock.
    • setLocked

      public void setLocked​(Boolean locked)
      Parameters:
      locked - Whether this account is temporarily locked. Locked accounts should unlock automatically after 24 hours. Can be explicitly set to false to force an unlock.
    • getTrustLevel

      @NotNull(message="a trust level must be given") public @NotNull(message="a trust level must be given") TrustLevel getTrustLevel()
      Returns:
      The permissions of the account.
    • setTrustLevel

      public void setTrustLevel​(TrustLevel trustLevel)
      Parameters:
      trustLevel - The permissions of the account.
    • getLastSuccessfulLogin

      @Null public @Null Instant getLastSuccessfulLogin()
      Returns:
      The time that the last successful login was. Read-only; cannot be set via the admin API.
    • getLastFailedLogin

      @Null public @Null Instant getLastFailedLogin()
      Returns:
      The time that the last failed login was. Read-only; cannot be set via the admin API.
    • getGroups

      public Map<String,​URI> getGroups()
      Note that no API that sets a user's information using a UserRecord allows setting the groups that user is a member of at the same time.
      Returns:
      The groups that the user is a member of. May be null if this information is not being reported.
    • setGroups

      public void setGroups​(Map<String,​URI> groups)
      Parameters:
      groups - The groups that the user is a member of.
    • getOpenIdSubject

      public String getOpenIdSubject()
      Returns:
      The OpenID subject that this user relates to, if known.
    • setOpenIdSubject

      public void setOpenIdSubject​(String subject)
      Parameters:
      subject - The OpenID subject that this user relates to.
    • isInternal

      public boolean isInternal()
      Returns:
      Whether this is an internal user.
    • setInternal

      public void setInternal​(boolean internal)
      Parameters:
      internal - Whether this is an internal user.
    • isExternallyAuthenticated

      public boolean isExternallyAuthenticated()
      Returns:
      Whether this represents a request to use external authentication (instead of just not setting the password).
    • sanitise

      @CanIgnoreReturnValue public UserRecord sanitise()
      Forces correct shrouding of information.
      Returns:
      the object (for convenience)
    • initCreationDefaults

      public void initCreationDefaults()
      Set up some defaults used when a user is being created.