use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.
the class SystemProcedures method resetAuthorizationIDPassword.
/**
* Reset the password for an already normalized authorization id.
*/
private static void resetAuthorizationIDPassword(String userName, String password) throws SQLException {
try {
LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
DataDictionary dd = lcc.getDataDictionary();
TransactionController tc = lcc.getTransactionExecute();
checkLegalUser(dd, userName);
/*
** Inform the data dictionary that we are about to write to it.
** There are several calls to data dictionary "get" methods here
** that might be done in "read" mode in the data dictionary, but
** it seemed safer to do this whole operation in "write" mode.
**
** We tell the data dictionary we're done writing at the end of
** the transaction.
*/
dd.startWriting(lcc);
UserDescriptor userDescriptor = makeUserDescriptor(dd, tc, userName, password);
dd.updateUser(userDescriptor, tc);
} catch (StandardException se) {
throw PublicAPI.wrapStandardException(se);
}
}
use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.
the class DiagUtil method checkAccess.
/**
* Raise an exception if we are running with SQL authorization turned on
* but the current user isn't the database owner. This method is used
* to restrict access to VTIs which disclose sensitive information.
* See DERBY-5395.
*/
static void checkAccess() throws StandardException {
LanguageConnectionContext lcc = (LanguageConnectionContext) getContextOrNull(LanguageConnectionContext.CONTEXT_ID);
DataDictionary dd = lcc.getDataDictionary();
if (dd.usesSqlAuthorization()) {
String databaseOwner = dd.getAuthorizationDatabaseOwner();
String currentUser = lcc.getStatementContext().getSQLSessionContext().getCurrentUser();
if (!databaseOwner.equals(currentUser)) {
throw StandardException.newException(SQLState.DBO_ONLY);
}
}
}
use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.
the class LockTable method next.
/**
* @see java.sql.ResultSet#next
* @exception SQLException if no transaction context can be found, or other
* Derby internal errors are encountered.
*/
public boolean next() throws SQLException {
try {
if (!initialized) {
LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
tc = lcc.getTransactionExecute();
LockFactory lf = tc.getAccessManager().getLockFactory();
lockTable = lf.makeVirtualLockTable();
initialized = true;
tabInfo = new TableNameInfo(lcc, true);
}
currentRow = null;
if (lockTable != null) {
while (lockTable.hasMoreElements() && (currentRow == null)) {
currentRow = dumpLock((Latch) lockTable.nextElement());
}
}
} catch (StandardException se) {
throw PublicAPI.wrapStandardException(se);
}
return (currentRow != null);
}
use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.
the class ConglomInfo method next.
/**
* @see java.sql.ResultSet#next
* @exception SQLException if no transaction context can be found
*/
public boolean next() throws SQLException {
try {
if (!initialized) {
LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
tc = lcc.getTransactionExecute();
getConglomInfo(lcc);
initialized = true;
currentRow = -1;
}
if (conglomTable == null)
return false;
currentRow++;
if (currentRow >= conglomTable.length)
return false;
spaceInfo = null;
getSpaceInfo(currentRow);
return true;
} catch (StandardException se) {
throw PublicAPI.wrapStandardException(se);
}
}
use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.
the class TransactionTable method next.
/**
* @see java.sql.ResultSet#next
* @exception SQLException if no transaction context can be found
*/
public boolean next() throws SQLException {
if (!initialized) {
LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
transactionTable = lcc.getTransactionExecute().getAccessManager().getTransactionInfo();
initialized = true;
currentRow = -1;
}
if (transactionTable == null)
return false;
for (currentRow++; currentRow < transactionTable.length; currentRow++) {
TransactionInfo info = transactionTable[currentRow];
if (info == null)
// transaction object in flux while the
continue;
// snap shot was taken, get another row
return true;
}
// currentRow >= transactionTable.length
transactionTable = null;
return false;
}
Aggregations