1 21 22 package org.apache.derby.iapi.sql.dictionary; 23 24 import org.apache.derby.catalog.Dependable; 25 import org.apache.derby.catalog.DependableFinder; 26 import org.apache.derby.catalog.UUID; 27 28 import org.apache.derby.iapi.error.StandardException; 29 import org.apache.derby.iapi.services.io.StoredFormatIds; 30 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 31 import org.apache.derby.impl.sql.catalog.DDdependableFinder; 32 33 37 public class RoutinePermsDescriptor extends PermissionsDescriptor 38 { 39 private UUID routineUUID; 40 private String routineName; 41 private boolean hasExecutePermission; 42 43 public RoutinePermsDescriptor( DataDictionary dd, 44 String grantee, 45 String grantor, 46 UUID routineUUID, 47 boolean hasExecutePermission) throws StandardException 48 { 49 super (dd, grantee, grantor); 50 this.routineUUID = routineUUID; 51 this.hasExecutePermission = hasExecutePermission; 52 if (routineUUID != null) 55 routineName = dd.getAliasDescriptor(routineUUID).getObjectName(); 56 } 57 58 public RoutinePermsDescriptor( DataDictionary dd, 59 String grantee, 60 String grantor, 61 UUID routineUUID) throws StandardException 62 { 63 this( dd, grantee, grantor, routineUUID, true); 64 } 65 66 69 public RoutinePermsDescriptor( DataDictionary dd, 70 String grantee, 71 String grantor) throws StandardException 72 { 73 this( dd, grantee, grantor, (UUID) null); 74 } 75 76 public RoutinePermsDescriptor( DataDictionary dd, UUID routineePermsUUID) 77 throws StandardException 78 { 79 this( dd, null, null, null, true); 80 this.oid = routineePermsUUID; 81 } 82 83 public int getCatalogNumber() 84 { 85 return DataDictionary.SYSROUTINEPERMS_CATALOG_NUM; 86 } 87 88 89 public UUID getRoutineUUID() { return routineUUID;} 90 public boolean getHasExecutePermission() { return hasExecutePermission;} 91 92 public String toString() 93 { 94 return "routinePerms: grantee=" + getGrantee() + 95 ",routinePermsUUID=" + getUUID() + 96 ",grantor=" + getGrantor() + 97 ",routineUUID=" + getRoutineUUID(); 98 } 99 100 104 public boolean equals( Object other) 105 { 106 if( !( other instanceof RoutinePermsDescriptor)) 107 return false; 108 RoutinePermsDescriptor otherRoutinePerms = (RoutinePermsDescriptor) other; 109 return super.keyEquals( otherRoutinePerms) && 110 routineUUID.equals( otherRoutinePerms.routineUUID); 111 } 112 113 116 public int hashCode() 117 { 118 return super.keyHashCode() + routineUUID.hashCode(); 119 } 120 121 124 public boolean checkOwner(String authorizationId) throws StandardException 125 { 126 UUID sd = getDataDictionary().getAliasDescriptor(routineUUID).getSchemaUUID(); 127 if (getDataDictionary().getSchemaDescriptor(sd, null).getAuthorizationId().equals(authorizationId)) 128 return true; 129 else 130 return false; 131 } 132 133 139 144 public String getObjectName() 145 { 146 return "Routine Privilege on " + routineName; 147 } 148 149 154 public String getClassType() 155 { 156 return Dependable.ROUTINE_PERMISSION; 157 } 158 159 164 public DependableFinder getDependableFinder() 165 { 166 return new DDdependableFinder(StoredFormatIds.ROUTINE_PERMISSION_FINDER_V01_ID); 167 } 168 } 169 | Popular Tags |