db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r506751 - in /db/derby/code/trunk/java: drda/org/apache/derby/drda/ drda/org/apache/derby/impl/drda/ drda/org/apache/derby/loc/drda/ engine/org/apache/derby/iapi/reference/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/a...
Date Mon, 12 Feb 2007 23:44:26 GMT
Author: rhillegas
Date: Mon Feb 12 15:44:25 2007
New Revision: 506751

URL: http://svn.apache.org/viewvc?view=rev&rev=506751
Log:
DERBY-2196: Commit derby-2196-02-install-01.diff, which installs a security manager when the
network server is booted without one.

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java
    db/derby/code/trunk/java/drda/org/apache/derby/drda/server.policy
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java?view=diff&rev=506751&r1=506750&r2=506751
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java Mon Feb
12 15:44:25 2007
@@ -23,6 +23,7 @@
 
 import java.io.PrintWriter;
 import java.net.InetAddress;
+import java.net.URL;
 import java.util.Properties;
 import org.apache.derby.iapi.reference.Property;
 
@@ -167,7 +168,12 @@
 
 	
 	public final static int DEFAULT_PORTNUMBER = 1527;
-	private NetworkServerControlImpl serverImpl;
+
+	private final static String DERBYNET_JAR = "derbynet.jar";
+	private final static String POLICY_FILENAME = "server.policy";
+	private final static String POLICY_FILE_PROPERTY = "java.security.policy";
+
+    private NetworkServerControlImpl serverImpl;
 
 	// constructor
 
