Package org.h2.engine
Class User
java.lang.Object
org.h2.engine.DbObject
org.h2.engine.RightOwner
org.h2.engine.User
- All Implemented Interfaces:
org.h2.util.HasSQL
Represents a user object.
-
Field Summary
Fields inherited from class org.h2.engine.DbObject
AGGREGATE, comment, COMMENT, CONSTANT, CONSTRAINT, database, DOMAIN, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, trace, TRIGGER, USERFields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks if this user has admin rights.voidChecks if this user has schema admin rights for every schema.voidcheckSchemaOwner(org.h2.schema.Schema schema) Checks if this user has schema owner rights for the specified schema.voidcheckTableRight(org.h2.table.Table table, int rightMask) Checks that this user has the given rights for the specified table.Get the list of dependent children (for tables, this includes indexes and so on).Construct the CREATE ...getCreateSQL(boolean password) Get the CREATE SQL statement for this object.intgetType()Get the object type.booleanhasTableRight(org.h2.table.Table table, int rightMask) See if this user has the given rights for this database object.booleanisAdmin()voidremoveChildrenAndResources(SessionLocal session) Delete all dependent children objects and resources of this object.voidsetAdmin(boolean admin) voidsetSaltAndHash(byte[] salt, byte[] hash) Set the salt and hash of the password for this user.voidsetUserPasswordHash(byte[] userPasswordHash) Set the user name password hash.Methods inherited from class org.h2.engine.RightOwner
checkOwnsNoSchemas, getRightForObject, getRightForRole, grantRight, grantRole, isRoleGranted, rename, revokeTemporaryRightsOnRolesMethods inherited from class org.h2.engine.DbObject
checkRename, equals, getComment, getCreateSQLForCopy, getCreateSQLForMeta, getDatabase, getDropSQL, getId, getModificationId, getName, getSQL, getSQL, hashCode, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.h2.util.HasSQL
getTraceSQL
-
Constructor Details
-
User
-
-
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 salthash- 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
Description copied from class:DbObjectConstruct the CREATE ... SQL statement for this object.- Specified by:
getCreateSQLin classDbObject- Returns:
- the SQL statement
-
getCreateSQL
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 tablerightMask- 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 checkrightMask- the rights required- Returns:
- true if the user has the rights
-
getType
public int getType()Description copied from class:DbObjectGet the object type. -
getChildren
Description copied from class:DbObjectGet the list of dependent children (for tables, this includes indexes and so on).- Overrides:
getChildrenin classDbObject- Returns:
- the list of children, or
null
-
removeChildrenAndResources
Description copied from class:DbObjectDelete all dependent children objects and resources of this object.- Specified by:
removeChildrenAndResourcesin classDbObject- Parameters:
session- the session
-