Top Description Fields Constructors Methods
org.hsqldb.rights

public Class Grantee

extends Object
implements SchemaObject
Class Inheritance
All Implemented Interfaces
org.hsqldb.SchemaObject
Known Direct Subclasses
org.hsqldb.rights.User
Imports
org.hsqldb.HsqlNameManager.HsqlName, .NumberSequence, .Routine, .SchemaObject, .Session, .Table, .Tokens, org.hsqldb.error.Error, .ErrorCode, org.hsqldb.lib.HashMap, .HsqlArrayList, .Iterator, .MultiValueHashMap, .OrderedHashSet, org.hsqldb.types.Type

A Grantee Object holds the name, access and administrative rights for a particular grantee.

It supplies the methods used to grant, revoke, test and check a grantee's access rights to other database objects. It also holds a reference to the common PUBLIC User Object, which represent the special user referred to in GRANT ... TO PUBLIC statements.

The check(), isAccessible() and getGrantedClassNames() methods check the rights granted to the PUBLIC User Object, in addition to individually granted rights, in order to decide which rights exist for the user. Method names ending in Direct indicate methods which do not recurse to look through Roles which "this" object is a member of. We use the word "Admin" (e.g., in private variable "admin" and method "isAdmin()") to mean this Grantee has admin priv by any means. We use the word "adminDirect" (e.g., in private variable "adminDirect" and method "isAdminDirect()") to mean this Grantee has admin priv directly.

Authors
Campbell Burnet (campbell-burnet@users dot sourceforge.net), Fred Toussi (fredt@users dot sourceforge.net), Blaine Simpson (blaine dot simpson at admc dot com)
Since
1.8.0
Version
2.7.3

Field Summary

Modifier and TypeField and Description
private MultiValueHashMap<HsqlNameManager.HsqlName, Right>
directRightsMap

map with database object identifier keys and access privileges values

pack-priv HashMap<HsqlNameManager.HsqlName, Right>
fullRightsMap

contains rights granted direct, or via roles, except those of PUBLIC

private MultiValueHashMap<HsqlNameManager.HsqlName, Right>
grantedRightsMap

map with database object identifier keys and access privileges values

protected GranteeManager
granteeManager

Needed only to give access to the roles for this database

protected HsqlNameManager.HsqlName
granteeName

Grantee name.

private boolean
isAdmin

true if this grantee has database administrator priv by any means.

private boolean
isAdminDirect

true if this grantee has database administrator priv directly (i.e., not by membership in any role)

pack-priv boolean
isPublic

true if this grantee is PUBLIC.

pack-priv boolean
pack-priv boolean
isSystem

true if this grantee is _SYSTEM.

protected Right
pack-priv OrderedHashSet<Grantee>
roles

These are the DIRECT roles.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private OrderedHashSet<Grantee>

Returns:

Given role with new elements added.
addGranteeAndRoles
(OrderedHashSet<Grantee> set)

Adds to given Set this.sName plus all roles and nested roles.

pack-priv void
addToFullRights(HashMap<HsqlNameManager.HsqlName, Right> map)

Full or partial rights are added to existing

private void
addToFullRights(MultiValueHashMap<HsqlNameManager.HsqlName, Right> map)

Full or partial rights are added to existing

public boolean
canChangeAuthorisation()

Returns true if this Grantee can change to a different user.

public boolean
canPerformScriptOps()

Returns true if this Grantee can change to a different user.

public Right
public void
checkAdmin()

Checks whether this Grantee has administrative privs either directly or indirectly.

public Right
public Right
checkInsert(SchemaObject object, boolean[] checkList)

public Right
checkReferences(SchemaObject object, boolean[] checkList)

public void
checkSchemaUpdateOrGrantRights(HsqlNameManager.HsqlName schemaName)

Checks if this object can modify schema objects or grant access rights to them.

public Right
checkSelect(SchemaObject object, boolean[] checkList)

Checks if a right represented by the methods have been granted on the specified database object.

public Right
checkTrigger(SchemaObject object, boolean[] checkList)

public Right
checkUpdate(SchemaObject object, boolean[] checkList)

pack-priv void
clearPrivileges()

Revokes all rights from this Grantee object.

public OrderedHashSet<Right>
pack-priv Right
public OrderedHashSet<Right>
public OrderedHashSet<Grantee>
getAllRoles()

Gets direct and indirect roles.

public HsqlNameManager.HsqlName
public long
public OrderedHashSet<HsqlNameManager.HsqlName>
public OrderedHashSet<Grantee>
getDirectRoles()