@@ -233,16 +239,48 @@
 	 */
     public static void main(String args[]) {
         NetworkServerControlImpl server = null;
+
+        //
+        // The following variable lets us preserve the error printing behavior
+        // seen before we started installing a security manager. Errors can be
+        // raised as we figure out whether we need to install a security manager
+        // and during the actual installation of the security manager. We need
+        // to print out these errors. The old error printing behavior assumed
+        // that all errors were generated inside NetworkServerControlImpl and
+        // were reported there.
+        //
+        boolean                                 printErrors = true;
+        
         try
         {
             server = new NetworkServerControlImpl();
-    		server.executeWork(args);
+            
+            int     command = server.parseArgs( args );
+
+            //
+            // In order to run secure-by-default, we install a security manager
+            // if one isn't already installed. This feature is described by DERBY-2196.
+            //
+            if ( needsSecurityManager( server, command ) )
+            {
+                verifySecurityState( server );
+                installSecurityManager( server );
+            }
+
+            //
+            // From this point on, NetworkServerControlImpl is responsible for
+            // printing errors.
+            //
+            printErrors = false;
+            server.executeWork( command );
         }
         catch (Exception e)
         {
 			//if there was an error, exit(1)
 			if ((e.getMessage() == null) ||
-				!e.getMessage().equals(NetworkServerControlImpl.UNEXPECTED_ERR))
+				!e.getMessage().equals(NetworkServerControlImpl.UNEXPECTED_ERR) ||
+				printErrors
+			)
 			{
 				if (server != null)
 					server.consoleExceptionPrint(e);
@@ -485,9 +523,155 @@
 	{
 		serverImpl.clientLocale = locale;
 	}
-}
 
+    /**
+     * Return true if we need to install a Security Manager. All of the
+     * following must apply. See DERBY-2196.
+     *
+     * <ul>
+     * <li>The VM was booted with NetworkServerContro.main() as the
+     * entry point. This is handled by the fact that this method is only called
+     * by main().</li>
+     * <li>The VM isn't already running a SecurityManager.</li>
+     * <li>The command must be "start".</li>
+     * <li>The customer didn't specify the -unsecure flag on the startup command
+     * line.</li>
+     * </ul>
+     */
+    private static  boolean needsSecurityManager( NetworkServerControlImpl server, int command
)
+        throws Exception
+    {
+        return
+            (
+             (System.getSecurityManager() == null) &&
+             (command == NetworkServerControlImpl.COMMAND_START) &&
+             (!server.runningUnsecure())
+             );
+   }
+    
+    /**
+     * Verify that all prerequisites are met before bringing up a security
+     * manager. See DERBY-2196.
+     */
+    private static  void verifySecurityState( NetworkServerControlImpl server )
+        throws Exception
+    {
+        //
+        // Authentication should be turned on. Otherwise, the user will
+        // be tricked into a false sense of security. Important security checks
+        // will be identity based.
+        //
+        if ( !Boolean.getBoolean( Property.REQUIRE_AUTHENTICATION_PARAMETER ) )
+        {
+            String  errorMessage = server.localizeMessage
+                (
+                 "DRDA_NoAuthentication.S",
+                 new String[]
+                    {
+                        Property.REQUIRE_AUTHENTICATION_PARAMETER,
+                        NetworkServerControlImpl.DASHARGS[  NetworkServerControlImpl.DASHARG_UNSECURE
] }
+                );
+
+            // this throws an exception and exits this method
+            server.consoleError( errorMessage );
+        }
+    }
 
+    
+    /**
+     * Install a SecurityManager governed by the Basic startup policy. See DERBY-2196.
+     */
+    private static  void installSecurityManager( NetworkServerControlImpl server )
+        throws Exception
+    {
+        //
+        // The Basic policy refers to some properties. Make sure they are set.
+        //
+        if ( System.getProperty( Property.SYSTEM_HOME_PROPERTY ) == null )
+        { System.setProperty( Property.SYSTEM_HOME_PROPERTY, System.getProperty( "user.dir"
) ); }
+
+        if ( System.getProperty( Property.DRDA_PROP_HOSTNAME ) == null )
+        { System.setProperty( Property.DRDA_PROP_HOSTNAME, server.getHost() ); }
+
+        //
+        // Forcibly set the following property. This is the parameter in
+        // the Basic policy which points at the directory where the embedded and
+        // network codesources. Do not let the customer
+        // override this
+        //
+        String      derbyInstallURL = getCodeSourcePrefix( server );
+
+        System.setProperty( Property.DERBY_INSTALL_URL, derbyInstallURL );
+        
+        //
+        // Now install a SecurityManager, using the Basic policy file.
+        //
+        String      policyFileURL = getPolicyFileURL();
+
+        System.setProperty( POLICY_FILE_PROPERTY, policyFileURL );
+        
+        SecurityManager     securityManager = new SecurityManager();
+
+        System.setSecurityManager( securityManager );
+
+        //
+        // Report success.
+        //
+        String  successMessage = server.localizeMessage( "DRDA_SecurityInstalled.I", null
);
+        
+        server.consoleMessage( successMessage );
+    }
+
+    /**
+     *<p>
+     * Find the url of the library directory which holds derby.jar and
+     * derbynet.jar. The Basic policy assumes that both jar files live in the
+     * same directory.
+     * </p>
+     */
+    private static  String  getCodeSourcePrefix( NetworkServerControlImpl server )
+        throws Exception
+    {
+        String  derbyNetURL = NetworkServerControl.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm();
+        int         idx = derbyNetURL.indexOf( DERBYNET_JAR );
+
+        //
+        // If the customer isn't running against jar files, our Basic policy
+        // won't work.
+        //
+        if ( idx < 0 )
+        {
+            String  errorMessage = server.localizeMessage( "DRDA_MissingNetworkJar.S", null
);
 
+            // this throws an exception and exits this method
+            server.consoleError( errorMessage );
+        }
+
+        //
+        // Otherwise, we have the directory prefix for our url.
+        //
+        String  directoryPrefix = derbyNetURL.substring( 0, idx );
+
+        return directoryPrefix;
+    }
+
+    /**
+     *<p>
+     * Get the URL of the policy file. Typically, this will be some pointer into
+     * derbynet.jar.
+     * </p>
+     */
+    private static  String getPolicyFileURL()
+        throws Exception
+    {
+        String      resourceName =
+            NetworkServerControl.class.getPackage().getName().replace( '.', '/' ) +
+            '/' +
+            POLICY_FILENAME;
+        URL         resourceURL = NetworkServerControl.class.getClassLoader().getResource(
resourceName );
+        String      stringForm = resourceURL.toExternalForm();
 
+        return stringForm;
+    }
 
+}

