db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r596774 - in /db/derby/code/branches/10.3/java: engine/org/apache/derby/iapi/util/IdUtil.java engine/org/apache/derby/iapi/util/StringUtil.java testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
Date Tue, 20 Nov 2007 18:41:08 GMT
Author: djd
Date: Tue Nov 20 10:41:07 2007
New Revision: 596774

URL: http://svn.apache.org/viewvc?rev=596774&view=rev
Log:
DERBY-3147 Merge remaining fixes from trunk 589902 590730 591401

Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/util/IdUtil.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/util/StringUtil.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/util/IdUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/util/IdUtil.java?rev=596774&r1=596773&r2=596774&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/util/IdUtil.java (original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/util/IdUtil.java Tue Nov
20 10:41:07 2007
@@ -128,9 +128,7 @@
 	}
 
     /**
-c
-    
-    @param s The string to be parsed
+    @param r The multi-part identifier to be parsed
     @return An array of strings made by breaking the input string at its dots, '.'.
       @exception StandardException Oops
       */
@@ -205,7 +203,7 @@
 			if (c == '"')
 				return parseQId(r,normalize);
 			else
-				return parseUnQId(r,normalize, true);
+				return parseUnQId(r,normalize);
 		}
 
 		catch (IOException ioe){
@@ -220,13 +218,12 @@
      * 
      * @param r Regular identifier to parse.
      * @param normalize If true return the identifer converted to a single case, otherwise
return the identifier as entered.
-     * @param normalizeToUpper
      * @return the value of the identifer or a delimited identifier
      * @throws IOException Error accessing value
      * @throws StandardException Error parsing identifier.
  
      */
-	private static String parseUnQId(StringReader r, boolean normalize, boolean normalizeToUpper)
+	private static String parseUnQId(StringReader r, boolean normalize)
 		 throws IOException,StandardException
 	{
 		StringBuffer b = new StringBuffer();
@@ -242,11 +239,13 @@
 				break;
 		}
 		if (c != -1) r.reset();
+        
+        String id = b.toString();
 
 		if (normalize)
-			return normalizeToUpper ? StringUtil.SQLToUpperCase(b.toString()) : StringUtil.SQLToLowerCase(b.toString());
+			return StringUtil.SQLToUpperCase(id);
 		else
-			return b.toString();
+			return id;
 	}
 
 
@@ -305,6 +304,11 @@
 			return normalToDelimited(b.toString()); //Put the quotes back.
 	}
 
+    /**
+     * Verify the read is empty (no more characters in its stream).
+     * @param r
+     * @throws StandardException
+     */
 	private static void verifyEmpty(java.io.Reader r)
 		 throws StandardException
 	{
@@ -407,7 +411,7 @@
 		if (p==null) return null;
 		StringReader r = new StringReader(p);
 		String[] result = parseIdList(r, true);
-		verifyListEmpty(r);
+		verifyEmpty(r);
 		return result;
 	}
 	
@@ -597,21 +601,6 @@
 			sb.append(externalIds[ix]);
 		}
 		return sb.toString();
