KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > sql > dictionary > PermissionsDescriptor


1 /*
2
3    Derby - Class org.apache.derby.iapi.sql.dictionary.PermissionsDescriptor
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.sql.dictionary;
23
24 import org.apache.derby.catalog.UUID;
25 import org.apache.derby.iapi.error.StandardException;
26 import org.apache.derby.iapi.sql.depend.Provider;
27 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
28 import org.apache.derby.iapi.services.sanity.SanityManager;
29
30 /**
31  * This class is used by rows in the SYS.SYSTABLEPERMS, SYS.SYSCOLPERMS, and SYS.SYSROUTINEPERMS
32  * system tables.
33  */

34 public abstract class PermissionsDescriptor extends TupleDescriptor
35     implements Cloneable JavaDoc, Provider
36 {
37     protected UUID oid;
38     private String JavaDoc grantee;
39     private final String JavaDoc grantor;
40
41     PermissionsDescriptor( DataDictionary dd,
42                                   String JavaDoc grantee,
43                                   String JavaDoc grantor)
44     {
45         super (dd);
46         this.grantee = grantee;
47         this.grantor = grantor;
48     }
49
50     public Object JavaDoc clone()
51     {
52         try
53         {
54             return super.clone();
55         }
56         catch( java.lang.CloneNotSupportedException JavaDoc cnse)
57         {
58             if( SanityManager.DEBUG)
59                 SanityManager.THROWASSERT( "Could not clone a " + getClass().getName());
60             return null;
61         }
62     }
63     
64     public abstract int getCatalogNumber();
65
66     /**
67      * @return true iff the key part of this permissions descriptor equals the key part of another permissions
68      * descriptor.
69      */

70     protected boolean keyEquals( PermissionsDescriptor other)
71     {
72         return grantee.equals( other.grantee);
73     }
74            
75     /**
76      * @return the hashCode for the key part of this permissions descriptor
77      */

78     protected int keyHashCode()
79     {
80         return grantee.hashCode();
81     }
82     
83     public void setGrantee( String JavaDoc grantee)
84     {
85         this.grantee = grantee;
86     }
87     
88     /*----- getter functions for rowfactory ------*/
89     public final String JavaDoc getGrantee() { return grantee;}
90     public final String JavaDoc getGrantor() { return grantor;}
91
92     /**
93      * Gets the UUID of the table.
94      *
95      * @return The UUID of the table.
96      */

97     public UUID getUUID() { return oid;}
98
99     /**
100      * Sets the UUID of the table
101      *
102      * @param oid The UUID of the table to be set in the descriptor
103      */

104     public void setUUID(UUID oid) { this.oid = oid;}
105     
106     /**
107      * This method checks if the passed authorization id is same as the owner
108      * of the object on which this permission is defined. This method gets
109      * called by create view/constraint/trigger to see if this permission
110      * needs to be saved in dependency system for the view/constraint/trigger.
111      * If the same user is the owner of the the object being accessed and the
112      * newly created object, then no need to keep this privilege dependency
113      *
114      * @return boolean If passed authorization id is owner of the table
115      */

116     public abstract boolean checkOwner(String JavaDoc authorizationId) throws StandardException;
117
118     //////////////////////////////////////////////
119
//
120
// PROVIDER INTERFACE
121
//
122
////////////////////////////////////////////////////////////////////
123

124     /**
125      * Get the provider's UUID
126      *
127      * @return The provider's UUID
128      */

129     public UUID getObjectID()
130     {
131         return oid;
132     }
133
134     /**
135      * Is this provider persistent? A stored dependency will be required
136      * if both the dependent and provider are persistent.
137      *
138      * @return boolean Whether or not this provider is persistent.
139      */

140     public boolean isPersistent()
141     {
142         return true;
143     }
144 }
145
Popular Tags