1 21 22 package org.apache.derby.iapi.sql.dictionary; 23 24 import org.apache.derby.iapi.error.StandardException; 25 import org.apache.derby.iapi.sql.conn.Authorizer; 26 import org.apache.derby.iapi.reference.SQLState; 27 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor; 28 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 29 import org.apache.derby.iapi.store.access.TransactionController; 30 import org.apache.derby.iapi.services.sanity.SanityManager; 31 32 35 36 public class StatementSchemaPermission extends StatementPermission 37 { 38 41 private String schemaName; 42 45 private String aid; 46 50 private int privType; 51 52 public StatementSchemaPermission(String schemaName, String aid, int privType) 53 { 54 this.schemaName = schemaName; 55 this.aid = aid; 56 this.privType = privType; 57 } 58 59 62 public void check( LanguageConnectionContext lcc, 63 String authid, 64 boolean forGrant) throws StandardException 65 { 66 DataDictionary dd = lcc.getDataDictionary(); 67 TransactionController tc = lcc.getTransactionExecute(); 68 69 switch ( privType ) 70 { 71 case Authorizer.MODIFY_SCHEMA_PRIV: 72 case Authorizer.DROP_SCHEMA_PRIV: 73 SchemaDescriptor sd = dd.getSchemaDescriptor(schemaName, tc, false); 74 if (sd == null) 78 return; 79 80 if (!authid.equals(sd.getAuthorizationId())) 81 throw StandardException.newException( 82 SQLState.AUTH_NO_ACCESS_NOT_OWNER, authid, schemaName); 83 break; 84 85 case Authorizer.CREATE_SCHEMA_PRIV: 86 if ( !schemaName.equals(authid) || 90 (aid != null && !aid.equals(authid)) ) 91 throw StandardException.newException( 92 SQLState.AUTH_NOT_DATABASE_OWNER, authid, schemaName); 93 break; 94 95 default: 96 if (SanityManager.DEBUG) 97 { 98 SanityManager.THROWASSERT( 99 "Unexpected value (" + privType + ") for privType"); 100 } 101 break; 102 } 103 } 104 105 112 public PermissionsDescriptor getPermissionDescriptor(String authid, DataDictionary dd) 113 throws StandardException 114 { 115 return null; 116 } 117 } 118 | Popular Tags |