-	}
-
-	private static void verifyListEmpty(StringReader r)
-		 throws StandardException
-	{
-		try {
-			if (r.read() != -1)
-				throw StandardException.newException(SQLState.ID_LIST_PARSE_ERROR);
-		}
-
-		catch (IOException ioe){
-			throw StandardException.newException(SQLState.ID_LIST_PARSE_ERROR,ioe);
-		}
-		
-
 	}
 
 	/**

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/util/StringUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/util/StringUtil.java?rev=596774&r1=596773&r2=596774&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/util/StringUtil.java (original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/util/StringUtil.java Tue
Nov 20 10:41:07 2007
@@ -343,19 +343,6 @@
 			return s.toUpperCase(Locale.ENGLISH);
 	}
 
-
-	/** Convert string to lowercase
-	 *  Return java.util.Locale.ENGLISH lowercasing
-	 * @param s string to lowercase
-	 * @return lowercased string
-	 */
-	public static String SQLToLowerCase(String s)
-	{
-		return s.toLowerCase(Locale.ENGLISH);
-
-	}
-
-
 	/** Compares two strings 
 	 * Strings will be uppercased in english and compared
 	 * equivalent to s1.equalsIgnoreCase(s2)

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java?rev=596774&r1=596773&r2=596774&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AuthenticationTest.java
Tue Nov 20 10:41:07 2007
@@ -202,6 +202,99 @@
             }
             
         }
+        
+        // Now test that setting the user connection authorizaton
+        // with the various names works correctly. Use the first user
+        // to set the access on others to avoid setting a user to read-only
+        // and then not being able to reset it.
+        
+        PreparedStatement psGetAccess = prepareStatement(
+            "VALUES SYSCS_UTIL.SYSCS_GET_USER_ACCESS(?)");
+        CallableStatement csSetAccess = prepareCall(
+            "CALL SYSCS_UTIL.SYSCS_SET_USER_ACCESS(?, ?)"); 
+        
+        setDatabaseProperty("derby.database.fullAccessUsers",
+                USERS[0], getConnection());
+        setDatabaseProperty("derby.database.readOnlyAccessUsers",
+                null, getConnection());
+        commit();
+        
+        // Yes - skip the first user, see above.
+        for (int i = 1; i < USERS.length; i++)
+        {          
+            String jdbcUserName = USERS[i];
+            boolean delimited = jdbcUserName.charAt(0) == '"';
+            String normalUserName;
+            if (delimited)
+            {
+                normalUserName = jdbcUserName.substring(1,
+                        jdbcUserName.length() - 1);          
+            }
+            else
+            {
+                normalUserName = jdbcUserName.toUpperCase(Locale.ENGLISH);
+            }
+             
+            String password = USERS[i] + PASSWORD_SUFFIX;
+            
+            // Set the access with the database property
+            setDatabaseProperty("derby.database.readOnlyAccessUsers",
+                    jdbcUserName, getConnection());
+            commit();
+            
+            
+            Connection connUser = openDefaultConnection(jdbcUserName, password);
+            
+            // DERBY-2738 (network client always returns false for isReadOnly)
+            if (usingEmbedded())
+                assertTrue(jdbcUserName + ":isReadOnly()",
+                    connUser.isReadOnly());
+            
+            
+            connUser.close();
+            
+            psGetAccess.setString(1, normalUserName);
+            //JDBC.assertSingleValueResultSet(psGetAccess.executeQuery(),
+            //        "READONLYACCESS");
+            commit();
+            
+            // clear the property.
+            setDatabaseProperty("derby.database.readOnlyAccessUsers",
+                    null, getConnection());
+            commit();
+            
+            // Test it was reset back
+            connUser = openDefaultConnection(jdbcUserName, password);
+            assertFalse(connUser.isReadOnly());
+            connUser.close(); 
+            
+            psGetAccess.setString(1, normalUserName);
+            //JDBC.assertSingleValueResultSet(psGetAccess.executeQuery(),
+            //        "FULLACCESS");
+            commit();
+            
+            
+            // Set to be read-only via the procedure which uses
+            // the normal user name.
+            csSetAccess.setString(1, normalUserName);
+            csSetAccess.setString(2, "READONLYACCESS");
+            csSetAccess.executeUpdate();
+            commit();
+            
+            connUser = openDefaultConnection(jdbcUserName, password);
+            // DERBY-2738 (network client always returns false for isReadOnly)
+            if (usingEmbedded())
+                assertTrue(jdbcUserName + ":isReadOnly()",
+                    connUser.isReadOnly());
+
+            connUser.close();
+            
+            psGetAccess.setString(1, normalUserName);
+            //JDBC.assertSingleValueResultSet(psGetAccess.executeQuery(),
+            //        "READONLYACCESS");
+            commit();           
+
+        }
     }
     
     /**



Mime
View raw message