use of org.apache.derby.iapi.sql.conn.Authorizer in project derby by apache.
the class SystemProcedures method setDatabaseProperty.
private static void setDatabaseProperty(String key, String value, Securable authorizationCheck) throws SQLException {
LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
try {
if (authorizationCheck != null) {
SecurityUtil.authorize(authorizationCheck);
}
Authorizer a = lcc.getAuthorizer();
a.authorize((Activation) null, Authorizer.PROPERTY_WRITE_OP);
// Get the current transaction controller
TransactionController tc = lcc.getTransactionExecute();
tc.setProperty(key, value, false);
} catch (StandardException se) {
throw PublicAPI.wrapStandardException(se);
}
}
use of org.apache.derby.iapi.sql.conn.Authorizer in project derby by apache.
the class PropertyInfo method setDatabaseProperty.
/**
* Set or delete the value of a property of the database on the current connection.
* For security reasons (see DERBY-6616), this code is duplicated in SystemProcedures.
*
* @param key the property key
* @param value the new value, if null the property is deleted.
*
* @exception SQLException on error
*/
public static void setDatabaseProperty(String key, String value) throws SQLException {
LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
try {
SecurityUtil.authorize(Securable.SET_DATABASE_PROPERTY);
Authorizer a = lcc.getAuthorizer();
a.authorize((Activation) null, Authorizer.PROPERTY_WRITE_OP);
// Get the current transaction controller
TransactionController tc = lcc.getTransactionExecute();
tc.setProperty(key, value, false);
} catch (StandardException se) {
throw PublicAPI.wrapStandardException(se);
}
}
use of org.apache.derby.iapi.sql.conn.Authorizer in project derby by apache.
the class SecurityUtil method authorize.
/**
* Raise an exception if the current user does not have permission
* to perform the indicated operation.
*/
public static void authorize(Securable operation) throws StandardException {
LanguageConnectionContext lcc = (LanguageConnectionContext) getContextOrNull(LanguageConnectionContext.CONTEXT_ID);
if (lcc.usesSqlAuthorization()) {
Authorizer authorizer = lcc.getAuthorizer();
DataDictionary dd = lcc.getDataDictionary();
AliasDescriptor ad = dd.getRoutineList(operation.routineSchemaID, operation.routineName, operation.routineType).get(0);
ArrayList<StatementPermission> requiredPermissions = new ArrayList<StatementPermission>();
StatementRoutinePermission executePermission = new StatementRoutinePermission(ad.getObjectID());
requiredPermissions.add(executePermission);
authorizer.authorize(requiredPermissions, lcc.getLastActivation());
}
}
Aggregations