Search in sources :

Example 6 with LanguageConnectionContext

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);
    }
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) TransactionController(org.apache.derby.iapi.store.access.TransactionController) UserDescriptor(org.apache.derby.iapi.sql.dictionary.UserDescriptor)

Example 7 with LanguageConnectionContext

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);
        }
    }
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary)

Example 8 with LanguageConnectionContext

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);
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) TableNameInfo(org.apache.derby.impl.services.locks.TableNameInfo) Latch(org.apache.derby.iapi.services.locks.Latch) LockFactory(org.apache.derby.iapi.services.locks.LockFactory)

Example 9 with LanguageConnectionContext

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);
    }
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext)

Example 10 with LanguageConnectionContext

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;
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) TransactionInfo(org.apache.derby.iapi.store.access.TransactionInfo)

Aggregations

LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)126 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)57 TransactionController (org.apache.derby.iapi.store.access.TransactionController)47 StandardException (org.apache.derby.shared.common.error.StandardException)36 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)20 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)20 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)20 UUID (org.apache.derby.catalog.UUID)14 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)13 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)11 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)10 StatementContext (org.apache.derby.iapi.sql.conn.StatementContext)7 ReferencedKeyConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ReferencedKeyConstraintDescriptor)7 RoleGrantDescriptor (org.apache.derby.iapi.sql.dictionary.RoleGrantDescriptor)7 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)6 SQLException (java.sql.SQLException)5 Iterator (java.util.Iterator)5 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)5 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)5 ArrayList (java.util.ArrayList)4