db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r570663 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/ engine/org/apache/derby/iapi/reference/ engine/org/apache/derby/impl/jdbc/authentication/ testing/org/apache/derbyTesting/functionTests/tests/derbynet/
Date Wed, 29 Aug 2007 07:02:03 GMT
Author: kahatlen
Date: Wed Aug 29 00:02:03 2007
New Revision: 570663

URL: http://svn.apache.org/viewvc?rev=570663&view=rev
Log:
DERBY-3025: NPE when connecting to database with securityMechanism=8

Use an internal attribute name when passing security mechanism from
the network server to the embedded driver. This prevents confusion if
an embedded connection is established with securityMechanism specified
(in which case the security mechanism should be ignored).

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/BasicAuthenticationServiceImpl.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=570663&r1=570662&r2=570663&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Wed Aug 29
00:02:03 2007
@@ -1261,7 +1261,7 @@
         if ((database.securityMechanism == CodePoint.SECMEC_USRSSBPWD) &&
             (database.dbName.indexOf(Attribute.PASSWORD_ATTR) == -1))
         {
-            p.put(Attribute.CLIENT_SECURITY_MECHANISM,
+            p.put(Attribute.DRDA_SECMEC,
                   String.valueOf(database.securityMechanism));
             p.put(Attribute.DRDA_SECTKN_IN,
                   DecryptionManager.toHexString(database.secTokenIn, 0,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java?rev=570663&r1=570662&r2=570663&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java Wed Aug
29 00:02:03 2007
@@ -237,6 +237,15 @@
      */
     String DRDA_SECTKN_IN = "drdaSecTokenIn";
     String DRDA_SECTKN_OUT = "drdaSecTokenOut";
+    /**
+     * Internal attribute which holds the value of the securityMechanism
+     * attribute specified by the client. Used for passing information about
+     * which security mechanism to use from the network server to the embedded
+     * driver. Use another name than "securityMechanism" in order to prevent
+     * confusion if an attempt is made to establish an embedded connection with
+     * securityMechanism specified (see DERBY-3025).
+     */
+    String DRDA_SECMEC = "drdaSecMec";
 
 	/**
 	 * Internal attribute. Used to always allow soft upgrade for

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/BasicAuthenticationServiceImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/BasicAuthenticationServiceImpl.java?rev=570663&r1=570662&r2=570663&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/BasicAuthenticationServiceImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/BasicAuthenticationServiceImpl.java
Wed Aug 29 00:02:03 2007
@@ -176,7 +176,7 @@
         // assess the substitute password to be legitimate for Derby's
         // BUILTIN authentication scheme/provider.
         if ((clientSecurityMechanism =
-                info.getProperty(Attribute.CLIENT_SECURITY_MECHANISM)) != null)
+                info.getProperty(Attribute.DRDA_SECMEC)) != null)
         {
             secMec = Integer.parseInt(clientSecurityMechanism);
         }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java?rev=570663&r1=570662&r2=570663&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
Wed Aug 29 00:02:03 2007
@@ -41,6 +41,7 @@
 import org.apache.derby.drda.NetworkServerControl;
 
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
 import org.apache.derbyTesting.junit.J2EEDataSource;
 import org.apache.derbyTesting.junit.JDBCDataSource;
 import org.apache.derbyTesting.junit.NetworkServerTestSetup;
@@ -173,9 +174,20 @@
     public static Test suite() 
     {
         TestSuite suite = new TestSuite("NSSecurityMechanismTest");
-        suite.addTest(new NSSecurityMechanismTest(
+
+        TestSuite clientSuite =
+            new TestSuite("NSSecurityMechanismTest - client");
+        clientSuite.addTest(new NSSecurityMechanismTest(
             "testNetworkServerSecurityMechanism"));
-        return TestConfiguration.clientServerDecorator((suite));
+        suite.addTest(TestConfiguration.clientServerDecorator(clientSuite));
+
+        // Test case for embedded mode. Enable builtin authentication.
+        suite.addTest(
+            DatabasePropertyTestSetup.builtinAuthentication(
+                new NSSecurityMechanismTest("testSecurityMechanismOnEmbedded"),
+                new String[] { "calvin" }, "pw"));
+
+        return suite;
     }
     
     public void tearDown() throws Exception {
@@ -368,7 +380,22 @@
             }
         }
     }
-    
+
+    /**
+     * Test that securityMechanism=8 is ignored by the embedded driver
+     * (DERBY-3025).
+     */
+    public void testSecurityMechanismOnEmbedded() throws SQLException {
+        DataSource ds = JDBCDataSource.getDataSource();
+        JDBCDataSource.setBeanProperty(
+            ds, "connectionAttributes", "securityMechanism=8");
+
+        // DERBY-3025: NullPointerException or AssertFailure was thrown here
+        Connection c = ds.getConnection("calvin", "calvinpw");
+
+        c.close();
+    }
+
     // returns a boolean true if the security mechanism is not supported
     // so the loop in which this is called can be continued without
     // causing unnecessary/impossible tests to be run



Mime
View raw message