Modified: db/derby/code/trunk/java/drda/org/apache/derby/drda/server.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/drda/server.policy?view=diff&rev=506751&r1=506750&r2=506751
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/drda/server.policy (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/drda/server.policy Mon Feb 12 15:44:25
2007
@@ -1,4 +1,4 @@
-grant codeBase "${derby.derby.jar}"
+grant codeBase "${derby.install.url}derby.jar"
 {
 //
 // These permissions are needed for everyday, embedded Derby usage.
@@ -20,7 +20,7 @@
   permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
 };
 
-grant codeBase "${derby.derbynet.jar}"
+grant codeBase "${derby.install.url}derbynet.jar"
 {
 //
 // This permission lets the Network Server manage connections from clients.

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?view=diff&rev=506751&r1=506750&r2=506751
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Mon Feb 12 15:44:25 2007
@@ -83,29 +83,30 @@
 	// number of required arguments for each command
 	private final static int [] COMMAND_ARGS =
 	{0, 0, 1, 1, 0, 1, 0, 0, 1, 1};
-	private final static int COMMAND_START = 0;
-	private final static int COMMAND_SHUTDOWN = 1;
-	private final static int COMMAND_TRACE = 2;
-	private final static int COMMAND_TRACEDIRECTORY = 3;
-	private final static int COMMAND_TESTCONNECTION = 4;
-	private final static int COMMAND_LOGCONNECTIONS = 5;
-	private final static int COMMAND_SYSINFO = 6;
-	private final static int COMMAND_RUNTIME_INFO = 7;
-	private final static int COMMAND_MAXTHREADS = 8;
-	private final static int COMMAND_TIMESLICE = 9;
-	private final static int COMMAND_PROPERTIES = 10;
-	private final static int COMMAND_UNKNOWN = -1;
-	private final static String [] DASHARGS =
-	{"p","d","u","ld","ea","ep", "b", "h", "s"};
-	private final static int DASHARG_PORT = 0;
-	private final static int DASHARG_DATABASE = 1;
-	private final static int DASHARG_USER = 2;
-	private final static int DASHARG_LOADSYSIBM = 3;
-	private final static int DASHARG_ENCALG = 4;
-	private final static int DASHARG_ENCPRV = 5;
-	private final static int DASHARG_BOOTPASSWORD = 6;
-	private final static int DASHARG_HOST = 7;
-	private final static int DASHARG_SESSION = 8;
+	public final static int COMMAND_START = 0;
+	public final static int COMMAND_SHUTDOWN = 1;
+	public final static int COMMAND_TRACE = 2;
+	public final static int COMMAND_TRACEDIRECTORY = 3;
+	public final static int COMMAND_TESTCONNECTION = 4;
+	public final static int COMMAND_LOGCONNECTIONS = 5;
+	public final static int COMMAND_SYSINFO = 6;
+	public final static int COMMAND_RUNTIME_INFO = 7;
+	public final static int COMMAND_MAXTHREADS = 8;
+	public final static int COMMAND_TIMESLICE = 9;
+	public final static int COMMAND_PROPERTIES = 10;
+	public final static int COMMAND_UNKNOWN = -1;
+	public final static String [] DASHARGS =
+	{"p","d","u","ld","ea","ep", "b", "h", "s", "unsecure"};
+	public final static int DASHARG_PORT = 0;
+	public final static int DASHARG_DATABASE = 1;
+	public final static int DASHARG_USER = 2;
+	public final static int DASHARG_LOADSYSIBM = 3;
+	public final static int DASHARG_ENCALG = 4;
+	public final static int DASHARG_ENCPRV = 5;
+	public final static int DASHARG_BOOTPASSWORD = 6;
+	public final static int DASHARG_HOST = 7;
+	public final static int DASHARG_SESSION = 8;
+	public final static int DASHARG_UNSECURE = 9;
 
 	// command protocol version - you need to increase this number each time
 	// the command protocol changes 
@@ -204,6 +205,7 @@
 	private String hostArg = DEFAULT_HOST;	
 	private InetAddress hostAddress;
 	private int sessionArg;
+	private boolean unsecureArg;
 
 	// Used to debug memory in SanityManager.DEBUG mode
 	private memCheck mc;
@@ -330,6 +332,17 @@
         }
     }
 
+    /**
+     * Get the host where we listen for connections.
+     */
+    public  String  getHost() { return hostArg; }
+
+    /**
+     * Return true if the customer forcibly overrode our decision to install a
+     * default SecurityManager.
+     */
+    public  boolean runningUnsecure() { return unsecureArg; }
+    
     // constructor
 	public NetworkServerControlImpl() throws Exception
 	{
@@ -1757,27 +1770,42 @@
 	}
 
 
