1
/* Copyright (c) 2001-2005, The HSQL Development Group
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
7
* Redistributions of source code must retain the above copyright notice, this
8
* list of conditions and the following disclaimer.
10
* Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
14
* Neither the name of the HSQL Development Group nor the names of its
15
* contributors may be used to endorse or promote products derived from this
16
* software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
22
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
/* Copyright (c) 2001-2005, The HSQL Development Group
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
7
* Redistributions of source code must retain the above copyright notice, this
8
* list of conditions and the following disclaimer.
10
* Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
14
* Neither the name of the HSQL Development Group nor the names of its
15
* contributors may be used to endorse or promote products derived from this
16
* software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
22
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
32
package org.hsqldb;
34
34
import org.hsqldb.HsqlNameManager.HsqlName;
73
73
* true if this grantee has database administrator priv directly
74
74
* (ie., not by membership in any role)
76
private boolean adminDirect = false;
76
private boolean isAdminDirect = false;
78
78
/** true if this grantee has database administrator priv by any means. */
79
private boolean admin = false;
79
private boolean isAdmin = false;
81
81
/** contains righs granted direct, or via roles, expept those of PUBLIC */
82
82
private IntValueHashMap fullRightsMap = new IntValueHashMap();
351
351
* from the dbobject argument for at least one of the rights
352
352
* contained in the rights argument. Otherwise, it throws.
354
void check(Object dbobject, int rights) throws HsqlException {
354
void check(HsqlName dbobject, int rights) throws HsqlException {
356
356
if (!isAccessible(dbobject, rights)) {
357
357
throw Trace.error(Trace.ACCESS_IS_DENIED);
361
void check(String dbobject) throws HsqlException {
363
if (!isAccessible(dbobject)) {
364
throw Trace.error(Trace.ACCESS_IS_DENIED);
362
369
* Returns true if any of the rights represented by the
363
370
* rights argument has been granted on the database object identified
399
* Returns true if any right at all has been granted to this User object
400
* on the database object identified by the dbObject argument.
402
boolean isAccessible(String functionName) throws HsqlException {
404
if (functionName.startsWith("org.hsqldb.Library")
405
|| functionName.startsWith("java.lang.Math")) {
413
if (pubGrantee != null && pubGrantee.isAccessible(functionName)) {
417
int n = fullRightsMap.get(functionName, 0);
399
423
* Returns true if any of the rights represented by the
400
424
* rights argument has been granted on the database object identified
401
425
* by the dbObject argument. <p>