db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r700295 - in /db/derby/code/trunk/java: testing/org/apache/derbyTesting/functionTests/harness/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ testing/org/apache/derbyTest...
Date Mon, 29 Sep 2008 22:43:56 GMT
Author: dag
Date: Mon Sep 29 15:43:55 2008
New Revision: 700295

URL: http://svn.apache.org/viewvc?rev=700295&view=rev
Log:
DERBY-3877 SQL roles: build support for dblook

Patch derby-3877-2, which adds basic support for roles in dblook (but
see DERBY-3884), adds test cases, and also enables the old test
harness to shutdown the server using credentials when required due to
authentication being enabled (needed by modified test for dblook).


Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_derby.properties   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_territory_derby.properties   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_derby.properties   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_territory_derby.properties   (with props)
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Roles.java   (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/NetServer.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net_territory.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net_territory.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_territory_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_territory_app.properties
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_GrantRevoke.java
    db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties
    db/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/NetServer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/NetServer.java?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/NetServer.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/NetServer.java Mon Sep 29 15:43:55 2008
@@ -43,6 +43,7 @@
     String javaCmd;
     String jvmflags;
     String framework;
+	String appsRequiredPassword;
     static String hostName;
     
     Object[] frameworkInfo;
@@ -89,6 +90,7 @@
 	     null});                                        //shutdown2
 
 	url = "jdbc:derby://" + hostName + ":1527/";  
+
 	m.put("DerbyNetClient", new Object[]
 	    {url,                 //prefix
 	     "",                                            // suffix
@@ -120,8 +122,9 @@
 	     null});
     }
 
-    public NetServer(File homeDir, String jvmName, String clPath, String 
-   	     javaCmd, String jvmflags, String framework, boolean startServer)
+    public NetServer(File homeDir, String jvmName, String clPath,
+					 String javaCmd, String jvmflags, String framework,
+					 boolean startServer, String appsRequiredPassword)
 	throws Exception
     {
 	this.homeDir = homeDir;
@@ -130,6 +133,10 @@
         this.javaCmd = javaCmd;
         this.jvmflags = jvmflags;
 	this.framework = framework;
+
+	    // if authentication is required to shutdown server we need password
+	    // for user APP (the dbo).
+    	this.appsRequiredPassword = appsRequiredPassword;
 	frameworkInfo =  (Object[]) m.get(framework);
 	
 	this.port = Integer.parseInt((String) frameworkInfo[PORT_POS]);
@@ -285,7 +292,18 @@
 	String[] stopcmd1 = (String[]) frameworkInfo[STOP_CMD1_POS];
 		if (stopcmd1 == null)
 		    return;
-		
+
+		if (appsRequiredPassword != null) {
+			String[] modifiedStopCmd = new String[stopcmd1.length + 4];
+			System.arraycopy(stopcmd1, 0, modifiedStopCmd, 0, stopcmd1.length);
+			modifiedStopCmd[stopcmd1.length]     = "-user";
+			modifiedStopCmd[stopcmd1.length + 1] = "app";
+			modifiedStopCmd[stopcmd1.length + 2] = "-password";
+			modifiedStopCmd[stopcmd1.length + 3] = appsRequiredPassword;
+			stopcmd1 = modifiedStopCmd;
+		}
+
+
 		for (int i = 0; i < stopcmd1.length; i++)
 		    connV.addElement(stopcmd1[i]);
 		
@@ -301,6 +319,7 @@
 		{
 		    stopV.addElement((String)jvmCmd.elementAt(i));
 		}
+
 		Process prconn = Runtime.getRuntime().exec(connCmd);
 		// Give the server sixty seconds to shutdown.
 		TimedProcess tp = new TimedProcess(prconn);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java Mon Sep 29 15:43:55 2008
@@ -271,7 +271,9 @@
 
         // Check for properties files, including derby.properties
         // and if needed, build the -p string to pass to the test
-        String propString = createPropString();
+        AppsRequiredPassword creds = new AppsRequiredPassword();
+        String propString = createPropString(creds);
+
         if ( (isSuiteRun == false) && (useprocess) )
         {
             SysInfoLog sysLog = new SysInfoLog();
@@ -314,11 +316,13 @@
                 }
 
                 ns = new NetServer(baseDir, jvmnetjvm, classpathServer, null,
-                                     spacedJvmFlags,framework, startServer);
+                                   spacedJvmFlags,framework, startServer,
+                                   creds.password);
             }
             else
                 ns = new NetServer(baseDir, jvmName, classpathServer, 
-                                     javaCmd, spacedJvmFlags,framework, startServer);
+                                   javaCmd, spacedJvmFlags,framework,
+                                   startServer, creds.password);
 
             //  With useprocess=true, we have a new dir for each test, and all files for
             // the test, including a clean database, go in that directory. So, network server
