use of org.apache.derby.iapi.sql.dictionary.TablePermsDescriptor in project derby by apache.
the class SYSTABLEPERMSRowFactory method buildDescriptor.
// end of makeRow
/**
* builds a tuple descriptor from a row
*/
public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentTuple, DataDictionary dataDictionary) throws StandardException {
if (SanityManager.DEBUG)
SanityManager.ASSERT(row.nColumns() == COLUMN_COUNT, "Wrong size row passed to SYSTABLEPERMSRowFactory.buildDescriptor");
String tablePermsUUIDString = row.getColumn(TABLEPERMSID_COL_NUM).getString();
UUID tablePermsUUID = getUUIDFactory().recreateUUID(tablePermsUUIDString);
String tableUUIDString = row.getColumn(TABLEID_COL_NUM).getString();
UUID tableUUID = getUUIDFactory().recreateUUID(tableUUIDString);
String selectPriv = row.getColumn(SELECTPRIV_COL_NUM).getString();
String deletePriv = row.getColumn(DELETEPRIV_COL_NUM).getString();
String insertPriv = row.getColumn(INSERTPRIV_COL_NUM).getString();
String updatePriv = row.getColumn(UPDATEPRIV_COL_NUM).getString();
String referencesPriv = row.getColumn(REFERENCESPRIV_COL_NUM).getString();
String triggerPriv = row.getColumn(TRIGGERPRIV_COL_NUM).getString();
if (SanityManager.DEBUG) {
SanityManager.ASSERT("y".equals(selectPriv) || "Y".equals(selectPriv) || "N".equals(selectPriv), "Invalid SYSTABLEPERMS.selectPriv column value: " + selectPriv);
SanityManager.ASSERT("y".equals(deletePriv) || "Y".equals(deletePriv) || "N".equals(deletePriv), "Invalid SYSTABLEPERMS.deletePriv column value: " + deletePriv);
SanityManager.ASSERT("y".equals(insertPriv) || "Y".equals(insertPriv) || "N".equals(insertPriv), "Invalid SYSTABLEPERMS.insertPriv column value: " + insertPriv);
SanityManager.ASSERT("y".equals(updatePriv) || "Y".equals(updatePriv) || "N".equals(updatePriv), "Invalid SYSTABLEPERMS.updatePriv column value: " + updatePriv);
SanityManager.ASSERT("y".equals(referencesPriv) || "Y".equals(referencesPriv) || "N".equals(referencesPriv), "Invalid SYSTABLEPERMS.referencesPriv column value: " + referencesPriv);
SanityManager.ASSERT("y".equals(triggerPriv) || "Y".equals(triggerPriv) || "N".equals(triggerPriv), "Invalid SYSTABLEPERMS.triggerPriv column value: " + triggerPriv);
}
TablePermsDescriptor tabPermsDesc = new TablePermsDescriptor(dataDictionary, getAuthorizationID(row, GRANTEE_COL_NUM), getAuthorizationID(row, GRANTOR_COL_NUM), tableUUID, selectPriv, deletePriv, insertPriv, updatePriv, referencesPriv, triggerPriv);
tabPermsDesc.setUUID(tablePermsUUID);
return tabPermsDesc;
}
use of org.apache.derby.iapi.sql.dictionary.TablePermsDescriptor in project derby by apache.
the class SYSTABLEPERMSRowFactory method buildIndexKeyRow.
/**
* builds a key row given for a given index number.
*/
public ExecIndexRow buildIndexKeyRow(int indexNumber, PermissionsDescriptor perm) throws StandardException {
ExecIndexRow row = null;
switch(indexNumber) {
case GRANTEE_TABLE_GRANTOR_INDEX_NUM:
// RESOLVE We do not support the FOR GRANT OPTION, so table permission rows are unique on the
// grantee and table UUID columns. The grantor column will always have the name of the owner of the
// table. So the index key, used for searching the index, only has grantee and table UUID columns.
// It does not have a grantor column.
//
// If we support FOR GRANT OPTION then there may be multiple table permissions rows for a
// (grantee, tableID) combination. We must either handle the multiple rows, which is necessary for
// checking permissions, or add a grantor column to the key, which is necessary for granting or revoking
// permissions.
row = getExecutionFactory().getIndexableRow(2);
row.setColumn(1, getAuthorizationID(perm.getGrantee()));
String tableUUIDStr = ((TablePermsDescriptor) perm).getTableUUID().toString();
row.setColumn(2, new SQLChar(tableUUIDStr));
break;
case TABLEPERMSID_INDEX_NUM:
row = getExecutionFactory().getIndexableRow(1);
String tablePermsUUIDStr = perm.getObjectID().toString();
row.setColumn(1, new SQLChar(tablePermsUUIDStr));
break;
case TABLEID_INDEX_NUM:
row = getExecutionFactory().getIndexableRow(1);
tableUUIDStr = ((TablePermsDescriptor) perm).getTableUUID().toString();
row.setColumn(1, new SQLChar(tableUUIDStr));
break;
}
return row;
}
use of org.apache.derby.iapi.sql.dictionary.TablePermsDescriptor in project derby by apache.
the class SYSTABLEPERMSRowFactory method removePermissions.
// end of orOnePermission
/**
* Remove a set of permissions from a row from this catalog table
*
* @param row an existing row
* @param perm a permission descriptor of the appropriate class for this PermissionsCatalogRowFactory class.
* @param colsChanged An array with one element for each column in row. It is updated to
* indicate which columns in row were changed
*
* @return -1 if there are no permissions left in the row, otherwise the number of columns that were changed.
*
* @exception StandardException standard error policy
*/
public int removePermissions(ExecRow row, PermissionsDescriptor perm, boolean[] colsChanged) throws StandardException {
TablePermsDescriptor tablePerms = (TablePermsDescriptor) perm;
int changeCount = 0;
boolean permissionsLeft = (removeOnePermission(row, colsChanged, SELECTPRIV_COL_NUM, tablePerms.getSelectPriv()) | removeOnePermission(row, colsChanged, DELETEPRIV_COL_NUM, tablePerms.getDeletePriv()) | removeOnePermission(row, colsChanged, INSERTPRIV_COL_NUM, tablePerms.getInsertPriv()) | removeOnePermission(row, colsChanged, UPDATEPRIV_COL_NUM, tablePerms.getUpdatePriv()) | removeOnePermission(row, colsChanged, REFERENCESPRIV_COL_NUM, tablePerms.getReferencesPriv()) | removeOnePermission(row, colsChanged, TRIGGERPRIV_COL_NUM, tablePerms.getTriggerPriv()));
if (!permissionsLeft)
return -1;
for (int i = 0; i < colsChanged.length; i++) {
if (colsChanged[i])
changeCount++;
}
return changeCount;
}
use of org.apache.derby.iapi.sql.dictionary.TablePermsDescriptor in project derby by apache.
the class SYSTABLEPERMSRowFactory method orPermissions.
/**
* Or a set of permissions in with a row from this catalog table
*
* @param row an existing row
* @param perm a permission descriptor of the appropriate class for this PermissionsCatalogRowFactory class.
* @param colsChanged An array with one element for each column in row. It is updated to
* indicate which columns in row were changed
*
* @return The number of columns that were changed.
*
* @exception StandardException standard error policy
*/
public int orPermissions(ExecRow row, PermissionsDescriptor perm, boolean[] colsChanged) throws StandardException {
TablePermsDescriptor tablePerms = (TablePermsDescriptor) perm;
int changeCount = 0;
changeCount += orOnePermission(row, colsChanged, SELECTPRIV_COL_NUM, tablePerms.getSelectPriv());
changeCount += orOnePermission(row, colsChanged, DELETEPRIV_COL_NUM, tablePerms.getDeletePriv());
changeCount += orOnePermission(row, colsChanged, INSERTPRIV_COL_NUM, tablePerms.getInsertPriv());
changeCount += orOnePermission(row, colsChanged, UPDATEPRIV_COL_NUM, tablePerms.getUpdatePriv());
changeCount += orOnePermission(row, colsChanged, REFERENCESPRIV_COL_NUM, tablePerms.getReferencesPriv());
changeCount += orOnePermission(row, colsChanged, TRIGGERPRIV_COL_NUM, tablePerms.getTriggerPriv());
return changeCount;
}
use of org.apache.derby.iapi.sql.dictionary.TablePermsDescriptor in project derby by apache.
the class SYSTABLEPERMSRowFactory method makeRow.
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
UUID oid;
DataValueDescriptor grantee = null;
DataValueDescriptor grantor = null;
String tablePermID = null;
String tableID = null;
String selectPriv = null;
String deletePriv = null;
String insertPriv = null;
String updatePriv = null;
String referencesPriv = null;
String triggerPriv = null;
if (td == null) {
grantee = getNullAuthorizationID();
grantor = getNullAuthorizationID();
} else {
TablePermsDescriptor tpd = (TablePermsDescriptor) td;
oid = tpd.getUUID();
if (oid == null) {
oid = getUUIDFactory().createUUID();
tpd.setUUID(oid);
}
tablePermID = oid.toString();
grantee = getAuthorizationID(tpd.getGrantee());
grantor = getAuthorizationID(tpd.getGrantor());
tableID = tpd.getTableUUID().toString();
selectPriv = tpd.getSelectPriv();
deletePriv = tpd.getDeletePriv();
insertPriv = tpd.getInsertPriv();
updatePriv = tpd.getUpdatePriv();
referencesPriv = tpd.getReferencesPriv();
triggerPriv = tpd.getTriggerPriv();
}
ExecRow row = getExecutionFactory().getValueRow(COLUMN_COUNT);
row.setColumn(TABLEPERMSID_COL_NUM, new SQLChar(tablePermID));
row.setColumn(GRANTEE_COL_NUM, grantee);
row.setColumn(GRANTOR_COL_NUM, grantor);
row.setColumn(TABLEID_COL_NUM, new SQLChar(tableID));
row.setColumn(SELECTPRIV_COL_NUM, new SQLChar(selectPriv));
row.setColumn(DELETEPRIV_COL_NUM, new SQLChar(deletePriv));
row.setColumn(INSERTPRIV_COL_NUM, new SQLChar(insertPriv));
row.setColumn(UPDATEPRIV_COL_NUM, new SQLChar(updatePriv));
row.setColumn(REFERENCESPRIV_COL_NUM, new SQLChar(referencesPriv));
row.setColumn(TRIGGERPRIV_COL_NUM, new SQLChar(triggerPriv));
return row;
}
Aggregations