Gets direct roles, not roles nested within them.

public OrderedHashSet<Grantee>
getDirectRolesWithPublic()

Gets direct roles and public role, not roles nested within them.

public OrderedHashSet<Grantee>
public OrderedHashSet<Grantee>
public HsqlNameManager.HsqlName
public Grantee
private MultiValueHashMap<HsqlNameManager.HsqlName, Right>
getRights()

Retrieves the map object that represents the rights that have been granted on database objects.

pack-priv HsqlArrayList<String>
public HsqlNameManager.HsqlName
public String
public int
pack-priv void
grant(HsqlNameManager.HsqlName name, Right right, Grantee grantor, boolean withGrant)

Grants the specified rights on the specified database object.

pack-priv void
grant(Grantee role)

Grant a role

private void
grantToAll(HsqlNameManager.HsqlName name, Right right, Grantee grantor, boolean withGrant)

public boolean
hasColumnRights(SchemaObject table, int[] columnMap)

public boolean
public boolean
private boolean
public boolean
hasSchemaUpdateOrGrantRights(HsqlNameManager.HsqlName schemaName)

Checks if this object can modify schema objects or grant access rights to them.

public boolean
public boolean
isAccessible(SchemaObject object)

returns true if grantee has any privilege (to any column) of the object

public boolean
public boolean
isAdmin()

Returns true if this Grantee has administrative privs either directly or indirectly.

public boolean
public boolean
public boolean
public boolean
isPublic()

Returns true if this grantee object is for the PUBLIC role.

public boolean
public boolean
isSchemaCreator()

Returns true if this Grantee can create schemas with own authorization.

public boolean
pack-priv void
revoke(SchemaObject object, Right right, Grantee grantor, boolean grantOption)

Revokes the specified rights on the specified database object.

pack-priv void
revoke(Grantee role)

Revoke a direct role only

pack-priv void
revokeDbObject(HsqlNameManager.HsqlName name)

Revokes all rights on the specified database object.

private void
revokeFromAll(HsqlNameManager.HsqlName name, Right right, Grantee grantor, boolean grantOption)

private String
pack-priv void
setAdminDirect()

Violates naming convention (for backward compatibility).

pack-priv void
updateAllRights()

Method used with all Grantee objects to set the full set of rights according to those inherited form ROLE Grantee objects and those granted to the object itself.

pack-priv boolean

Returns:

true if this Grantee has possibly changed as a result
updateNestedRoles
(Grantee
a modified, revoked or dropped role.
role
)

Recursive method used with ROLE Grantee objects to set the fullRightsMap and admin flag for all the roles.

public OrderedHashSet<Grantee>
visibleGrantees()

Iteration of all visible grantees, including self.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

directRightsMapback to summary
private MultiValueHashMap<HsqlNameManager.HsqlName, Right> directRightsMap

map with database object identifier keys and access privileges values

fullRightsMapback to summary
pack-priv HashMap<HsqlNameManager.HsqlName, Right> fullRightsMap

contains rights granted direct, or via roles, except those of PUBLIC

grantedRightsMapback to summary
private MultiValueHashMap<HsqlNameManager.HsqlName, Right> grantedRightsMap

map with database object identifier keys and access privileges values

granteeManagerback to summary
protected GranteeManager granteeManager

Needed only to give access to the roles for this database

granteeNameback to summary
protected HsqlNameManager.HsqlName granteeName

Grantee name.

isAdminback to summary
private boolean isAdmin

true if this grantee has database administrator priv by any means.

isAdminDirectback to summary
private boolean isAdminDirect

true if this grantee has database administrator priv directly (i.e., not by membership in any role)

isPublicback to summary
pack-priv boolean isPublic

true if this grantee is PUBLIC.

isRoleback to summary
pack-priv boolean isRole
isSystemback to summary
pack-priv boolean isSystem

true if this grantee is _SYSTEM.

ownerRightsback to summary
protected Right ownerRights
rolesback to summary
pack-priv OrderedHashSet<Grantee> roles

These are the DIRECT roles. Each of these may contain nested roles

Constructor Detail

Granteeback to summary
pack-priv Grantee(HsqlNameManager.HsqlName name, GranteeManager man)

Constructor.

Method Detail

addGranteeAndRolesback to summary
private OrderedHashSet<Grantee> addGranteeAndRoles(OrderedHashSet<Grantee> set)

Adds to given Set this.sName plus all roles and nested roles.

Returns:OrderedHashSet<Grantee>

Given role with new elements added.