@@ -1297,7 +1301,7 @@
 		return jvhs;
     }
 
-    private static String createPropString()
+    private static String createPropString(AppsRequiredPassword creds)
         throws ClassNotFoundException, FileNotFoundException, IOException
     {
         // Check for existence of app properties and/or derby.properties files
@@ -1428,6 +1432,20 @@
             bos = new BufferedOutputStream(new FileOutputStream(clPropFile));
             clp.store(bos, "Derby Properties");
         	bos.close();
+
+            String auth = clp.getProperty(
+                "derby.connection.requireAuthentication");
+
+            if (auth != null && auth.equals("true")) {
+                // Look for password for user APP is supplied; useful for
+                // shutting down server in network mode. We only look for APP,
+                // since this will be the database owner.
+                String appPw = clp.getProperty("derby.user.app");
+
+                if (appPw != null) {
+                    creds.password = appPw;
+                }
+            }
         }
 
 		// --------------------------------- 
@@ -2987,6 +3005,9 @@
         }
     }
 
+    static private class AppsRequiredPassword {
+        public String password;
+    }
 }
 
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out Mon Sep 29 15:43:55 2008
@@ -1950,5 +1950,42 @@
 N
 APP
 -----
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+-----
+"eve"
+B
+APP
+N
+N
+-----
+A
+APP
+_SYSTEM
+Y
+Y
+-----
+A
+B
+APP
+N
+N
+-----
+B
+APP
+_SYSTEM
+Y
+Y
+-----
+B
+WHOMEVER
+APP
+N
+N
+-----
 Database 'wombat_new' deleted.
 [ Done. ]

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net_territory.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net_territory.out?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net_territory.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net_territory.out Mon Sep 29 15:43:55 2008
@@ -1950,5 +1950,42 @@
 N
 APP
 -----
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+-----
+"eve"
+B
+APP
+N
+N
+-----
+A
+APP
+_SYSTEM
+Y
+Y
+-----
+A
+B
+APP
+N
+N
+-----
+B
+APP
+_SYSTEM
+Y
+Y
+-----
+B
+WHOMEVER
+APP
+N
+N
+-----
 Database 'wombat_new' deleted.
 [ Done. ]

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out Mon Sep 29 15:43:55 2008
@@ -1950,5 +1950,42 @@
 N
 APP
 -----
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+-----
+"eve"
+B
+APP
+N
+N
+-----
+A
+APP
+_SYSTEM
+Y
+Y
+-----
+A
+B
+APP
+N
+N
+-----
+B
+APP
+_SYSTEM
+Y
+Y
+-----
+B
+WHOMEVER
+APP
+N
+N
+-----
 Database 'wombat_new' deleted.
 [ Done. ]

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net_territory.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net_territory.out?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net_territory.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net_territory.out Mon Sep 29 15:43:55 2008
@@ -1950,5 +1950,42 @@
 N
 APP
 -----
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+-----
+"eve"
+B
+APP
+N
+N
+-----
+A
+APP
+_SYSTEM
+Y
+Y
+-----
+A
+B
+APP
+N
+N
+-----
+B
+APP
+_SYSTEM
+Y
+Y
+-----
+B
+WHOMEVER
+APP
+N
+N
+-----
 Database 'wombat_new' deleted.
 [ Done. ]

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out Mon Sep 29 15:43:55 2008
@@ -1943,6 +1943,43 @@
 N
 APP
 ----
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+----
+"eve"
+B
+APP
+N
+N
+----
+A
+APP
+_SYSTEM
+Y
+Y
+----
+A
+B
+APP
+N
+N
+----
+B
+APP
+_SYSTEM
+Y
+Y
+----
+B
+WHOMEVER
+APP
+N
+N
+----
 --
 *******************************************
 Dumping full schema for 'wombat'
