## org.h2.engine
Class User

    java.lang.Object
      org.h2.engine.DbObjectBase
          org.h2.engine.RightOwner
              org.h2.engine.User

All Implemented Interfaces:
  DbObject

    public class User

extends RightOwner

Represents a user object.

Field Summary

Fields inherited from class org.h2.engine.DbObjectBase
`comment, database, trace`

Fields inherited from interface org.h2.engine.DbObject
`AGGREGATE, COMMENT, CONSTANT, CONSTRAINT, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, TABLE_OR_VIEW, TRIGGER, USER, USER_DATATYPE`

Constructor Summary
`User(Database database, int id, java.lang.String userName, boolean systemUser)`

Method Summary
`void` `checkAdmin()` Check if this user has admin rights.
`void` `checkOwnsNoSchemas()` Check that this user does not own any schema.
`void` `checkRename()` Check if this object can be renamed.
`void` `checkRight(Table table, int rightMask)` Checks that this user has the given rights for this database object.
`void` `checkSchemaAdmin()` Check if this user has schema admin rights.
`java.util.ArrayList<DbObject>` `getChildren()` Get the list of dependent children (for tables, this includes indexes and so on).
`java.lang.String` `getCreateSQL()` Build a SQL statement to re-create this object.
`java.lang.String` `getCreateSQL(boolean password)` Get the CREATE SQL statement for this object.
`java.lang.String` `getCreateSQLForCopy(Table table, java.lang.String quotedName)` Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table
`java.lang.String` `getDropSQL()` Build a SQL statement to drop this object.
`int` `getType()` Get the object type.
`boolean` `hasRight(Table table, int rightMask)` See if this user has the given rights for this database object.
`boolean` `isAdmin()`
`void` `removeChildrenAndResources(Session session)` Remove all dependent objects and free all resources (files, blocks in files) of this object.
`void` `setAdmin(boolean admin)`
`void` `setSaltAndHash(byte[] salt, byte[] hash)` Set the salt and hash of the password for this user.
`void` `setUserPasswordHash(byte[] userPasswordHash)` Set the user name password hash.

Methods inherited from class org.h2.engine.RightOwner
`getRightForObject, getRightForRole, grantRight, grantRole, isRoleGranted`

Methods inherited from class org.h2.engine.DbObjectBase
`getComment, getDatabase, getId, getModificationId, getName, getSQL, initDbObjectBase, invalidate, isTemporary, rename, setComment, setModified, setObjectName, setTemporary, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### User

    public User(Database database,
                int id,
                java.lang.String userName,
                boolean systemUser)

Method Detail

### 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

### getCreateSQLForCopy

    public java.lang.String getCreateSQLForCopy(Table table,
                                                java.lang.String quotedName)

  Description copied from interface: `DbObject`
  Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table

  Parameters:
    `table` - the new table
    `quotedName` - the quoted name
  Returns:
    the SQL statement

### getCreateSQL

    public java.lang.String getCreateSQL()

  Description copied from class: `DbObjectBase`
  Build a SQL statement to re-create this object.

  Specified by:
    `getCreateSQL` in interface `DbObject`
  Specified by:
    `getCreateSQL` in class `DbObjectBase`
  Returns:
    the SQL statement

### getDropSQL

    public java.lang.String getDropSQL()

  Description copied from class: `DbObjectBase`
  Build a SQL statement to drop this object.

  Specified by:
    `getDropSQL` in interface `DbObject`
  Specified by:
    `getDropSQL` in class `DbObjectBase`
  Returns:
    the SQL statement

### checkRight

    public void checkRight(Table table,
                           int rightMask)

  Checks that this user has the given rights for this database object.

  Parameters:
    `table` - the database object
    `rightMask` - the rights required
  Throws:
    `DbException` - if this user does not have the required rights

### hasRight

    public boolean hasRight(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

### getCreateSQL

    public java.lang.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()

  Check if this user has admin rights. An exception is thrown if he does not have them.

  Throws:
    `DbException` - if this user is not an admin

### checkSchemaAdmin

    public void checkSchemaAdmin()

  Check if this user has schema admin rights. An exception is thrown if he does not have them.

  Throws:
    `DbException` - if this user is not a schema admin

### getType

    public int getType()

  Description copied from interface: `DbObject`
  Get the object type.

  Returns:
    the object type

### getChildren

    public java.util.ArrayList<DbObject> getChildren()

  Description copied from interface: `DbObject`
  Get the list of dependent children (for tables, this includes indexes and so on).

  Specified by:
    `getChildren` in interface `DbObject`
  Overrides:
    `getChildren` in class `DbObjectBase`
  Returns:
    the list of children

### removeChildrenAndResources

    public void removeChildrenAndResources(Session session)

  Description copied from class: `DbObjectBase`
  Remove all dependent objects and free all resources (files, blocks in files) of this object.

  Specified by:
    `removeChildrenAndResources` in interface `DbObject`
  Specified by:
    `removeChildrenAndResources` in class `DbObjectBase`
  Parameters:
    `session` - the session

### checkRename

    public void checkRename()

  Description copied from class: `DbObjectBase`
  Check if this object can be renamed. System objects may not be renamed.

  Specified by:
    `checkRename` in interface `DbObject`
  Specified by:
    `checkRename` in class `DbObjectBase`

### checkOwnsNoSchemas

    public void checkOwnsNoSchemas()

  Check that this user does not own any schema. An exception is thrown if he owns one or more schemas.

  Throws:
    `DbException` - if this user owns a schema