addToFullRightsback to summary
pack-priv void addToFullRights(HashMap<HsqlNameManager.HsqlName, Right> map)

Full or partial rights are added to existing

addToFullRightsback to summary
private void addToFullRights(MultiValueHashMap<HsqlNameManager.HsqlName, Right> map)

Full or partial rights are added to existing

canChangeAuthorisationback to summary
public boolean canChangeAuthorisation()

Returns true if this Grantee can change to a different user.

canPerformScriptOpsback to summary
public boolean canPerformScriptOps()

Returns true if this Grantee can change to a different user.

checkAccessback to summary
public Right checkAccess(SchemaObject object)
checkAdminback to summary
public void checkAdmin()

Checks whether this Grantee has administrative privs either directly or indirectly. Otherwise it throws.

checkDeleteback to summary
public Right checkDelete(SchemaObject object)
checkInsertback to summary
public Right checkInsert(SchemaObject object, boolean[] checkList)
checkReferencesback to summary
public Right checkReferences(SchemaObject object, boolean[] checkList)
checkSchemaUpdateOrGrantRightsback to summary
public void checkSchemaUpdateOrGrantRights(HsqlNameManager.HsqlName schemaName)

Checks if this object can modify schema objects or grant access rights to them.

checkSelectback to summary
public Right checkSelect(SchemaObject object, boolean[] checkList)

Checks if a right represented by the methods have been granted on the specified database object.

This is done by checking that a mapping exists in the rights map from the dbobject argument. Otherwise, it throws.

checkTriggerback to summary
public Right checkTrigger(SchemaObject object, boolean[] checkList)
checkUpdateback to summary
public Right checkUpdate(SchemaObject object, boolean[] checkList)
clearPrivilegesback to summary
pack-priv void clearPrivileges()

Revokes all rights from this Grantee object. The map is cleared and the database administrator role attribute is set false.

getAllDirectPrivilegesback to summary
public OrderedHashSet<Right> getAllDirectPrivileges(SchemaObject object)
getAllGrantableRightsback to summary
pack-priv Right getAllGrantableRights(HsqlNameManager.HsqlName name)
getAllGrantedPrivilegesback to summary
public OrderedHashSet<Right> getAllGrantedPrivileges(SchemaObject object)
getAllRolesback to summary
public OrderedHashSet<Grantee> getAllRoles()

Gets direct and indirect roles.

getCatalogNameback to summary
public HsqlNameManager.HsqlName getCatalogName()

Implements org.hsqldb.SchemaObject.getCatalogName.

getChangeTimestampback to summary
public long getChangeTimestamp()

Implements org.hsqldb.SchemaObject.getChangeTimestamp.

getColumnsForAllPrivilegesback to summary
public OrderedHashSet<HsqlNameManager.HsqlName> getColumnsForAllPrivileges(SchemaObject object)
getDirectRolesback to summary
public OrderedHashSet<Grantee> getDirectRoles()

Gets direct roles, not roles nested within them.

getDirectRolesWithPublicback to summary
public OrderedHashSet<Grantee> getDirectRolesWithPublic()

Gets direct roles and public role, not roles nested within them.

getGranteeAndAllRolesback to summary
public OrderedHashSet<Grantee> getGranteeAndAllRoles()
getGranteeAndAllRolesWithPublicback to summary
public OrderedHashSet<Grantee> getGranteeAndAllRolesWithPublic()
getNameback to summary
public HsqlNameManager.HsqlName getName()

Implements org.hsqldb.SchemaObject.getName.

getOwnerback to summary
public Grantee getOwner()

Implements org.hsqldb.SchemaObject.getOwner.

getRightsback to summary
private MultiValueHashMap<HsqlNameManager.HsqlName, Right> getRights()

Retrieves the map object that represents the rights that have been granted on database objects.

The map has keys and values with the following interpretation:

  • The keys are generally (but not limited to) objects having an attribute or value equal to the name of an actual database object.
  • Specifically, the keys act as database object identifiers.
  • The values are Right objects.
getRightsSQLback to summary
pack-priv HsqlArrayList<String> getRightsSQL()
getSchemaNameback to summary
public HsqlNameManager.HsqlName getSchemaName()

Implements org.hsqldb.SchemaObject.getSchemaName.

getSQLback to summary
public String getSQL()

Implements org.hsqldb.SchemaObject.getSQL.

getTypeback to summary
public int getType()

Implements org.hsqldb.SchemaObject.getType.

grantback to summary
pack-priv void grant(HsqlNameManager.HsqlName name, Right right, Grantee grantor, boolean withGrant)