@@ -3893,6 +3930,43 @@
 N
 APP
 ----
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+----
+"eve"
+B
+APP
+N
+N
+----
+A
+APP
+_SYSTEM
+Y
+Y
+----
+A
+B
+APP
+N
+N
+----
+B
+APP
+_SYSTEM
+Y
+Y
+----
+B
+WHOMEVER
+APP
+N
+N
+----
 Database 'wombat_new' deleted.
 --
 *******************************************
@@ -4477,6 +4551,43 @@
 null
 ----
 ========== SYSVIEWS ==========
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+----
+"eve"
+B
+APP
+N
+N
+----
+A
+APP
+_SYSTEM
+Y
+Y
+----
+A
+B
+APP
+N
+N
+----
+B
+APP
+_SYSTEM
+Y
+Y
+----
+B
+WHOMEVER
+APP
+N
+N
+----
 Database 'wombat_new' deleted.
 --
 *******************************************
@@ -4723,6 +4834,43 @@
 ----
 ========== SYSTRIGGERS ==========
 ========== SYSVIEWS ==========
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+----
+"eve"
+B
+APP
+N
+N
+----
+A
+APP
+_SYSTEM
+Y
+Y
+----
+A
+B
+APP
+N
+N
+----
+B
+APP
+_SYSTEM
+Y
+Y
+----
+B
+WHOMEVER
+APP
+N
+N
+----
 Database 'wombat_new' deleted.
 --
 *******************************************
@@ -5016,6 +5164,43 @@
 N
 APP
 ----
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+----
+"eve"
+B
+APP
+N
+N
+----
+A
+APP
+_SYSTEM
+Y
+Y
+----
+A
+B
+APP
+N
+N
+----
+B
+APP
+_SYSTEM
+Y
+Y
+----
+B
+WHOMEVER
+APP
+N
+N
+----
 Database 'wombat_new' deleted.
 --
 *******************************************
@@ -5152,6 +5337,43 @@
 null
 ----
 ========== SYSVIEWS ==========
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+----
+"eve"
+B
+APP
+N
+N
+----
+A
+APP
+_SYSTEM
+Y
+Y
+----
+A
+B
+APP
+N
+N
+----
+B
+APP
+_SYSTEM
+Y
+Y
+----
+B
+WHOMEVER
+APP
+N
+N
+----
 Database 'wombat_new' deleted.
 --
 *******************************************
@@ -5188,6 +5410,7 @@
 ========== SYSTABLES ==========
 ========== SYSTRIGGERS ==========
 ========== SYSVIEWS ==========
+========== SYSROLES ==========
 Database 'wombat_new' deleted.
 -= Start dblook Message Tests =-
 Database 'wombat' deleted.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out Mon Sep 29 15:43:55 2008
@@ -1943,6 +1943,43 @@
 N
 APP
 ----
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+----
+"eve"
+B
+APP
+N
+N
+----
+A
+APP
+_SYSTEM
+Y
+Y
+----
+A
+B
+APP
+N
+N
+----
+B
+APP
+_SYSTEM
+Y
+Y
+----
+B
+WHOMEVER
+APP
+N
+N
+----
 --
 *******************************************
 Dumping full schema for 'wombat'
@@ -3893,6 +3930,43 @@
 N
 APP
 ----
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+----
+"eve"
+B
+APP
+N
+N
+----
+A
+APP
+_SYSTEM
+Y
+Y
+----
+A
+B
+APP
+N
+N
+----
+B
+APP
+_SYSTEM
+Y
+Y
+----
+B
+WHOMEVER
+APP
+N
+N
+----
 Database 'wombat_new' deleted.
 --
 *******************************************
@@ -4477,6 +4551,43 @@
 null
 ----
 ========== SYSVIEWS ==========
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+----
+"eve"
+B
+APP
+N
+N
+----
+A
+APP
+_SYSTEM
+Y
+Y
+----
+A
+B
+APP
+N
+N
+----
+B
+APP
+_SYSTEM
+Y
+Y
+----
+B
+WHOMEVER
+APP
+N
+N
+----
 Database 'wombat_new' deleted.
 --
 *******************************************
@@ -4723,6 +4834,43 @@
 ----
 ========== SYSTRIGGERS ==========
 ========== SYSVIEWS ==========
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+----
+"eve"
+B
+APP
+N
+N
+----
+A
+APP
+_SYSTEM
+Y
+Y
+----
+A
+B
+APP
+N
+N
+----
+B
+APP
+_SYSTEM
+Y
+Y
+----
+B
+WHOMEVER
+APP
+N
+N
+----
 Database 'wombat_new' deleted.
 --
 *******************************************
