Top Description Fields Constructors Methods
org.h2.engine

public final Class User

extends RightOwner
Class Inheritance
Imports
java.util.ArrayList, .Arrays, org.h2.api.ErrorCode, org.h2.message.DbException, .Trace, org.h2.schema.Schema, org.h2.security.SHA256, org.h2.table.DualTable, .MetaTable, .RangeTable, .Table, .TableType, org.h2.util.MathUtils, .StringUtils, .Utils

Represents a user object.

Field Summary

Modifier and TypeField and Description
private boolean
private byte[]
private byte[]
private final boolean

Constructor Summary

AccessConstructor and Description
public
User(Database database, int id, String userName, boolean systemUser)

Method Summary

Modifier and TypeMethod and Description
public void
checkAdmin()

Checks if this user has admin rights.

public void
checkSchemaAdmin()

Checks if this user has schema admin rights for every schema.

public void
checkSchemaOwner(Schema
the schema
schema
)

Checks if this user has schema owner rights for the specified schema.

public void
checkTableRight(Table
the table
table
,
int
the rights required
rightMask
)

Checks that this user has the given rights for the specified table.

public ArrayList<DbObject>
getChildren()

Overrides org.h2.engine.DbObject.getChildren.

Get the list of dependent children (for tables, this includes indexes and so on).

public String
getCreateSQL()

Implements abstract org.h2.engine.DbObject.getCreateSQL.

Construct the CREATE ...

public String

Returns:

the SQL statement
getCreateSQL
(boolean
true if the password (actually the salt and hash) should be returned
password
)

Get the CREATE SQL statement for this object.

public int
getType()

Implements abstract org.h2.engine.DbObject.getType.

Get the object type.

private boolean

Returns:

true if the user has the rights
hasSchemaRight
(Schema
the schema
schema
)

See if this user has owner rights for the specified schema

public boolean

Returns:

true if the user has the rights
hasTableRight
(Table
the database object, or null for schema-only check
table
,
int
the rights required
rightMask
)

See if this user has the given rights for this database object.

public boolean
public void
removeChildrenAndResources(SessionLocal
the session
session
)

Implements abstract org.h2.engine.DbObject.removeChildrenAndResources.

Delete all dependent children objects and resources of this object.

public void
setAdmin(boolean admin)

public void
setSaltAndHash(byte[]
the salt
salt
,
byte[]
the password hash
hash
)

Set the salt and hash of the password for this user.

public void
setUserPasswordHash(byte[]
the user name password hash
userPasswordHash
)

Set the user name password hash.

pack-priv boolean

Returns:

true if the user password hash is correct
validateUserPasswordHash
(byte[]
the password data (the user password hash)
userPasswordHash
)

Check the password of this user.

Inherited from org.h2.engine.RightOwner:
checkOwnsNoSchemasgetRightForObjectgetRightForRolegrantRightgrantRoleisRoleGrantedisSchemaRightGrantedRecursiveisTableRightGrantedRecursiverenamerevokeRightrevokeRolerevokeTemporaryRightsOnRoles

Field Detail

adminback to summary
private boolean admin
passwordHashback to summary
private byte[] passwordHash
saltback to summary
private byte[] salt
systemUserback to summary
private final boolean systemUser

Constructor Detail

Userback to summary
public User(Database database, int id, String userName, boolean systemUser)

Method Detail

checkAdminback to summary
public void checkAdmin()

Checks if this user has admin rights. An exception is thrown if user doesn't have them.

Exceptions
DbException:
if this user is not an admin
checkSchemaAdminback to summary
public void checkSchemaAdmin()

Checks if this user has schema admin rights for every schema. An exception is thrown if user doesn't have them.

Exceptions
DbException:
if this user is not a schema admin
checkSchemaOwnerback to summary
public void checkSchemaOwner(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:Schema

the schema

Exceptions
DbException:
if this user is not a schema owner
checkTableRightback to summary
public void checkTableRight(Table table, int rightMask)

Checks that this user has the given rights for the specified table.

Parameters
table:Table

the table

rightMask:int

the rights required

Exceptions
DbException:
if this user does not have the required rights
getChildrenback to summary
public ArrayList<DbObject> getChildren()

Overrides org.h2.engine.DbObject.getChildren.

Doc from org.h2.engine.DbObject.getChildren.

Get the list of dependent children (for tables, this includes indexes and so on).

Returns:ArrayList<DbObject>

the list of children, or null

Annotations
@Override
getCreateSQLback to summary
public String getCreateSQL()

Implements abstract org.h2.engine.DbObject.getCreateSQL.

Doc from org.h2.engine.DbObject.getCreateSQL.

Construct the CREATE ... SQL statement for this object.

Returns:String

the SQL statement

Annotations
@Override
getCreateSQLback to summary
public String getCreateSQL(boolean password)

Get the CREATE SQL statement for this object.

Parameters
password:boolean

true if the password (actually the salt and hash) should be returned

Returns:String

the SQL statement

getTypeback to summary
public int getType()

Implements abstract org.h2.engine.DbObject.getType.

Doc from org.h2.engine.DbObject.getType.

Get the object type.

Returns:int

the object type

Annotations
@Override
hasSchemaRightback to summary
private boolean hasSchemaRight(Schema schema)

See if this user has owner rights for the specified schema

Parameters
schema:Schema

the schema

Returns:boolean

true if the user has the rights

hasTableRightback to summary
public boolean hasTableRight(Table table, int rightMask)

See if this user has the given rights for this database object.

Parameters
table:Table

the database object, or null for schema-only check

rightMask:int

the rights required

Returns:boolean

true if the user has the rights

isAdminback to summary
public boolean isAdmin()
removeChildrenAndResourcesback to summary
public void removeChildrenAndResources(SessionLocal session)

Implements abstract org.h2.engine.DbObject.removeChildrenAndResources.

Doc from org.h2.engine.DbObject.removeChildrenAndResources.

Delete all dependent children objects and resources of this object.

Parameters
session:SessionLocal

the session

Annotations
@Override
setAdminback to summary
public void setAdmin(boolean admin)
setSaltAndHashback to summary
public void setSaltAndHash(byte[] salt, byte[] hash)

Set the salt and hash of the password for this user.

Parameters
salt:byte[]

the salt

hash:byte[]

the password hash

setUserPasswordHashback to summary
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:byte[]

the user name password hash

validateUserPasswordHashback to summary
pack-priv boolean validateUserPasswordHash(byte[] userPasswordHash)

Check the password of this user.

Parameters
userPasswordHash:byte[]

the password data (the user password hash)

Returns:boolean

true if the user password hash is correct