+    /**
+     * Parse the command-line arguments. As a side-effect, fills in various instance
+     * fields. This method was carved out of executeWork() so that
+     * NetworkServerControl can figure out whether to install a security manager
+     * before the server actually comes up. This is part of the work for DERBY-2196.
+     *
+     * @param args	array of arguments indicating command to be executed
+     *
+     * @return the command to be executed
+     */
+    public int parseArgs(String args[]) throws Exception
+    {
+        // For convenience just use NetworkServerControlImpls log writer for user messages
+        logWriter = makePrintWriter(System.out);
+
+        int command = COMMAND_START; 
+        if (args.length > 0)
+            command = findCommand(args);
+        else
+        {
+            consolePropertyMessage("DRDA_NoArgs.U");
+        }
+
+        return command;
+    }
+
 	/**
 	 * Execute the command given on the command line
 	 *
-	 * @param args	array of arguments indicating command to be executed
+	 * @param command   The command to execute. The command itself was determined by an earlier
call to parseArgs().
 	 *
 	 * @exception Exception	throws an exception if an error occurs
 	 * see class comments for more information
 	 */
-	public void executeWork(String args[]) throws Exception
+	public void executeWork(int command) throws Exception
 	{
-		// For convenience just use NetworkServerControlImpls log writer for user messages
-		logWriter = makePrintWriter(System.out);
-		
-		int command = 0; 
-		if (args.length > 0)
-			command = findCommand(args);
-		else
-		{
-			consolePropertyMessage("DRDA_NoArgs.U");
-		}
-
 		// if we didn't have a valid command just return - error already generated
 		if (command == COMMAND_UNKNOWN)
 			return;
@@ -1962,7 +1990,7 @@
 			if (DASHARGS[i].equals(args[pos].substring(1)))
 			{
 				dashArg = i;
-				pos++;
+				if ( dashArg != DASHARG_UNSECURE ) { pos++ ; }
 				break;
 			}
 		}
@@ -2038,6 +2066,11 @@
 				else
 					consolePropertyMessage("DRDA_MissingValue.U", "DRDA_Session.I");
 				break;
+
+			case DASHARG_UNSECURE:
+				unsecureArg = true;
+				break;
+
 			default:
 				//shouldn't get here
 		}
@@ -2878,6 +2911,18 @@
 		throw new Exception(UNEXPECTED_ERR);
 
 	}
+
+    /**
+     * Convenience routine so that NetworkServerControl can localize messages.
+     *
+     * @param msgProp	message key
+     * @param args		arguments to message
+     *
+     */
+    public String localizeMessage( String msgProp, String[] args )
+    {
+        return localizeMessage( msgProp, langUtil, args );
+    }
 
 	/**
 	 * Localize a message given a particular AppUI 

Modified: db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties?view=diff&rev=506751&r1=506750&r2=506751
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties Mon Feb
12 15:44:25 2007
@@ -81,6 +81,9 @@
 DRDA_IOException.S=IOException: {0}.
 DRDA_UnknownProtocol=Unknown Command Protocol version: {0}.
 DRDA_MissingLocale.I=Resources not found for current locale; switching to {0}.
+DRDA_MissingNetworkJar.S=Cannot find derbynet.jar on the classpath.
+DRDA_NoAuthentication.S=Network Server startup failed. User authentication should be enabled
before the Network Server installs a security manager. Please either set the ''{0}'' system
property to true or run the network server with the ''-{1}'' option.
+DRDA_SecurityInstalled.I=Security manager installed using the Basic server security policy.
 
 # Derby Network Server SYSINFO stuff
 #
@@ -109,7 +112,7 @@
 #
 DRDA_Usage1.I=Usage: NetworkServerControl <commands> 
 DRDA_Usage2.I=Commands:
-DRDA_Usage3.I=start [-h <host>] [-p <portnumber>]
+DRDA_Usage3.I=start [-h <host>] [-p <portnumber>] [-unsecure]
 DRDA_Usage4.I=shutdown [-h <host>][-p <portnumber>]
 DRDA_Usage5.I=ping [-h <host>][-p <portnumber>]
 DRDA_Usage6.I=sysinfo [-h <host>][-p <portnumber>]

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java?view=diff&rev=506751&r1=506750&r2=506751
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java Mon Feb
12 15:44:25 2007
@@ -319,6 +319,15 @@
 	*/
 	String DATABASE_PROPERTIES_ONLY = "derby.database.propertiesOnly";
 