@@ -5016,6 +5164,43 @@
 N
 APP
 ----
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+----
+"eve"
+B
+APP
+N
+N
+----
+A
+APP
+_SYSTEM
+Y
+Y
+----
+A
+B
+APP
+N
+N
+----
+B
+APP
+_SYSTEM
+Y
+Y
+----
+B
+WHOMEVER
+APP
+N
+N
+----
 Database 'wombat_new' deleted.
 --
 *******************************************
@@ -5152,6 +5337,43 @@
 null
 ----
 ========== SYSVIEWS ==========
+========== SYSROLES ==========
+"eve"
+APP
+_SYSTEM
+Y
+Y
+----
+"eve"
+B
+APP
+N
+N
+----
+A
+APP
+_SYSTEM
+Y
+Y
+----
+A
+B
+APP
+N
+N
+----
+B
+APP
+_SYSTEM
+Y
+Y
+----
+B
+WHOMEVER
+APP
+N
+N
+----
 Database 'wombat_new' deleted.
 --
 *******************************************
@@ -5188,6 +5410,7 @@
 ========== SYSTABLES ==========
 ========== SYSTRIGGERS ==========
 ========== SYSVIEWS ==========
+========== SYSROLES ==========
 Database 'wombat_new' deleted.
 -= Start dblook Message Tests =-
 Database 'wombat' deleted.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_app.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_app.properties?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_app.properties Mon Sep 29 15:43:55 2008
@@ -13,6 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+ij.user=app
+ij.password=apppw
 supportfiles=tests/tools/dblook_makeDB.sql,tests/tools/dblook_test.jar
 
 # disable security manager for now - due to DERBY-537

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_derby.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_derby.properties?rev=700295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_derby.properties (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_derby.properties Mon Sep 29 15:43:55 2008
@@ -0,0 +1,39 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# This is the default derby properties file for SQL and JAVA tests.
+#
+# *** DO NOT PUT PROPERTIES FOR THE JAVA ENVIRONMENT IN THIS FILE.
+# *** THEY BELONG IN default_app.properties.
+#
+# This file will get renamed to be derby.properties for all
+# tests without a <testname>_derby.properties file defined.
+#
+# If you want to alter these to use other settings,
+# or to not be used, override this file by creating
+# a file <testname>_derby.properties to be used instead of this file.
+#
+
+# statement cache size of 20 is the default, do not add this property
+# to this file.  If your test wants to do consistency checking that
+# requires an empty cache, add a special test_derby.properties file, see
+# inbetween_derby.properties for an example.
+#
+# derby.language.statementCacheSize=20
+derby.infolog.append=true
+derby.connection.requireAuthentication=true
+derby.database.sqlAuthorization=true
+derby.user.app=apppw

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_derby.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_territory_app.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_territory_app.properties?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_territory_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_territory_app.properties Mon Sep 29 15:43:55 2008
@@ -13,6 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+ij.user=app
+ij.password=apppw
 supportfiles=tests/tools/dblook_makeDB.sql,tests/tools/dblook_test.jar
 
 # disable security manager for now - due to DERBY-537

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_territory_derby.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_territory_derby.properties?rev=700295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_territory_derby.properties (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_territory_derby.properties Mon Sep 29 15:43:55 2008
@@ -0,0 +1,39 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# This is the default derby properties file for SQL and JAVA tests.
+#
+# *** DO NOT PUT PROPERTIES FOR THE JAVA ENVIRONMENT IN THIS FILE.
+# *** THEY BELONG IN default_app.properties.
+#
+# This file will get renamed to be derby.properties for all
+# tests without a <testname>_derby.properties file defined.
+#
+# If you want to alter these to use other settings,
+# or to not be used, override this file by creating
+# a file <testname>_derby.properties to be used instead of this file.
+#
+
+# statement cache size of 20 is the default, do not add this property
+# to this file.  If your test wants to do consistency checking that
+# requires an empty cache, add a special test_derby.properties file, see
+# inbetween_derby.properties for an example.
+#
+# derby.language.statementCacheSize=20
+derby.infolog.append=true
+derby.connection.requireAuthentication=true
+derby.database.sqlAuthorization=true
+derby.user.app=apppw

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dblook_test_net_territory_derby.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql Mon Sep 29 15:43:55 2008
@@ -166,3 +166,14 @@
 create table x (x int);
 create table removed (x int);
 create trigger trigFour after update of x on x referencing old_table as old new_table as new for each statement insert into removed select * from old where x not in (select x from new where x < 10);
+
+-- ----------------------------------------------
+-- Roles
+-- ----------------------------------------------
+create role a;
+create role b;
+create role """eve""";
+grant a to b;
+grant """eve""" to b;
+grant b to whomever;
+

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test.java?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test.java Mon Sep 29 15:43:55 2008
@@ -397,17 +397,18 @@
 		String sourceDBUrl;
 		if (TestUtil.isJCCFramework())
 			sourceDBUrl = jdbcProtocol + "\"" + dbPath +
-				separator + dbName + "\":user=someusr;password=somepwd;";
+				separator + dbName + "\":user=app;password=apppw;";
 		else
 			sourceDBUrl = jdbcProtocol + dbPath +
-			separator + dbName + ";user=someusr;password=somepwd";
+			separator + dbName + ";user=app;password=apppw";
 
 		// Make sure we're not connected to the database
 		// (we connected to it in embedded mode when we
 		// created it, so we have to shut it down).
 		try {
 			DriverManager.getConnection(
-				"jdbc:derby:" + dbName + ";shutdown=true");
+				"jdbc:derby:" + dbName +
+				";shutdown=true;user=app;password=apppw");
 		} catch (SQLException e) {}
 
 		// Run the test.
@@ -561,7 +562,7 @@
 
 		jdbcProtocol = "jdbc:derby:";
 		String sourceDBUrl = jdbcProtocol + dbPath +
-			separator + dbName;
+			separator + dbName + ";user=app;password=apppw";
 
 		String [] fullArgs = new String[args.length+2];
 		fullArgs[0] = "-d";
@@ -664,7 +665,7 @@
 		try {
 			Connection conn =
 				DriverManager.getConnection("jdbc:derby:" + 
-					jarPath + ";shutdown=true");
+					jarPath + ";shutdown=true,user=app;password=apppw");
 			conn.close();
 		} catch (SQLException se) {
 		// shutdown exception.
@@ -721,7 +722,7 @@
 
 		// Connect to the database.
 		Connection conn = DriverManager.getConnection(
-				"jdbc:derby:" + dbName);
+				"jdbc:derby:" + dbName + ";user=app;password=apppw");
 		conn.setAutoCommit(false);
 
 		// Set the system schema to ensure that UCS_BASIC collation is used.
