db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r570752 - in /db/derby/code/branches/10.3/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 11:09:12 GMT
Author: kahatlen
Date: Wed Aug 29 04:08:54 2007
New Revision: 570752

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

Merged fix from trunk (rev 570663).

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

Modified: db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=570752&r1=570751&r2=570752&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Wed
Aug 29 04:08:54 2007
@@ -1231,7 +1231,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/branches/10.3/java/engine/org/apache/derby/iapi/reference/Attribute.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/reference/Attribute.java?rev=570752&r1=570751&r2=570752&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/reference/Attribute.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/reference/Attribute.java
Wed Aug 29 04:08:54 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/branches/10.3/java/engine/org/apache/derby/impl/jdbc/authentication/BasicAuthenticationServiceImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/authentication/BasicAuthenticationServiceImpl.java?rev=570752&r1=570751&r2=570752&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/authentication/BasicAuthenticationServiceImpl.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/authentication/BasicAuthenticationServiceImpl.java
Wed Aug 29 04:08:54 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/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java?rev=570752&r1=570751&r2=570752&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
Wed Aug 29 04:08:54 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