+    /**
+     * Ths property is private to Derby.
+     * This property is forcibly set by the Network Server to override
+     * any values which the user may have set. This property is only used to
+     * parameterize the Basic security policy used by the Network Server.
+     * This property is the location of the derby jars.
+     **/
+    public static final String DERBY_INSTALL_URL = "derby.install.url";
+
 	/*
 	** derby.storage.*
 	*/

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out?view=diff&rev=506751&r1=506750&r2=506751
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out
Mon Feb 12 15:44:25 2007
@@ -29,7 +29,7 @@
 No arguments given.
 Usage: NetworkServerControl <commands> 
 Commands:
-start [-h <host>] [-p <portnumber>]
+start [-h <host>] [-p <portnumber>] [-unsecure]
 shutdown [-h <host>][-p <portnumber>]
 ping [-h <host>][-p <portnumber>]
 sysinfo [-h <host>][-p <portnumber>]

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out?view=diff&rev=506751&r1=506750&r2=506751
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out
Mon Feb 12 15:44:25 2007
@@ -9,7 +9,7 @@
 Invalid value, -12, for maxthreads.
 Usage: NetworkServerControl <commands> 
 Commands:
-start [-h <host>] [-p <portnumber>]
+start [-h <host>] [-p <portnumber>] [-unsecure]
 shutdown [-h <host>][-p <portnumber>]
 ping [-h <host>][-p <portnumber>]
 sysinfo [-h <host>][-p <portnumber>]
@@ -30,7 +30,7 @@
 Invalid value, a, for maxthreads.
 Usage: NetworkServerControl <commands> 
 Commands:
-start [-h <host>] [-p <portnumber>]
+start [-h <host>] [-p <portnumber>] [-unsecure]
 shutdown [-h <host>][-p <portnumber>]
 ping [-h <host>][-p <portnumber>]
 sysinfo [-h <host>][-p <portnumber>]

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out?view=diff&rev=506751&r1=506750&r2=506751
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out
Mon Feb 12 15:44:25 2007
@@ -1,16 +1,16 @@
 Start testProperties to test property priority
 Testing derby.properties Port 1528 
-org.apache.derby.drda.NetworkServerControl start 
+org.apache.derby.drda.NetworkServerControl start -unsecure 
 Successfully Connected
 org.apache.derby.drda.NetworkServerControl shutdown 
 Apache Derby Network Server - 10.3.0.0 alpha -(EXPECTED SUBVERSION INFO)  shutdown at xxxxxxFILTERED-TIMESTAMPxxxxxGMT
 Testing System properties  Port 1529 
------Dderby.drda.portNumber=1529 org.apache.derby.drda.NetworkServerControl start 
+-----Dderby.drda.portNumber=1529 org.apache.derby.drda.NetworkServerControl start -unsecure

 Successfully Connected
 org.apache.derby.drda.NetworkServerControl shutdown -p 1529 
 Apache Derby Network Server - 10.3.0.0 alpha -(EXPECTED SUBVERSION INFO)  shutdown at xxxxxxFILTERED-TIMESTAMPxxxxxGMT
 Testing command line option. Port 1530
-org.apache.derby.drda.NetworkServerControl start -p 1530 
+org.apache.derby.drda.NetworkServerControl start -p 1530 -unsecure 
 Successfully Connected
 org.apache.derby.drda.NetworkServerControl shutdown -p 1530 
 Apache Derby Network Server - 10.3.0.0 alpha -(EXPECTED SUBVERSION INFO)  shutdown at xxxxxxFILTERED-TIMESTAMPxxxxxGMT
@@ -18,7 +18,7 @@
 First shutdown server started on default port by the test harness
 org.apache.derby.drda.NetworkServerControl shutdown -p 1527 
 Apache Derby Network Server - 10.3.0.0 alpha -(EXPECTED SUBVERSION INFO)  shutdown at xxxxxxFILTERED-TIMESTAMPxxxxxGMT
------Dderby.drda.logConnections -Dderby.drda.traceAll -Dderby.drda.traceDirectory -Dderby.drda.keepAlive
-Dderby.drda.timeSlice -Dderby.drda.host -Dderby.drda.portNumber -Dderby.drda.minThreads -Dderby.drda.maxThreads
-Dderby.drda.startNetworkServer -Dderby.drda.debug org.apache.derby.drda.NetworkServerControl
start 
+-----Dderby.drda.logConnections -Dderby.drda.traceAll -Dderby.drda.traceDirectory -Dderby.drda.keepAlive
-Dderby.drda.timeSlice -Dderby.drda.host -Dderby.drda.portNumber -Dderby.drda.minThreads -Dderby.drda.maxThreads
-Dderby.drda.startNetworkServer -Dderby.drda.debug org.apache.derby.drda.NetworkServerControl
start -unsecure 
 ----- listing properties --
 derby.drda.maxThreads=0
 derby.drda.keepAlive=true