@@ -828,6 +829,14 @@
 		rs = stmt.executeQuery("select compilationschemaid, sys.sysviews.* from sys.sysviews");
 		dumpResultSet(rs, idToNameMap, null);
 
+		writeOut("\n========== SYSROLES ==========\n");
+		rs = stmt.executeQuery
+			("select 'dummyFirstCol', " +
+			 "roleid || '_' || grantee || '_' || grantor as rgd, " +
+			 "roleid, grantee, grantor, withadminoption, isdef " +
+			 "from sys.sysroles");
+		dumpResultSet(rs, idToNameMap, null);
+
 		stmt.close();
 		rs.close();
 		conn.commit();
@@ -915,7 +924,6 @@
 		TreeMap orderedRows = new TreeMap();
 		ArrayList rowValues = new ArrayList();
 		ArrayList duplicateRowIds = new ArrayList();
-
 		ResultSetMetaData rsmd = rs.getMetaData();
 		int cols = rsmd.getColumnCount();
 		while (rs.next()) {
@@ -957,8 +965,18 @@
 				// it in the results.
 					continue;
 
-				String uniquePiece = dumpColumnData(colName,
-					value, mappedName, rowValues);
+
+				String uniquePiece;
+
+				if (colName.equals("RGD")) {
+					// Role Grant Descriptor: synthetic unique column, see query
+					// from SYS.SYSROLES.
+					uniquePiece = value;
+				} else {
+					uniquePiece = dumpColumnData(colName,
+												 value, mappedName, rowValues);
+				}
+
 
 				if (colName.equals("DEPENDENTID")) {
 				// Special case: rows in the "DEPENDS" table
@@ -1212,7 +1230,8 @@
 			"' from ddl script '" + scriptName + "'");
 
 		Connection conn = DriverManager.getConnection(
-				"jdbc:derby:" + newDBName + ";create=true" + territoryBased);
+				"jdbc:derby:" + newDBName +
+				";create=true;user=app;password=apppw" + territoryBased);
 
 		Statement stmt = conn.createStatement();
 		BufferedReader ddlScript =
