001: /*
002:
003: Derby - Class org.apache.derby.iapi.sql.conn.Authorizer
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.iapi.sql.conn;
023:
024: import org.apache.derby.iapi.sql.Activation;
025: import org.apache.derby.iapi.error.StandardException;
026:
027: /**
028: The Authorizer verifies a connected user has the authorization
029: to perform a requested database operation using the current
030: connection.
031:
032: <P>
033: Today no object based authorization is supported.
034: */
035: public interface Authorizer {
036: /** SQL write (insert,update,delete) operation */
037: public static final int SQL_WRITE_OP = 0;
038: /** SQL SELECT operation */
039: public static final int SQL_SELECT_OP = 1;
040: /** Any other SQL operation */
041: public static final int SQL_ARBITARY_OP = 2;
042: /** SQL CALL/VALUE operation */
043: public static final int SQL_CALL_OP = 3;
044: /** SQL DDL operation */
045: public static final int SQL_DDL_OP = 4;
046: /** database property write operation */
047: public static final int PROPERTY_WRITE_OP = 5;
048: /** database jar write operation */
049: public static final int JAR_WRITE_OP = 6;
050:
051: /* Privilege types for SQL standard (grant/revoke) permissions checking. */
052: public static final int NULL_PRIV = -1;
053: public static final int SELECT_PRIV = 0;
054: public static final int UPDATE_PRIV = 1;
055: public static final int REFERENCES_PRIV = 2;
056: public static final int INSERT_PRIV = 3;
057: public static final int DELETE_PRIV = 4;
058: public static final int TRIGGER_PRIV = 5;
059: public static final int EXECUTE_PRIV = 6;
060: public static final int PRIV_TYPE_COUNT = 7;
061:
062: /* Used to check who can create schemas or who can modify objects in schema */
063: public static final int CREATE_SCHEMA_PRIV = 16;
064: public static final int MODIFY_SCHEMA_PRIV = 17;
065: public static final int DROP_SCHEMA_PRIV = 18;
066:
067: /**
068: * The system authorization ID is defined by the SQL2003 spec as the grantor
069: * of privileges to object owners.
070: */
071: public static final String SYSTEM_AUTHORIZATION_ID = "_SYSTEM";
072:
073: /**
074: * The public authorization ID is defined by the SQL2003 spec as implying all users.
075: */
076: public static final String PUBLIC_AUTHORIZATION_ID = "PUBLIC";
077:
078: /**
079: Verify the connected user is authorized to perform the requested
080: operation.
081:
082: This variation should only be used with operations that do not use tables
083: or routines. If the operation involves tables or routines then use the
084: variation of the authorize method that takes an Activation parameter. The
085: activation holds the table, column, and routine lists.
086:
087: @param operation the enumeration code for the requsted operation.
088:
089: @exception StandardException Thrown if the operation is not allowed
090: */
091: public void authorize(int operation) throws StandardException;
092:
093: /**
094: Verify the connected user is authorized to perform the requested
095: operation.
096:
097: @param activation holds the list of tables, columns, and routines used.
098: @param operation the enumeration code for the requsted operation.
099:
100: @exception StandardException Thrown if the operation is not allowed
101: */
102: public void authorize(Activation activation, int operation)
103: throws StandardException;
104:
105: /**
106: Get the Authorization ID for this Authorizer.
107: */
108: public String getAuthorizationId();
109:
110: /**
111: Get the readOnly status for this authorizer's connection.
112: */
113: public boolean isReadOnlyConnection();
114:
115: /**
116: Set the readOnly status for this authorizer's connection.
117: @param on true means set the connection to read only mode,
118: false means set the connection to read wrte mode.
119: @param authorize true means to verify the caller has authority
120: to set the connection and false means do not check.
121: @exception StandardException Oops not allowed.
122: */
123: public void setReadOnlyConnection(boolean on, boolean authorize)
124: throws StandardException;
125:
126: /**
127: Refresh this authorizer to reflect a change in the database
128: permissions.
129:
130: @exception AuthorizerSessionException Connect permission gone.
131: @exception StandardException Oops.
132: */
133: public void refresh() throws StandardException;
134: }
|