1 21 22 package org.apache.derby.iapi.sql.dictionary; 23 24 import org.apache.derby.iapi.error.StandardException; 25 import org.apache.derby.catalog.UUID; 26 import org.apache.derby.iapi.sql.conn.Authorizer; 27 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 28 import org.apache.derby.iapi.reference.SQLState; 29 import org.apache.derby.iapi.sql.dictionary.RoutinePermsDescriptor; 30 import org.apache.derby.iapi.store.access.TransactionController; 31 32 36 37 public final class StatementRoutinePermission extends StatementPermission 38 { 39 private UUID routineUUID; 40 41 public StatementRoutinePermission( UUID routineUUID) 42 { 43 this.routineUUID = routineUUID; 44 } 45 46 49 public void check( LanguageConnectionContext lcc, 50 String authorizationId, 51 boolean forGrant) throws StandardException 52 { 53 DataDictionary dd = lcc.getDataDictionary(); 54 TransactionController tc = lcc.getTransactionExecute(); 55 56 RoutinePermsDescriptor perms = dd.getRoutinePermissions( routineUUID, authorizationId); 57 if( perms == null || ! perms.getHasExecutePermission()) 58 perms = dd.getRoutinePermissions(routineUUID, Authorizer.PUBLIC_AUTHORIZATION_ID); 59 60 if( perms == null || ! perms.getHasExecutePermission()) 61 { 62 AliasDescriptor ad = dd.getAliasDescriptor( routineUUID); 63 if( ad == null) 64 throw StandardException.newException( SQLState.AUTH_INTERNAL_BAD_UUID, "routine"); 65 SchemaDescriptor sd = dd.getSchemaDescriptor( ad.getSchemaUUID(), tc); 66 if( sd == null) 67 throw StandardException.newException( SQLState.AUTH_INTERNAL_BAD_UUID, "schema"); 68 throw StandardException.newException( forGrant ? SQLState.AUTH_NO_EXECUTE_PERMISSION_FOR_GRANT 69 : SQLState.AUTH_NO_EXECUTE_PERMISSION, 70 authorizationId, 71 ad.getDescriptorType(), 72 sd.getSchemaName(), 73 ad.getDescriptorName()); 74 } 75 } 77 80 public PermissionsDescriptor getPermissionDescriptor(String authid, DataDictionary dd) 81 throws StandardException 82 { 83 return dd.getRoutinePermissions(routineUUID,authid); 84 } 85 } 86 | Popular Tags |