You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by kr...@apache.org on 2007/05/15 13:19:27 UTC
svn commit: r538138 -
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionKeyTest.java
Author: kristwaa
Date: Tue May 15 04:19:26 2007
New Revision: 538138
URL: http://svn.apache.org/viewvc?view=rev&rev=538138
Log:
DERBY-2555: Remove use of doPrivileged in EncryptionKeyTest.
Patch file: derby-2555-1a.diff
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionKeyTest.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionKeyTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionKeyTest.java?view=diff&rev=538138&r1=538137&r2=538138
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionKeyTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/EncryptionKeyTest.java Tue May 15 04:19:26 2007
@@ -276,7 +276,7 @@
shutdown(dbName);
// Create a new database from backup.
String dbNameRestored = dbName + "Restored";
- con = getPrivilegedConnection(dbNameRestored, CORRECT_KEY,
+ con = getConnection(dbNameRestored, CORRECT_KEY,
"createFrom=" + backupDbLocation);
validateDBContents(con);
con.close();
@@ -284,7 +284,7 @@
// Try to create a new database from backup with the wrong key.
dbNameRestored = dbName + "RestoreAttemptedWrongKey";
try {
- con = getPrivilegedConnection(dbNameRestored, WRONG_KEY,
+ con = getConnection(dbNameRestored, WRONG_KEY,
"createFrom=" + backupDbLocation);
fail("Created database from encrypted backup with wrong key.");
} catch (SQLException sqle) {
@@ -295,7 +295,7 @@
// Try to create a new database from backup with an invalid key.
dbNameRestored = dbName + "RestoreAttemptedInvalidKey";
try {
- con = getPrivilegedConnection(dbNameRestored, INVALID_CHAR_KEY,
+ con = getConnection(dbNameRestored, INVALID_CHAR_KEY,
"createFrom=" + backupDbLocation);
fail("Created database from encrypted backup with an invalid key.");
} catch (SQLException sqle) {
@@ -306,7 +306,7 @@
// Try to create a new database from backup with an odd length key.
dbNameRestored = dbName + "RestoreAttemptedOddLengthKey";
try {
- con = getPrivilegedConnection(dbNameRestored, ODD_LENGTH_KEY,
+ con = getConnection(dbNameRestored, ODD_LENGTH_KEY,
"createFrom=" + backupDbLocation);
fail("Created db from encrypted backup with an odd length key.");
} catch (SQLException sqle) {
@@ -332,7 +332,7 @@
assertTrue(con.isClosed());
// Create a new database from backup again.
dbNameRestored = dbName + "RestoredOnceMore";
- con = getPrivilegedConnection(dbNameRestored, CORRECT_KEY,
+ con = getConnection(dbNameRestored, CORRECT_KEY,
"createFrom=" + backupDbLocation);
validateDBContents(con);
con.close();
@@ -376,7 +376,7 @@
// the existing database we are trying to restore to/into. This is
// expected behavior currently, but should maybe change?
try {
- con = getPrivilegedConnection(dbNameRestored, INVALID_CHAR_KEY,
+ con = getConnection(dbNameRestored, INVALID_CHAR_KEY,
";restoreFrom=" + obtainDbName(dbName, null));
fail("Restored database with an invalid key.");
} catch (SQLException sqle) {
@@ -486,7 +486,7 @@
shutdown(sourceDb);
confirmNonBootedDB(sourceDb);
// Use the restoreFrom attribute.
- con = getPrivilegedConnection(targetDb, CORRECT_KEY,
+ con = getConnection(targetDb, CORRECT_KEY,
";restoreFrom=" + obtainDbName(sourceDb, "backups"));
validateDBContents(con);
con.close();
@@ -521,39 +521,6 @@
private Connection getConnection(String dbName, int keyMode)
throws SQLException {
return getConnection(dbName, keyMode, null);
- }
-
- /**
- * Try to establish a connection to the named database with the
- * specified type of key and recovery mode.
- * <p>
- * The connection is made in a privileged block of code to allow Derby to
- * read the database backup used for recovery.
- *
- * @param dbName name of the database
- * @param keyMode what kind of key to use (correct, wrong, invalid, odd)
- * @param recoveryAttribute attribute to recover a database from a backup,
- * for instance <code>createFrom</code> or <code>restoreFrom</code>.
- * Both the attribute and its value is expected.
- * @return A connection to the database.
- * @throws SQLException if connection fails
- */
- private Connection getPrivilegedConnection(final String dbName,
- final int keyMode,
- final String recoveryAttribute)
- throws SQLException {
- try {
- return (Connection)AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
- public Object run()
- throws SQLException {
- return getConnection(dbName, keyMode,
- recoveryAttribute);
- }
- });
- } catch (PrivilegedActionException pae) {
- throw (SQLException)pae.getException();
- }
}
/**