db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From be...@apache.org
Subject svn commit: r543435 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/Connection.java client/org/apache/derby/jdbc/ClientBaseDataSource.java testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java
Date Fri, 01 Jun 2007 09:08:56 GMT
Author: bernt
Date: Fri Jun  1 02:08:54 2007
New Revision: 543435

URL: http://svn.apache.org/viewvc?view=rev&rev=543435
Log:
DERBY-2273 Implement SSL flag in datasource objects. Code changes

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java?view=diff&rev=543435&r1=543434&r2=543435
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java Fri Jun  1
02:08:54 2007
@@ -139,7 +139,7 @@
     public org.apache.derby.jdbc.ClientBaseDataSource dataSource_;
     public String serverNameIP_;
     public int portNumber_;
-    public int clientSSLMode_ = org.apache.derby.jdbc.ClientBaseDataSource.SSL_OFF;
+    public int clientSSLMode_ = ClientBaseDataSource.SSL_OFF;
 
     public java.util.Hashtable clientCursorNameCache_ = new java.util.Hashtable();
     public boolean canUseCachedConnectBytes_ = false;
@@ -212,11 +212,14 @@
         serverNameIP_ = dataSource.getServerName();
         portNumber_ = dataSource.getPortNumber();
 
+        clientSSLMode_ = 
+            ClientBaseDataSource.getSSLModeFromString(dataSource.getSsl());
+
         agent_ = newAgent_(logWriter,
                 loginTimeout_,
                 serverNameIP_,
                 portNumber_,
-                0 /*TODO: SSL & Datasource*/);
+                clientSSLMode_);
     }
 
     // For jdbc 2 connections
@@ -241,11 +244,14 @@
         serverNameIP_ = dataSource.getServerName();
         portNumber_ = dataSource.getPortNumber();
 
+        clientSSLMode_ = 
+            ClientBaseDataSource.getSSLModeFromString(dataSource.getSsl());
+
         agent_ = newAgent_(logWriter,
                 loginTimeout_,
                 serverNameIP_,
                 portNumber_,
-                0 /*TODO: SSL & Datasource*/);
+                clientSSLMode_);
     }
 
     // This is a callback method, called by subsystem - NetConnection

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java?view=diff&rev=543435&r1=543434&r2=543435
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java Fri Jun
 1 02:08:54 2007
@@ -175,10 +175,8 @@
     public final static int SSL_OFF = 0;
     public final static int SSL_BASIC = 1;
     public final static int SSL_PEER_AUTHENTICATION = 2;
-    
-    public static final int getClientSSLMode(Properties properties)
-    {
-        String s = properties.getProperty(Attribute.SSL_ATTR);
+
+    public static final int getSSLModeFromString(String s) {
 		if (s != null){
 			if (s.equalsIgnoreCase("off")) {
 				return SSL_OFF;
@@ -195,6 +193,11 @@
 			return SSL_OFF;
 		}
     }
+    
+    public static final int getClientSSLMode(Properties properties)
+    {
+        return getSSLModeFromString(properties.getProperty(Attribute.SSL_ATTR));
+    }
 
     // ---------------------------- user -----------------------------------
     //
@@ -854,6 +857,30 @@
         return securityMechanism;
     }
 
+    // ----------------------- ssl
+
+    private int sslMode;
+
+    public void setSsl(String mode) {
+        sslMode = getSSLModeFromString(mode);
+    }
+
+    public void setSsl(int mode) {
+        sslMode = mode;
+    }
+
+    public String getSsl() {
+        switch(sslMode) {
+        case SSL_OFF: 
+        default: 
+            return "off";
+        case SSL_BASIC: 
+            return "basic";
+        case SSL_PEER_AUTHENTICATION: 
+            return "peerAuthentication";
+        }
+    }
+
     // ----------------------- set/getCreate/ShutdownDatabase ---------------------------
     /**
      * Set to true if the database should be created.
@@ -1041,6 +1068,9 @@
         }
         if (prop.containsKey(Attribute.CLIENT_RETIEVE_MESSAGE_TEXT)) {
             setRetrieveMessageText(getRetrieveMessageText(prop));
+        }
+        if (prop.containsKey(Attribute.SSL_ATTR)) {
+            setSsl(getClientSSLMode(prop));
         }
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java?view=diff&rev=543435&r1=543434&r2=543435
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java
Fri Jun  1 02:08:54 2007
@@ -76,7 +76,8 @@
          {"portNumber", "tmpportno"},
          {"retrieveMessageText", "true"},
          {"securityMechanism", "4"},
-         {"serverName", "tmphostName"}, null, null, null, 
+         {"serverName", "tmphostName"}, null, 
+         {"ssl","off"}, null, null, 
          {"traceFileAppend", "false"},
          {"traceLevel", "-1"},
          {"user", "tmpUserName"}},
@@ -92,6 +93,7 @@
          {"securityMechanism", "1805"},
          {"serverName", "XX_serverName_1048"},
          {"shutdownDatabase", "shutdown"},
+         {"ssl","basic"},
          {"traceDirectory", "XX_traceDirectory_1476"},
          {"traceFile", "XX_traceFile_911"},
          {"traceFileAppend", "true"},
@@ -156,7 +158,7 @@
                 String.valueOf(TestConfiguration.getCurrent().getPort());
             expectedValues[expectedArrayIndex][10][1] =
                 TestConfiguration.getCurrent().getHostName();
-            expectedValues[expectedArrayIndex][16][1] =
+            expectedValues[expectedArrayIndex][17][1] =
                 TestConfiguration.getCurrent().getUserName();
         }
         
@@ -239,6 +241,8 @@
                     value = "create";
                 else if (property.equals("shutdownDatabase"))
                     value = "shutdown";
+                else if (property.equals("ssl"))
+                    value = "basic";
                 else
                     value = "XX_" + property + "_" + val;
                     



Mime
View raw message