@@ -1458,7 +1477,7 @@
 		try {
 			Connection conn =
 				DriverManager.getConnection("jdbc:derby:" + 
-					deletePath + ";shutdown=true");
+					deletePath + ";shutdown=true;user=app;password=apppw");
 			conn.close();
 		} catch (SQLException se) {
 		// shutdown exception.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_app.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_app.properties?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_app.properties Mon Sep 29 15:43:55 2008
@@ -12,7 +12,8 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
+ij.user=app
+ij.password=apppw
 supportfiles=tests/tools/dblook_makeDB.sql,tests/tools/dblook_makeDB_2.sql,tests/tools/dblook_test.jar
 
 #Exclude for J2ME/Foundation - test requires java.sql.DriverManager

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_derby.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_derby.properties?rev=700295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_derby.properties (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_derby.properties Mon Sep 29 15:43:55 2008
@@ -0,0 +1,39 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# This is the default derby properties file for SQL and JAVA tests.
+#
+# *** DO NOT PUT PROPERTIES FOR THE JAVA ENVIRONMENT IN THIS FILE.
+# *** THEY BELONG IN default_app.properties.
+#
+# This file will get renamed to be derby.properties for all
+# tests without a <testname>_derby.properties file defined.
+#
+# If you want to alter these to use other settings,
+# or to not be used, override this file by creating
+# a file <testname>_derby.properties to be used instead of this file.
+#
+
+# statement cache size of 20 is the default, do not add this property
+# to this file.  If your test wants to do consistency checking that
+# requires an empty cache, add a special test_derby.properties file, see
+# inbetween_derby.properties for an example.
+#
+# derby.language.statementCacheSize=20
+derby.infolog.append=true
+derby.connection.requireAuthentication=true
+derby.database.sqlAuthorization=true
+derby.user.app=apppw

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_derby.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_territory_app.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_territory_app.properties?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_territory_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_territory_app.properties Mon Sep 29 15:43:55 2008
@@ -13,6 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+ij.user=app
+ij.password=apppw
 supportfiles=tests/tools/dblook_makeDB.sql,tests/tools/dblook_makeDB_2.sql,tests/tools/dblook_test.jar
 
 #Exclude for J2ME/Foundation - test requires java.sql.DriverManager

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_territory_derby.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_territory_derby.properties?rev=700295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_territory_derby.properties (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_territory_derby.properties Mon Sep 29 15:43:55 2008
@@ -0,0 +1,39 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# This is the default derby properties file for SQL and JAVA tests.
+#
+# *** DO NOT PUT PROPERTIES FOR THE JAVA ENVIRONMENT IN THIS FILE.
+# *** THEY BELONG IN default_app.properties.
+#
+# This file will get renamed to be derby.properties for all
+# tests without a <testname>_derby.properties file defined.
+#
+# If you want to alter these to use other settings,
+# or to not be used, override this file by creating
+# a file <testname>_derby.properties to be used instead of this file.
+#
+
+# statement cache size of 20 is the default, do not add this property
+# to this file.  If your test wants to do consistency checking that
+# requires an empty cache, add a special test_derby.properties file, see
+# inbetween_derby.properties for an example.
+#
+# derby.language.statementCacheSize=20
+derby.infolog.append=true
+derby.connection.requireAuthentication=true
+derby.database.sqlAuthorization=true
+derby.user.app=apppw

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_test_territory_derby.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_GrantRevoke.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_GrantRevoke.java?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_GrantRevoke.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_GrantRevoke.java Mon Sep 29 15:43:55 2008
@@ -1,6 +1,6 @@
 /*
 
-   Derby - Class org.apache.derby.impl.tools.dblook.DB_Alias
+   Derby - Class org.apache.derby.impl.tools.dblook.DB_GrantRevoke
 
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -83,9 +83,12 @@
 				Logs.reportString("----------------------------------------------\n");
 			}
 
-			String authName = rs.getString(1);
-			String schemaName = dblook.addQuotes(dblook.expandDoubleQuotes(rs.getString(2)));
-			String tableName = dblook.addQuotes(dblook.expandDoubleQuotes(rs.getString(3)));
+			String authName = dblook.addQuotes
+				(dblook.expandDoubleQuotes(rs.getString(1)));
+			String schemaName = dblook.addQuotes
+				(dblook.expandDoubleQuotes(rs.getString(2)));
+			String tableName = dblook.addQuotes
+				(dblook.expandDoubleQuotes(rs.getString(3)));
 			String fullName = schemaName + "." + tableName;
 
 			if (dblook.isIgnorableSchema(schemaName))
@@ -175,7 +178,8 @@
 				Logs.reportString("----------------------------------------------\n");
 			}
 
-			String authName = rs.getString(1);
+			String authName = dblook.addQuotes
+				(dblook.expandDoubleQuotes(rs.getString(1)));
 			String schemaName = dblook.expandDoubleQuotes(rs.getString(2));
 			String tableName = dblook.expandDoubleQuotes(rs.getString(3));
 
@@ -280,9 +284,12 @@
 	{
 		boolean firstTime = true;
 		while (rs.next()) {
-			String authName = rs.getString(1);
-			String schemaName = dblook.addQuotes(dblook.expandDoubleQuotes(rs.getString(2)));
-			String aliasName = dblook.addQuotes(dblook.expandDoubleQuotes(rs.getString(3)));
+			String authName = dblook.addQuotes
+				(dblook.expandDoubleQuotes(rs.getString(1)));
+			String schemaName = dblook.addQuotes
+				(dblook.expandDoubleQuotes(rs.getString(2)));
+			String aliasName = dblook.addQuotes
+				(dblook.expandDoubleQuotes(rs.getString(3)));
 			String fullName = schemaName + "." + aliasName;
 			String aliasType = rs.getString(4);
 

Added: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Roles.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Roles.java?rev=700295&view=auto
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Roles.java (added)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Roles.java Mon Sep 29 15:43:55 2008
@@ -0,0 +1,176 @@
+/*
+
+   Derby - Class org.apache.derby.impl.tools.dblook.DB_Roles
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derby.impl.tools.dblook;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import java.util.StringTokenizer;
+
+import org.apache.derby.tools.dblook;
+
+public class DB_Roles {
+
+    /**
+     * Generate role definition statements and role grant statements. Note that
+     * privileges granted to roles are handled by DB_GrantRevoke, similar to
+     * privileges granted to users.
+     *
+     * @param conn Connection to use
+     */
+    public static void doRoles(Connection conn)
+        throws SQLException {
+
+        // First generate role definition statements
+        Statement stmt = conn.createStatement();
+        ResultSet rs = stmt.executeQuery
+            ("SELECT ROLEID, GRANTEE, GRANTOR, " +
+             "WITHADMINOPTION FROM SYS.SYSROLES WHERE ISDEF = 'Y'");
+        generateRoleDefinitions(rs);
+        rs.close();
+
+        // Generate role grant statements
+        rs = stmt.executeQuery
+            ("SELECT ROLEID, GRANTEE, GRANTOR, WITHADMINOPTION" +
+             " FROM SYS.SYSROLES WHERE ISDEF = 'N'");
+        generateRoleGrants(rs);
+
+        rs.close();
+        stmt.close();
+        return;
+
+    }
+
+    /**
+     * Generate role definition statements
+     *
+     * @param rs Result set holding required information
+     */
+    private static void generateRoleDefinitions(ResultSet rs)
+        throws SQLException
+    {
+        boolean firstTime = true;
+        while (rs.next()) {
+
+            if (firstTime) {
+                Logs.reportString
+                    ("----------------------------------------------");
+                Logs.reportMessage( "DBLOOK_Role_definitions_header");
+                Logs.reportString
+                    ("----------------------------------------------\n");
+            }
+
+            String roleName = dblook.addQuotes
+                (dblook.expandDoubleQuotes(rs.getString(1)));
+            // String grantee = dblook.addQuotes
+            //     (dblook.expandDoubleQuotes(rs.getString(2))); // always DBO
+            // String grantor = dblook.addQuotes
+            //   (dblook.expandDoubleQuotes(rs.getString(3))); // always _SYSTEM
+            // boolean isWithAdminOption = rs.getString
+            //   (4).equals("Y") ? true : false; // always true for a definition
+
+            Logs.writeToNewDDL(roleDefinitionStatement(rs, roleName));
+            Logs.writeStmtEndToNewDDL();
+            Logs.writeNewlineToNewDDL();
+            firstTime = false;
+        }
+    }
+
+    /**
+     * Generate a role definition statement for the current row
+     *
+     * @param rs        @{code ResultSet} holding role definition information
+     * @param roleName  The role defined, already quoted
+     */
+    private static String roleDefinitionStatement(ResultSet rs, String roleName)
+        throws SQLException
+    {
+        StringBuffer createStmt = new StringBuffer("CREATE ROLE ");
+
+        createStmt.append(roleName);
+        return createStmt.toString();
+    }
+
+    private static void generateRoleGrants(ResultSet rs)
+        throws SQLException
+    {
+        boolean firstTime = true;
+        while (rs.next()) {
+
+            if (firstTime) {
+                firstTime = false;
+
+                Logs.reportString
+                    ("----------------------------------------------");
+                Logs.reportMessage( "DBLOOK_Role_grants_header");
+                Logs.reportString
+                    ("----------------------------------------------\n");
+            }
+
+            String roleName = dblook.addQuotes
+                (dblook.expandDoubleQuotes(rs.getString(1)));
+            String grantee = dblook.addQuotes
+                (dblook.expandDoubleQuotes(rs.getString(2)));
+            String grantor = dblook.addQuotes
+                (dblook.expandDoubleQuotes(rs.getString(3))); // always DBO
+            boolean isWithAdminOption =
+                rs.getString(4).equals("Y") ? true : false;
+
+            Logs.writeToNewDDL
+                (roleGrantStatement(rs, roleName, grantee, isWithAdminOption));
+            Logs.writeStmtEndToNewDDL();
+            Logs.writeNewlineToNewDDL();
+        }
+    }
+
+    /**
+     * Generate role grant statement for the current row
+     *
+     * @param rs        @{ResultSet} holding role grant information
+     * @param roleName  The role granted, already quoted
+     * @param graentee The authorization id to whom the role is granted (a role
+     *                  or a user), already quoted
+     * @param isWithAdminOption @{code true} if ADMIN OPTION was used for the
+     *         grant
+     */
+    private static String roleGrantStatement(ResultSet rs,
+                                             String roleName,
+                                             String grantee,
+                                             boolean isWithAdminOption)
+        throws SQLException
+    {
+        StringBuffer createStmt = new StringBuffer("GRANT ");
+
+        createStmt.append(roleName);
+        createStmt.append(" TO ");
+        createStmt.append(grantee);
+
+        if (isWithAdminOption) {
+            createStmt.append(" WITH ADMIN OPTION");
+        }
+
+        return createStmt.toString();
+    }
+
+}

Propchange: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Roles.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties Mon Sep 29 15:43:55 2008
@@ -242,6 +242,8 @@
 DBLOOK_TablePrivHeader=GRANT statements for tables
 DBLOOK_ColumnPrivHeader=GRANT statements for columns
 DBLOOK_RoutinePrivHeader=GRANT statements for routines
+DBLOOK_Role_definitions_header=CREATE statements for roles
+DBLOOK_Role_grants_header=GRANT statements for roles
 DBLOOK_Jar_Note=\
 **** NOTE **** In order for jar files to be loaded correctly,\n\
 -- you must either 1) ensure that the DBJARS directory (created\n\

Modified: db/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java?rev=700295&r1=700294&r2=700295&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java Mon Sep 29 15:43:55 2008
@@ -48,6 +48,7 @@
 import org.apache.derby.impl.tools.dblook.DB_Alias;
 import org.apache.derby.impl.tools.dblook.DB_Trigger;
 import org.apache.derby.impl.tools.dblook.DB_View;
+import org.apache.derby.impl.tools.dblook.DB_Roles;
 import org.apache.derby.impl.tools.dblook.DB_GrantRevoke;
 import org.apache.derby.impl.tools.dblook.Logs;
 
@@ -539,6 +540,7 @@
 
 			DB_Trigger.doTriggers(this.conn);
 
+			DB_Roles.doRoles(this.conn);
 			DB_GrantRevoke.doAuthorizations(this.conn);
 
 			// That's it; we're done.



Mime
View raw message