Package org.h2.engine

Class RightOwner

  • All Implemented Interfaces:
    HasSQL
    Direct Known Subclasses:
    Role, User

    public abstract class RightOwner
    extends DbObject
    A right owner (sometimes called principal).
    • Field Detail

      • grantedRoles

        private java.util.HashMap<Role,​Right> grantedRoles
        The map of granted roles.
      • grantedRights

        private java.util.HashMap<DbObject,​Right> grantedRights
        The map of granted rights.
    • Constructor Detail

      • RightOwner

        protected RightOwner​(Database database,
                             int id,
                             java.lang.String name,
                             int traceModuleId)
    • Method Detail

      • rename

        public void rename​(java.lang.String newName)
        Description copied from class: DbObject
        Rename the object.
        Overrides:
        rename in class DbObject
        Parameters:
        newName - the new name
      • isRoleGranted

        public boolean isRoleGranted​(Role grantedRole)
        Check if a role has been granted for this right owner.
        Parameters:
        grantedRole - the role
        Returns:
        true if the role has been granted
      • isTableRightGrantedRecursive

        final boolean isTableRightGrantedRecursive​(Table table,
                                                   int rightMask)
        Checks if a right is already granted to this object or to objects that were granted to this object. The rights of schemas will be valid for every each table in the related schema. The ALTER ANY SCHEMA right gives all rights to all tables.
        Parameters:
        table - the table to check
        rightMask - the right mask to check
        Returns:
        true if the right was already granted
      • isSchemaRightGrantedRecursive

        final boolean isSchemaRightGrantedRecursive​(Schema schema)
        Checks if a schema owner right is already granted to this object or to objects that were granted to this object. The ALTER ANY SCHEMA right gives rights to all schemas.
        Parameters:
        schema - the schema to check, or null to check for ALTER ANY SCHEMA right only
        Returns:
        true if the right was already granted
      • grantRight

        public void grantRight​(DbObject object,
                               Right right)
        Grant a right for the given table. Only one right object per table is supported.
        Parameters:
        object - the object (table or schema)
        right - the right
      • revokeRight

        void revokeRight​(DbObject object)
        Revoke the right for the given object (table or schema).
        Parameters:
        object - the object
      • grantRole

        public void grantRole​(Role role,
                              Right right)
        Grant a role to this object.
        Parameters:
        role - the role
        right - the right to grant
      • revokeRole

        void revokeRole​(Role role)
        Remove the right for the given role.
        Parameters:
        role - the role to revoke
      • revokeTemporaryRightsOnRoles

        public void revokeTemporaryRightsOnRoles()
        Remove all the temporary rights granted on roles
      • getRightForObject

        public Right getRightForObject​(DbObject object)
        Get the 'grant schema' right of this object.
        Parameters:
        object - the granted object (table or schema)
        Returns:
        the right or null if the right has not been granted
      • getRightForRole

        public Right getRightForRole​(Role role)
        Get the 'grant role' right of this object.
        Parameters:
        role - the granted role
        Returns:
        the right or null if the right has not been granted
      • checkOwnsNoSchemas

        public final void checkOwnsNoSchemas()
        Check that this right owner does not own any schema. An exception is thrown if it owns one or more schemas.
        Throws:
        DbException - if this right owner owns a schema