Package org.h2.engine

Class User

All Implemented Interfaces:
org.h2.util.HasSQL

public final class User extends RightOwner
Represents a user object.
  • Constructor Details

    • User

      public User(Database database, int id, String userName, boolean systemUser)
  • Method Details

    • setAdmin

      public void setAdmin(boolean admin)
    • isAdmin

      public boolean isAdmin()
    • setSaltAndHash

      public void setSaltAndHash(byte[] salt, byte[] hash)
      Set the salt and hash of the password for this user.
      Parameters:
      salt - the salt
      hash - the password hash
    • setUserPasswordHash

      public void setUserPasswordHash(byte[] userPasswordHash)
      Set the user name password hash. A random salt is generated as well. The parameter is filled with zeros after use.
      Parameters:
      userPasswordHash - the user name password hash
    • getCreateSQL

      public String getCreateSQL()
      Description copied from class: DbObject
      Construct the CREATE ... SQL statement for this object.
      Specified by:
      getCreateSQL in class DbObject
      Returns:
      the SQL statement
    • getCreateSQL

      public String getCreateSQL(boolean password)
      Get the CREATE SQL statement for this object.
      Parameters:
      password - true if the password (actually the salt and hash) should be returned
      Returns:
      the SQL statement
    • checkAdmin

      public void checkAdmin()
      Checks if this user has admin rights. An exception is thrown if user doesn't have them.
      Throws:
      org.h2.message.DbException - if this user is not an admin
    • checkSchemaAdmin

      public void checkSchemaAdmin()
      Checks if this user has schema admin rights for every schema. An exception is thrown if user doesn't have them.
      Throws:
      org.h2.message.DbException - if this user is not a schema admin
    • checkSchemaOwner

      public void checkSchemaOwner(org.h2.schema.Schema schema)
      Checks if this user has schema owner rights for the specified schema. An exception is thrown if user doesn't have them.
      Parameters:
      schema - the schema
      Throws:
      org.h2.message.DbException - if this user is not a schema owner
    • checkTableRight

      public void checkTableRight(org.h2.table.Table table, int rightMask)
      Checks that this user has the given rights for the specified table.
      Parameters:
      table - the table
      rightMask - the rights required
      Throws:
      org.h2.message.DbException - if this user does not have the required rights
    • hasTableRight

      public boolean hasTableRight(org.h2.table.Table table, int rightMask)
      See if this user has the given rights for this database object.
      Parameters:
      table - the database object, or null for schema-only check
      rightMask - the rights required
      Returns:
      true if the user has the rights
    • getType

      public int getType()
      Description copied from class: DbObject
      Get the object type.
      Specified by:
      getType in class DbObject
      Returns:
      the object type
    • getChildren

      public ArrayList<DbObject> getChildren()
      Description copied from class: DbObject
      Get the list of dependent children (for tables, this includes indexes and so on).
      Overrides:
      getChildren in class DbObject
      Returns:
      the list of children, or null
    • removeChildrenAndResources

      public void removeChildrenAndResources(SessionLocal session)
      Description copied from class: DbObject
      Delete all dependent children objects and resources of this object.
      Specified by:
      removeChildrenAndResources in class DbObject
      Parameters:
      session - the session