@@ -63,7 +63,7 @@
 No arguments given.
 Usage: NetworkServerControl <commands> 
 Commands:
-start [-h <host>] [-p <portnumber>]
+start [-h <host>] [-p <portnumber>] [-unsecure]
 shutdown [-h <host>][-p <portnumber>]
 ping [-h <host>][-p <portnumber>]
 sysinfo [-h <host>][-p <portnumber>]
@@ -77,7 +77,7 @@
 Command unknowncmd is unknown.
 Usage: NetworkServerControl <commands> 
 Commands:
-start [-h <host>] [-p <portnumber>]
+start [-h <host>] [-p <portnumber>] [-unsecure]
 shutdown [-h <host>][-p <portnumber>]
 ping [-h <host>][-p <portnumber>]
 sysinfo [-h <host>][-p <portnumber>]
@@ -91,7 +91,7 @@
 Invalid number of arguments for command ping.
 Usage: NetworkServerControl <commands> 
 Commands:
-start [-h <host>] [-p <portnumber>]
+start [-h <host>] [-p <portnumber>] [-unsecure]
 shutdown [-h <host>][-p <portnumber>]
 ping [-h <host>][-p <portnumber>]
 sysinfo [-h <host>][-p <portnumber>]

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out?view=diff&rev=506751&r1=506750&r2=506751
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out
Mon Feb 12 15:44:25 2007
@@ -9,7 +9,7 @@
 Invalid value, -12, for timeslice.
 Usage: NetworkServerControl <commands> 
 Commands:
-start [-h <host>] [-p <portnumber>]
+start [-h <host>] [-p <portnumber>] [-unsecure]
 shutdown [-h <host>][-p <portnumber>]
 ping [-h <host>][-p <portnumber>]
 sysinfo [-h <host>][-p <portnumber>]
@@ -30,7 +30,7 @@
 Invalid value, a, for timeslice.
 Usage: NetworkServerControl <commands> 
 Commands:
-start [-h <host>] [-p <portnumber>]
+start [-h <host>] [-p <portnumber>] [-unsecure]
 shutdown [-h <host>][-p <portnumber>]
 ping [-h <host>][-p <portnumber>]
 sysinfo [-h <host>][-p <portnumber>]

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java?view=diff&rev=506751&r1=506750&r2=506751
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java
Mon Feb 12 15:44:25 2007
@@ -80,7 +80,8 @@
 									"-Dderby.drda.startNetworkServer",
 									"-Dderby.drda.debug",
 									"org.apache.derby.drda.NetworkServerControl",
-									"start"};
+									"start",
+									"-unsecure",};
     
     //No arguments
     private static String[] cmdWithoutArgs =
@@ -212,9 +213,35 @@
 		else
 			cmdArr = new String[] {"org.apache.derby.drda.NetworkServerControl", cmd,"-p", portString};
 		
+        cmdArr = unsecure( cmd, cmdArr );
+        
         execCmdDumpResults(cmdArr, wait);
 	}	
-	
+
+    /**
+     * Add the "-unsecure" option to the arguments of the start command. This
+     * prevents the server from choking on the fact that authentication isn't
+     * required. This allows the test to go ahead and test what it intends to,
+     * viz., the precedence of various property-setting techniques.
+     * The authentication requirement and the "-unsecure" option were added as
+     * part of the work for DERBY-2196.
+     */
+    private static  String[]    unsecure( String cmd, String[] originalArgs )
+    {
+        if ( !cmd.equals( "start" ) ) { return originalArgs; }
+        else
+        {
+            int             count = originalArgs.length;
+            String[]    cooked = new String[ count + 1 ];
+
+            for ( int i = 0; i < count; i++ ) { cooked[ i ] = originalArgs[ i ]; }
+
+            cooked[ count ] = "-unsecure";
+
+            return cooked;
+        }
+    }
+
 	private static void waitForStart(String portString, int timeToWait) throws Exception
 	{
 		int waitTime = 0;



Mime
View raw message