Grants the specified rights on the specified database object.

Keys stored in rightsMap for database tables are their HsqlName attribute. This allows rights to persist when a table is renamed.

grantback to summary
pack-priv void grant(Grantee role)

Grant a role

grantToAllback to summary
private void grantToAll(HsqlNameManager.HsqlName name, Right right, Grantee grantor, boolean withGrant)
hasColumnRightsback to summary
public boolean hasColumnRights(SchemaObject table, int[] columnMap)
hasNonSelectTableRightback to summary
public boolean hasNonSelectTableRight(SchemaObject table)
hasRoleback to summary
public boolean hasRole(Grantee role)
hasRoleDirectback to summary
private boolean hasRoleDirect(Grantee role)
hasSchemaUpdateOrGrantRightsback to summary
public boolean hasSchemaUpdateOrGrantRights(HsqlNameManager.HsqlName schemaName)

Checks if this object can modify schema objects or grant access rights to them.

isAccessibleback to summary
public boolean isAccessible(HsqlNameManager.HsqlName name, int action)
isAccessibleback to summary
public boolean isAccessible(SchemaObject object)

returns true if grantee has any privilege (to any column) of the object

isAccessibleback to summary
public boolean isAccessible(HsqlNameManager.HsqlName name)
isAdminback to summary
public boolean isAdmin()

Returns true if this Grantee has administrative privs either directly or indirectly.

isFullyAccessibleByRoleback to summary
public boolean isFullyAccessibleByRole(HsqlNameManager.HsqlName name)
isGrantableback to summary
public boolean isGrantable(SchemaObject object, Right right)
isGrantableback to summary
public boolean isGrantable(Grantee role)
isPublicback to summary
public boolean isPublic()

Returns true if this grantee object is for the PUBLIC role.

isRoleback to summary
public boolean isRole()
isSchemaCreatorback to summary
public boolean isSchemaCreator()

Returns true if this Grantee can create schemas with own authorization.

isSystemback to summary
public boolean isSystem()
revokeback to summary
pack-priv void revoke(SchemaObject object, Right right, Grantee grantor, boolean grantOption)

Revokes the specified rights on the specified database object.

If, after removing the specified rights, no rights remain on the database object, then the key/value pair for that object is removed from the rights map

revokeback to summary
pack-priv void revoke(Grantee role)

Revoke a direct role only

revokeDbObjectback to summary
pack-priv void revokeDbObject(HsqlNameManager.HsqlName name)

Revokes all rights on the specified database object.

This method removes any existing mapping from the rights map

revokeFromAllback to summary
private void revokeFromAll(HsqlNameManager.HsqlName name, Right right, Grantee grantor, boolean grantOption)
roleMapToStringback to summary
private String roleMapToString(OrderedHashSet<Grantee> roles)
setAdminDirectback to summary
pack-priv void setAdminDirect()

Violates naming convention (for backward compatibility). Should be "setAdminDirect(boolean)".

updateAllRightsback to summary
pack-priv void updateAllRights()

Method used with all Grantee objects to set the full set of rights according to those inherited form ROLE Grantee objects and those granted to the object itself.

updateNestedRolesback to summary
pack-priv boolean updateNestedRoles(Grantee role)

Recursive method used with ROLE Grantee objects to set the fullRightsMap and admin flag for all the roles. If a new ROLE is granted to a ROLE Grantee object, the ROLE should first be added to the Set of ROLE Grantee objects (roles) for the grantee. The grantee will be the parameter. If the direct permissions granted to an existing ROLE Grantee is modified no extra initial action is necessary. The existing Grantee will be the parameter. If an existing ROLE is REVOKEed from a ROLE, it should first be removed from the set of ROLE Grantee objects in the containing ROLE. The containing ROLE will be the parameter. If an existing ROLE is DROPped, all its privileges should be cleared first. The ROLE will be the parameter. After calling this method on all other roles, the DROPped role should be removed from all grantees. After the initial modification, this method should be called iteratively on all the ROLE Grantee objects contained in RoleManager. The updateAllRights() method is then called iteratively on all the USER Grantee objects contained in UserManager.

Parameters
role:Grantee

a modified, revoked or dropped role.

Returns:boolean

true if this Grantee has possibly changed as a result

visibleGranteesback to summary
public OrderedHashSet<Grantee> visibleGrantees()

Iteration of all visible grantees, including self.

For grantees with admin, this is all grantees. For regular grantees, this is self plus all roles granted directly or indirectly