--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.iapi.sql.dictionary.PermissionsDescriptor\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.iapi.sql.dictionary;\r
+\r
+import org.apache.derby.catalog.UUID;\r
+import org.apache.derby.iapi.error.StandardException;\r
+import org.apache.derby.iapi.sql.depend.Provider;\r
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+\r
+/**\r
+ * This class is used by rows in the SYS.SYSTABLEPERMS, SYS.SYSCOLPERMS, and SYS.SYSROUTINEPERMS\r
+ * system tables.\r
+ */\r
+public abstract class PermissionsDescriptor extends TupleDescriptor \r
+ implements Cloneable, Provider\r
+{\r
+ protected UUID oid;\r
+ private String grantee;\r
+ private final String grantor;\r
+\r
+ PermissionsDescriptor( DataDictionary dd,\r
+ String grantee,\r
+ String grantor)\r
+ {\r
+ super (dd);\r
+ this.grantee = grantee;\r
+ this.grantor = grantor;\r
+ }\r
+\r
+ public Object clone()\r
+ {\r
+ try\r
+ {\r
+ return super.clone();\r
+ }\r
+ catch( java.lang.CloneNotSupportedException cnse)\r
+ {\r
+ if( SanityManager.DEBUG)\r
+ SanityManager.THROWASSERT("Could not clone a " +\r
+ getClass().getName(), cnse);\r
+ return null;\r
+ }\r
+ }\r
+ \r
+ public abstract int getCatalogNumber();\r
+\r
+ /**\r
+ * @return true iff the key part of this permissions descriptor equals the key part of another permissions\r
+ * descriptor.\r
+ */\r
+ protected boolean keyEquals( PermissionsDescriptor other)\r
+ {\r
+ return grantee.equals( other.grantee);\r
+ }\r
+ \r
+ /**\r
+ * @return the hashCode for the key part of this permissions descriptor\r
+ */\r
+ protected int keyHashCode()\r
+ {\r
+ return grantee.hashCode();\r
+ }\r
+ \r
+ public void setGrantee( String grantee)\r
+ {\r
+ this.grantee = grantee;\r
+ }\r
+ \r
+ /*----- getter functions for rowfactory ------*/\r
+ public final String getGrantee() { return grantee;}\r
+ public final String getGrantor() { return grantor;}\r
+\r
+ /**\r
+ * Gets the UUID of the table.\r
+ *\r
+ * @return The UUID of the table.\r
+ */\r
+ public UUID getUUID() { return oid;}\r
+\r
+ /**\r
+ * Sets the UUID of the table\r
+ *\r
+ * @param oid The UUID of the table to be set in the descriptor\r
+ */\r
+ public void setUUID(UUID oid) { this.oid = oid;}\r
+ \r
+ /**\r
+ * This method checks if the passed authorization id is same as the owner \r
+ * of the object on which this permission is defined. This method gets\r
+ * called by create view/constraint/trigger to see if this permission \r
+ * needs to be saved in dependency system for the view/constraint/trigger. \r
+ * If the same user is the owner of the the object being accessed and the \r
+ * newly created object, then no need to keep this privilege dependency \r
+ *\r
+ * @return boolean If passed authorization id is owner of the table\r
+ */\r
+ public abstract boolean checkOwner(String authorizationId) throws StandardException;\r
+\r
+ //////////////////////////////////////////////\r
+ //\r
+ // PROVIDER INTERFACE\r
+ //\r
+ ////////////////////////////////////////////////////////////////////\r
+\r
+ /**\r
+ * Get the provider's UUID\r
+ *\r
+ * @return The provider's UUID\r
+ */\r
+ public UUID getObjectID()\r
+ {\r
+ return oid;\r
+ }\r
+\r
+ /**\r
+ * Is this provider persistent? A stored dependency will be required\r
+ * if both the dependent and provider are persistent.\r
+ *\r
+ * @return boolean Whether or not this provider is persistent.\r
+ */\r
+ public boolean isPersistent()\r
+ {\r
+ return true;\r
+ }\r
+}\r