db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r753177 - /db/derby/code/branches/10.4/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
Date Fri, 13 Mar 2009 09:03:34 GMT
Author: kristwaa
Date: Fri Mar 13 09:03:33 2009
New Revision: 753177

URL: http://svn.apache.org/viewvc?rev=753177&view=rev
Log:
DERBY-4073: Creation/configuration of ClientXDataSource fails because of two setSsl methods.
Merged fix from trunk (revision 753176).

Modified:
    db/derby/code/branches/10.4/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java

Modified: db/derby/code/branches/10.4/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java?rev=753177&r1=753176&r2=753177&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
(original)
+++ db/derby/code/branches/10.4/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
Fri Mar 13 09:03:33 2009
@@ -173,25 +173,48 @@
 
     //---------------------- client SSL ----------------
 
+    /** The constant indicating that SSL encryption won't be used. */
     public final static int SSL_OFF = 0;
+    private final static String SSL_OFF_STR = "off";
+    /** The constant indicating that SSL encryption will be used. */
     public final static int SSL_BASIC = 1;
+    private final static String SSL_BASIC_STR = "basic";
+    /**
+     * The constant indicating that SSL encryption with peer authentication
+     * will be used.
+     */
     public final static int SSL_PEER_AUTHENTICATION = 2;
+    private final static String SSL_PEER_AUTHENTICATION_STR =
+            "peerAuthentication";
 
+    /**
+     * Parses the string and returns the corresponding constant for the SSL
+     * mode denoted.
+     * <p>
+     * Valid values are <tt>off</tt>, <tt>basic</tt> and
+     * <tt>peerAuthentication</tt>.
+     *
+     * @param s string denoting the SSL mode
+     * @return A constant indicating the SSL mode denoted by the string. If the
+     *      string is {@code null}, {@link #SSL_OFF} is returned.
+     * @throws SqlException if the string has an invalid value
+     */
     public static final int getSSLModeFromString(String s) 
         throws SqlException
     {
         
 		if (s != null){
-			if (s.equalsIgnoreCase("off")) {
+			if (s.equalsIgnoreCase(SSL_OFF_STR)) {
 				return SSL_OFF;
-            } else if (s.equalsIgnoreCase("basic")) {
+            } else if (s.equalsIgnoreCase(SSL_BASIC_STR)) {
 				return SSL_BASIC;
-			} else if (s.equalsIgnoreCase("peerAuthentication")) {
+			} else if (s.equalsIgnoreCase(SSL_PEER_AUTHENTICATION_STR)) {
 				return SSL_PEER_AUTHENTICATION;
 			} else {
-                throw new SqlException(null, 
-                                       new ClientMessageId(SQLState.INVALID_ATTRIBUTE),
-                                       Attribute.SSL_ATTR, s, "off, basic, peerAuthentication");
+                throw new SqlException(null,
+                        new ClientMessageId(SQLState.INVALID_ATTRIBUTE),
+                        Attribute.SSL_ATTR, s, SSL_OFF_STR + ", " +
+                        SSL_BASIC_STR + ", " + SSL_PEER_AUTHENTICATION_STR);
 			}
 		} else {
 			// Default
@@ -199,6 +222,15 @@
 		}
     }
     
+    /**
+     * Returns the SSL mode specified by the property object.
+     *
+     * @param properties data source properties
+     * @return A constant indicating the SSL mode to use. Defaults to
+     *      {@link #SSL_OFF} if the SSL attribute isn't specified.
+     * @throws SqlException if an invalid value for the SSL mode is specified
+     *      in the property object
+     */
     public static final int getClientSSLMode(Properties properties)
         throws SqlException
     {
@@ -877,25 +909,36 @@
 
     private int sslMode;
 
+    /**
+     * Specifices the SSL encryption mode to use.
+     * <p>
+     * Valid values are <tt>off</tt>, <tt>basic</tt> and
+     * <tt>peerAuthentication</tt>.
+     *
+     * @param mode the SSL mode to use (<tt>off</tt>, <tt>basic</tt>
or
+     *      <tt>peerAuthentication</tt>)
+     * @throws SqlException if the specified mode is invalid
+     */
     public void setSsl(String mode) 
         throws SqlException
     {
         sslMode = getSSLModeFromString(mode);
     }
 
-    public void setSsl(int mode) {
-        sslMode = mode;
-    }
-
+    /**
+     * Returns the SSL encryption mode specified for the data source.
+     *
+     * @return <tt>off</tt>, <tt>basic</tt> or <tt>peerAuthentication</tt>.
+     */
     public String getSsl() {
         switch(sslMode) {
         case SSL_OFF: 
         default: 
-            return "off";
+            return SSL_OFF_STR;
         case SSL_BASIC: 
-            return "basic";
+            return SSL_BASIC_STR;
         case SSL_PEER_AUTHENTICATION: 
-            return "peerAuthentication";
+            return SSL_PEER_AUTHENTICATION_STR;
         }
     }
 
@@ -1108,7 +1151,7 @@
             setRetrieveMessageText(getRetrieveMessageText(prop));
         }
         if (prop.containsKey(Attribute.SSL_ATTR)) {
-            setSsl(getClientSSLMode(prop));
+            sslMode = getClientSSLMode(prop);
         }
     }
 }



Mime
View raw message