db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r632502 - 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/jdbc/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache...
Date Sat, 01 Mar 2008 00:17:13 GMT
Author: djd
Date: Fri Feb 29 16:17:11 2008
New Revision: 632502

URL: http://svn.apache.org/viewvc?rev=632502&view=rev
Log:
DERBY-2109 Major sub-set of patch 12 that requires a user name and password for network server
shutdown.
Also includes the code to check a permission when shutting down the network server but
the actual call to check the permission is commented out.

Contributed by: Martin Zaun Email: martin dot zaun at sun dot com

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java
    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/jdbc/DRDAServerStarter.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/timeslice.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SecureServerTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.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?rev=632502&r1=632501&r2=632502&view=diff
==============================================================================
--- 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 Fri Feb
29 16:17:11 2008
@@ -50,8 +50,7 @@
 	on a specific interface on a  multiple IP machine. 
     For documentation on &lt;sslmode&gt;, consult the Server and Administration Guide.</LI>
 
-	<LI>shutdown [-h &lt;host>][-p &lt;portnumber>] [-ssl &lt;sslmode&gt;]:
This shutdowns the network 	server on the host and port specified or on the local host and
port 
-	1527(default) if no host or port is specified.  </LI> 
+	<LI>shutdown [-h &lt;host&gt;][-p &lt;portnumber&gt;] [-ssl &lt;sslmode&gt;]
[-user &lt;username&gt;] [-password &lt;password&gt;]: This shutdowns the
network server with given user credentials on the host and port specified or on the local
host and port 1527(default) if no host or port is specified.  </LI> 
 
 	<LI>ping [-h &lt;host>] [-p &lt;portnumber>] [-ssl &lt;sslmode&gt;]
 	This will test whether the Network Server is up.
@@ -187,6 +186,48 @@
 	// constructor
 
 	/**
+	 * Creates a NetworkServerControl object that is configured to control
+	 * a Network Server on a specified port and InetAddress with given
+	 * user credentials.
+	 *
+	 * @param address	  The IP address of the Network Server host.
+	 *					   address cannot be null.
+	 *
+	 * @param portNumber  port number server is to used. If <= 0,
+	 *					  default port number is used
+	 *						 
+	 * @param userName	  The user name for actions requiring authorization.
+	 *						 
+	 * @param password	  The password for actions requiring authorization.
+	 *						 
+	 * @throws			   Exception on error
+	 */
+	public NetworkServerControl(InetAddress address, int portNumber,
+								String userName, String password)
+			throws Exception
+	{
+		serverImpl = new NetworkServerControlImpl(address, portNumber,
+												  userName, password);
+	}
+
+	/**
+	 * Creates a NetworkServerControl object that is configured to control
+	 * a Network Server on the default host and the default port with given
+	 * user credentials.
+	 *
+	 * @param userName	  The user name for actions requiring authorization.
+	 *						 
+	 * @param password	  The password for actions requiring authorization.
+	 *						 
+	 * @throws			   Exception on error
+	 */
+	public NetworkServerControl(String userName, String password)
+			throws Exception
+	{
+		serverImpl = new NetworkServerControlImpl(userName, password);
+	}
+
+	/**
 	 * 
 	 * Creates a NetworkServerControl object that is configured to control
 	 * a Network Server on a  specified port and InetAddress.
@@ -209,12 +250,9 @@
 	 */
 	public NetworkServerControl(InetAddress address,int portNumber) throws Exception
 	{
-		
-		serverImpl = new NetworkServerControlImpl(address, 
-										portNumber);
-
+		serverImpl = new NetworkServerControlImpl(address, portNumber);
 	}
-	
+
 
 	/**
 	 * 
@@ -234,9 +272,7 @@
 	 */
 	public NetworkServerControl() throws Exception
 	{
-		
 		serverImpl = new NetworkServerControlImpl();
-
 	}
 	
     

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?rev=632502&r1=632501&r2=632502&view=diff
==============================================================================
--- 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
Fri Feb 29 16:17:11 2008
@@ -41,7 +41,9 @@
 import javax.net.ssl.SSLServerSocketFactory;
 import java.net.UnknownHostException;
 import java.nio.charset.Charset;
+import java.security.Permission;
 import java.security.AccessController;
+import java.security.AccessControlException;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -58,6 +60,7 @@
 import java.util.Vector;
 
 import org.apache.derby.drda.NetworkServerControl;
+import org.apache.derby.security.SystemPermission;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.jdbc.DRDAServerStarter;
 import org.apache.derby.iapi.reference.Attribute;
@@ -78,6 +81,10 @@
 import org.apache.derby.iapi.util.CheapDateFormatter;
 import org.apache.derby.iapi.util.StringUtil;
 import org.apache.derby.impl.jdbc.EmbedSQLException;
+import org.apache.derby.impl.jdbc.Util;
+import org.apache.derby.iapi.jdbc.AuthenticationService;
+import org.apache.derby.iapi.reference.MessageId;
+import org.apache.derby.iapi.security.SecurityUtil;
 import org.apache.derby.mbeans.VersionMBean;
 import org.apache.derby.mbeans.drda.NetworkServerMBean;
 
@@ -124,25 +131,27 @@
 	public final static int COMMAND_STOP_REPLICATION = 14;
 	public final static int COMMAND_UNKNOWN = -1;
 	public final static String [] DASHARGS =
-	{"p","d","u","ld","ea","ep", "b", "h", "s", "noSecurityManager", "ssl", 
-	"slavehost", "slaveport"};
+	{"p", "d", "user", "password", "ld", "ea", "ep", "b", "h", "s",
+		 "noSecurityManager", "ssl", "slavehost", "slaveport"};
 	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;
-	private final static int DASHARG_SSL = 10;
-	private final static int DASHARG_SLAVEHOST = 11;
-	private final static int DASHARG_SLAVEPORT = 12;
+	public final static int DASHARG_PASSWORD = 3;
+	public final static int DASHARG_LOADSYSIBM = 4;
+	public final static int DASHARG_ENCALG = 5;
+	public final static int DASHARG_ENCPRV = 6;
+	public final static int DASHARG_BOOTPASSWORD = 7;
+	public final static int DASHARG_HOST = 8;
+	public final static int DASHARG_SESSION = 9;
+	public final static int DASHARG_UNSECURE = 10;
+	private final static int DASHARG_SSL = 11;
+	private final static int DASHARG_SLAVEHOST = 12;
+	private final static int DASHARG_SLAVEPORT = 13;
 
 	// command protocol version - you need to increase this number each time
 	// the command protocol changes 
-	private final static int PROTOCOL_VERSION = 1;
+    // DERBY-2109: shutdown command now transmits user credentials
+	private final static int PROTOCOL_VERSION = 2;
 	private final static String COMMAND_HEADER = "CMD:";
 	private final static String REPLY_HEADER = "RPY:";
 	private final static int REPLY_HEADER_LENGTH = REPLY_HEADER.length();
@@ -164,7 +173,7 @@
 	private final static int DEFAULT_MAXTHREADS = 0; //for now create whenever needed
 	private final static int DEFAULT_TIMESLICE = 0;	//for now never yield
 
-   private final static String DEFAULT_HOST = "localhost";
+	private final static String DEFAULT_HOST = "localhost";
 	private final static String DRDA_MSG_PREFIX = "DRDA_";
 	private final static String DEFAULT_LOCALE= "en";
 	private final static String DEFAULT_LOCALE_COUNTRY="US";
@@ -230,8 +239,12 @@
 	// command argument information
 	private Vector commandArgs = new Vector();
 	private String databaseArg;
-	private String userArg;
-	private String passwordArg;
+	// DERBY-2109: Note that derby JDBC clients have a default user name
+    // "APP" (= Property.DEFAULT_USER_NAME) assigned if they don't provide
+    // credentials.  We could do the same for NetworkServerControl clients
+    // here, but this class is robust enough to allow for null as default.
+	private String userArg = null;
+	private String passwordArg = null;
 	private String bootPasswordArg;
 	private String encAlgArg;
 	private String encPrvArg;
@@ -393,24 +406,55 @@
 		getPropertyInfo();
     }
 
-
 	/**
 	 * Internal constructor for NetworkServerControl API. 
-	 * @param address - InetAddress to listen on, May not be null.  Throws NPE if null
-	 * @param portNumber - portNumber to listen on, -1 use propert or default.
+	 * @param address InetAddress to listen on, throws NPE if null
+	 * @param portNumber portNumber to listen on, -1 use property or default
 	 * @throws Exception on error
 	 * @see NetworkServerControl
 	 */
 	public NetworkServerControlImpl(InetAddress address, int portNumber) throws Exception
 	{
-		init();
-		getPropertyInfo();
+		this();
 		this.hostAddress = address;
 		this.portNumber = (portNumber <= 0) ?
 			this.portNumber: portNumber;
 		this.hostArg = address.getHostAddress();
 	}
 
+	/**
+	 * Internal constructor for NetworkServerControl API. 
+	 * @param userName the user name for actions requiring authorization
+	 * @param password the password for actions requiring authorization
+	 * @throws Exception on error
+	 * @see NetworkServerControl
+	 */
+	public NetworkServerControlImpl(String userName, String password)
+		throws Exception
+	{
+        this();
+		this.userArg = userName;
+		this.passwordArg = password;
+	}
+
+	/**
+	 * Internal constructor for NetworkServerControl API. 
+	 * @param address InetAddress to listen on, throws NPE if null
+	 * @param portNumber portNumber to listen on, -1 use property or default
+	 * @param userName the user name for actions requiring authorization
+	 * @param password the password for actions requiring authorization
+	 * @throws Exception on error
+	 * @see NetworkServerControl
+	 */
+	public NetworkServerControlImpl(InetAddress address, int portNumber,
+									String userName, String password)
+		throws Exception
+	{
+		this(address, portNumber);
+		this.userArg = userName;
+		this.passwordArg = password;
+	}
+
     private void init() throws Exception
     {
 
@@ -842,13 +886,22 @@
 
 			// Shutdown Derby
 			try {
-				if (cloudscapeDriver != null)
-					cloudscapeDriver.connect("jdbc:derby:;shutdown=true",
-											 (Properties) null);
+				// tell driver to shutdown the engine
+				if (cloudscapeDriver != null) {
+					// DERBY-2109: pass user credentials for driver shutdown
+					final Properties p = new Properties();
+					if (userArg != null) {
+						p.setProperty("user", userArg);
+					}
+					if (passwordArg != null) {
+						p.setProperty("password", passwordArg);
+					}
+					cloudscapeDriver.connect("jdbc:derby:;shutdown=true", p);
+				}
 			} catch (SQLException sqle) {
-				// If we can't shutdown Derby. Perhaps authentication is
-				// set to true or some other reason. We will just print a
-				// message to the console and proceed.
+				// If we can't shutdown Derby, perhaps, authentication has
+				// failed or System Privileges weren't granted. We will just
+				// print a message to the console and proceed.
 				String expectedState =
 					StandardException.getSQLStateFromIdentifier(
 							SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);
@@ -862,8 +915,6 @@
 		consolePropertyMessage("DRDA_ShutdownSuccess.I", new String [] 
 						        {att_srvclsnm, versionString, 
 								getFormattedTimestamp()});
-		
-
     }
 	
 	/** 
@@ -947,6 +998,9 @@
 	{
 		setUpSocket();
 		writeCommandHeader(COMMAND_SHUTDOWN);
+		// DERBY-2109: transmit user credentials for System Privileges check
+		writeLDString(userArg);
+		writeLDString(passwordArg);
 		send();
 		readResult();
 		// Wait up to 10 seconds for things to really shut down
@@ -985,17 +1039,97 @@
 		return;
 	}
 
+    /**
+     * Authenticates the user and checks for shutdown System Privileges.
+     * No Network communication needed.
+     *
+     * To perform this check the following policy grant is required
+     * <ul>
+     * <li> to run the encapsulated test:
+     *      permission javax.security.auth.AuthPermission "doAsPrivileged";
+     * </ul>
+     * or a SQLException will be raised detailing the cause.
+     * <p>
+     * In addition, for the test to succeed
+     * <ul>
+     * <li> the given user needs to be covered by a grant:
+     *      principal org.apache.derby.authentication.SystemPrincipal "..." {}
+     * <li> that lists a shutdown permission:
+     *      permission org.apache.derby.security.SystemPermission "shutdown";
+     * </ul>
+     * or it will fail with a SQLException detailing the cause.
+     *
+     * @param user The user to be checked for shutdown privileges
+     * @throws SQLException if the privileges check fails
+     */
+    /**
+     * @throws SQLException if authentication or privileges check fails
+     */
+    public void checkShutdownPrivileges() throws SQLException {    
+        // get the system's authentication service
+        final AuthenticationService auth
+            = ((AuthenticationService)
+               Monitor.findService(AuthenticationService.MODULE,
+                                   "authentication"));
+
+        // authenticate user
+        if (auth != null) {
+            final Properties finfo = new Properties();
+            if (userArg != null) {
+                finfo.setProperty("user", userArg);
+            }
+            if (passwordArg != null) {
+                finfo.setProperty("password", passwordArg);
+            }
+            if (!auth.authenticate((String)null, finfo)) {
+                // not a valid user
+                throw Util.generateCsSQLException(
+                SQLState.NET_CONNECT_AUTH_FAILED,
+                MessageService.getTextMessage(MessageId.AUTH_INVALID));
+            }
+        }
+
+        // approve action if not running under a security manager
+        if (System.getSecurityManager() == null) {
+            return;
+        }
+
+        // the check
+        try {
+            final Permission sp
+                = new SystemPermission(SystemPermission.SHUTDOWN);
+            // For porting the network server to J2ME/CDC, consider calling
+            // abstract method InternalDriver.checkShutdownPrivileges(user)
+            // instead of static SecurityUtil.checkUserHasPermission().
+            // SecurityUtil.checkUserHasPermission(userArg, sp);
+        } catch (AccessControlException ace) {
+            throw Util.generateCsSQLException(
+				SQLState.AUTH_SHUTDOWN_MISSING_PERMISSION,
+				userArg, (Object)ace); // overloaded method
+        }
+    }
+
 	/*
 	 Shutdown the server directly (If you have the original object)
 	 No Network communication needed.
 	*/
-	public void directShutdown() 	{
+	public void directShutdown() throws SQLException {
+		// DERBY-2109: the public shutdown method now checks privileges
+		checkShutdownPrivileges();
+		directShutdownInternal();
+	}
+	
+	/*
+	 Shutdown the server directly (If you have the original object)
+	 No Network communication needed.
+	*/
+	private void directShutdownInternal() {
+		// DERBY-2109: the direct, unchecked shutdown is made private
 		shutdown = true;
 		synchronized(shutdownSync) {						
 			// wake up the server thread
 			shutdownSync.notifyAll();
 		}
-		
 	}
 
 
@@ -1335,8 +1469,12 @@
 	 * 	Protocol:
 	 * 		1 byte		- 0 off, 1 on
 	 * 
-	 * 	Command: shutdown
-	 * 	No parameters
+	 *	Command: shutdown
+	 *		// DERBY-2109: transmit user credentials for System Privileges check
+	 *		2 bytes		- length of user name
+	 *		n bytes		- user name
+	 *		2 bytes		- length of password
+	 *		n bytes		- password
 	 * 
 	 * 	Command: sysinfo
 	 * 	No parameters
@@ -1451,8 +1589,20 @@
 			switch(command)
 			{
 				case COMMAND_SHUTDOWN:
-					sendOK(writer);
-					directShutdown();
+					// DERBY-2109: receive user credentials for shutdown
+					// System Privileges check
+					userArg = reader.readCmdString();
+					passwordArg = reader.readCmdString();
+					try {
+						checkShutdownPrivileges();
+						sendOK(writer);
+						directShutdownInternal();
+					} catch (SQLException sqle) {
+						sendSQLMessage(writer, sqle, SQLERROR);
+						// also print a message to the console
+						consolePropertyMessage("DRDA_ShutdownWarning.I",
+											   sqle.getMessage());
+					}
 					break;
 				case COMMAND_TRACE:
 					sessionArg = reader.readNetworkInt();
@@ -2212,16 +2362,15 @@
 				break;
 			case DASHARG_USER:
 				if (pos < args.length)
-				{
-					userArg = args[pos++];
-					if (pos < args.length)
-						passwordArg = args[pos];
-					else
-						consolePropertyMessage("DRDA_MissingValue.U", 
-							"DRDA_Password.I");
-				}
+					userArg = args[pos];
 				else
 					consolePropertyMessage("DRDA_MissingValue.U", "DRDA_User.I");
+				break;
+			case DASHARG_PASSWORD:
+				if (pos < args.length)
+					passwordArg = args[pos];
+				else
+					consolePropertyMessage("DRDA_MissingValue.U", "DRDA_Password.I");
 				break;
 			case DASHARG_ENCALG:
 				if (pos < args.length)

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?rev=632502&r1=632501&r2=632502&view=diff
==============================================================================
--- 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 Fri Feb
29 16:17:11 2008
@@ -119,7 +119,7 @@
 DRDA_Usage1.I=Usage: NetworkServerControl <commands> 
 DRDA_Usage2.I=Commands:
 DRDA_Usage3.I=start [-h <host>] [-p <portnumber>] [-noSecurityManager] [-ssl
<sslmode>]
-DRDA_Usage4.I=shutdown [-h <host>][-p <portnumber>] [-ssl <sslmode>]
+DRDA_Usage4.I=shutdown [-h <host>][-p <portnumber>] [-ssl <sslmode>] [-user
<username>] [-password <password>]
 DRDA_Usage5.I=ping [-h <host>][-p <portnumber>] [-ssl <sslmode>]
 DRDA_Usage6.I=sysinfo [-h <host>][-p <portnumber>] [-ssl <sslmode>]
 DRDA_Usage7.I=runtimeinfo [-h <host>][-p <portnumber>] [-ssl <sslmode>]

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java?rev=632502&r1=632501&r2=632502&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/DRDAServerStarter.java Fri
Feb 29 16:17:11 2008
@@ -84,6 +84,8 @@
 	
 	private InetAddress listenAddress =null;
 	private int portNumber = -1;
+	private String userArg = null;
+	private String passwordArg = null;
 	private PrintWriter consoleWriter = null;
 
     /**
@@ -93,6 +95,24 @@
 //     {
 
 
+	/**
+	 * Sets configuration information for the network server to be started.
+	 * @param address InetAddress to listen on
+	 * @param portNumber portNumber to listen on
+	 * @param userName the user name for actions requiring authorization
+	 * @param password the password for actions requiring authorization
+	 * @throws Exception on error
+	 * @see NetworkServerControl
+	 */
+	public void setStartInfo(InetAddress listenAddress, int portNumber,
+                             String userName, String password,
+                             PrintWriter consoleWriter)
+	{
+		this.userArg = userName;
+		this.passwordArg = password;
+        setStartInfo(listenAddress, portNumber, consoleWriter);
+    }
+
 	public void setStartInfo(InetAddress listenAddress, int portNumber, PrintWriter
 							 consoleWriter)
 	{
@@ -164,12 +184,16 @@
 						  public Object run() throws NoSuchMethodException, SecurityException
 						  {
 							  if (listenAddress == null)
-								  return serverClass.getConstructor(null);
+								  return serverClass.getConstructor(
+                                      new Class[]{String.class, String.class});
 							  else
 								  return
 									  serverClass.getConstructor(new
 										  Class[] {java.net.InetAddress.class,
-												   Integer.TYPE});}
+												   Integer.TYPE,
+                                                   String.class,
+                                                   String.class});
+                          }
 					  }
 				  );
             }
@@ -185,11 +209,14 @@
             
             findStartStopMethods(serverClass);
             
-			if (listenAddress == null)
-				server = serverConstructor.newInstance( null);
-			else
+			if (listenAddress == null) {
+				server = serverConstructor.newInstance(
+                    new Object[]{userArg, passwordArg});
+            } else {
 				server = serverConstructor.newInstance(new Object[]
-					{listenAddress, new Integer(portNumber)});
+					{listenAddress, new Integer(portNumber),
+                     userArg, passwordArg});
+            }
 
             serverThread = Monitor.getMonitor().getDaemonThread( this, "NetworkServerStarter",
false);
             serverThread.start();

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?rev=632502&r1=632501&r2=632502&view=diff
==============================================================================
--- 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
Fri Feb 29 16:17:11 2008
@@ -30,7 +30,7 @@
 Usage: NetworkServerControl <commands> 
 Commands:
 start [-h <host>] [-p <portnumber>] [-noSecurityManager] [-ssl <sslmode>]
-shutdown [-h <host>][-p <portnumber>] [-ssl <sslmode>]
+shutdown [-h <host>][-p <portnumber>] [-ssl <sslmode>] [-user <username>]
[-password <password>]
 ping [-h <host>][-p <portnumber>] [-ssl <sslmode>]
 sysinfo [-h <host>][-p <portnumber>] [-ssl <sslmode>]
 runtimeinfo [-h <host>][-p <portnumber>] [-ssl <sslmode>]

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?rev=632502&r1=632501&r2=632502&view=diff
==============================================================================
--- 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
Fri Feb 29 16:17:11 2008
@@ -10,7 +10,7 @@
 Usage: NetworkServerControl <commands> 
 Commands:
 start [-h <host>] [-p <portnumber>] [-noSecurityManager] [-ssl <sslmode>]
-shutdown [-h <host>][-p <portnumber>] [-ssl <sslmode>]
+shutdown [-h <host>][-p <portnumber>] [-ssl <sslmode>] [-user <username>]
[-password <password>]
 ping [-h <host>][-p <portnumber>] [-ssl <sslmode>]
 sysinfo [-h <host>][-p <portnumber>] [-ssl <sslmode>]
 runtimeinfo [-h <host>][-p <portnumber>] [-ssl <sslmode>]
@@ -35,7 +35,7 @@
 Usage: NetworkServerControl <commands> 
 Commands:
 start [-h <host>] [-p <portnumber>] [-noSecurityManager] [-ssl <sslmode>]
-shutdown [-h <host>][-p <portnumber>] [-ssl <sslmode>]
+shutdown [-h <host>][-p <portnumber>] [-ssl <sslmode>] [-user <username>]
[-password <password>]
 ping [-h <host>][-p <portnumber>] [-ssl <sslmode>]
 sysinfo [-h <host>][-p <portnumber>] [-ssl <sslmode>]
 runtimeinfo [-h <host>][-p <portnumber>] [-ssl <sslmode>]

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?rev=632502&r1=632501&r2=632502&view=diff
==============================================================================
--- 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
Fri Feb 29 16:17:11 2008
@@ -10,7 +10,7 @@
 Usage: NetworkServerControl <commands> 
 Commands:
 start [-h <host>] [-p <portnumber>] [-noSecurityManager] [-ssl <sslmode>]
-shutdown [-h <host>][-p <portnumber>] [-ssl <sslmode>]
+shutdown [-h <host>][-p <portnumber>] [-ssl <sslmode>] [-user <username>]
[-password <password>]
 ping [-h <host>][-p <portnumber>] [-ssl <sslmode>]
 sysinfo [-h <host>][-p <portnumber>] [-ssl <sslmode>]
 runtimeinfo [-h <host>][-p <portnumber>] [-ssl <sslmode>]
@@ -35,7 +35,7 @@
 Usage: NetworkServerControl <commands> 
 Commands:
 start [-h <host>] [-p <portnumber>] [-noSecurityManager] [-ssl <sslmode>]
-shutdown [-h <host>][-p <portnumber>] [-ssl <sslmode>]
+shutdown [-h <host>][-p <portnumber>] [-ssl <sslmode>] [-user <username>]
[-password <password>]
 ping [-h <host>][-p <portnumber>] [-ssl <sslmode>]
 sysinfo [-h <host>][-p <portnumber>] [-ssl <sslmode>]
 runtimeinfo [-h <host>][-p <portnumber>] [-ssl <sslmode>]

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java?rev=632502&r1=632501&r2=632502&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
Fri Feb 29 16:17:11 2008
@@ -398,15 +398,17 @@
     private boolean setSecurityMechanism(String derby_security_mechanism) 
     throws Exception {
         try {
-        // getting a networkservercontrol to shutdown the currently running 
-        // server, before setting the next security mechanism
-        NetworkServerControl server = new NetworkServerControl(
-            InetAddress.getByName(
-                TestConfiguration.getCurrent().getHostName()),
-                TestConfiguration.getCurrent().getPort());
+            // getting a networkservercontrol to shutdown the currently running
+            // server, before setting the next security mechanism
+            final TestConfiguration config = TestConfiguration.getCurrent();
+            NetworkServerControl server = new NetworkServerControl(
+                InetAddress.getByName(config.getHostName()),
+                config.getPort(),
+                config.getUserName(),
+                config.getUserPassword());
 
-        // shut down the server
-        server.shutdown();
+            // shut down the server
+            server.shutdown();
         } catch (Exception e) {
             if (!(e.getMessage().substring(0,17).equals("DRDA_InvalidValue")))
             {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SecureServerTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SecureServerTest.java?rev=632502&r1=632501&r2=632502&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SecureServerTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SecureServerTest.java
Fri Feb 29 16:17:11 2008
@@ -271,6 +271,10 @@
         }
 
         Test        test = TestConfiguration.defaultServerDecorator( testSetup );
+        // DERBY-2109: add support for user credentials
+        test = TestConfiguration.changeUserDecorator( test,
+                                                      SST_USER_NAME,
+                                                      SST_PASSWORD );
 
         return test;
     }
@@ -367,9 +371,12 @@
     private void    connectToServer()
         throws Exception
     {
-        String  url =
-            "jdbc:derby://localhost:" + getTestConfiguration().getPort() + "/" + "wombat;create=true"
+
-            ";user=" + SST_USER_NAME + ";password=" + SST_PASSWORD;
+        final TestConfiguration config = getTestConfiguration();
+        String  url
+            = ( "jdbc:derby://localhost:" + config.getPort()
+                + "/" + "wombat;create=true"
+                + ";user=" + config.getUserName()
+                + ";password=" + config.getUserPassword() );
 
         println( "XXX in connectToServer(). url = " + url );
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java?rev=632502&r1=632501&r2=632502&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
Fri Feb 29 16:17:11 2008
@@ -332,7 +332,7 @@
                 nsctrl.shutdown();
             }
         } catch (Exception e) {
-            return "failed to shutdown server with API parameter";
+            return "failed to shutdown server with API parameter (" + e + ")";
         }
         if (canPingServer(port,false)) {
             return "Can still ping server";

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java?rev=632502&r1=632501&r2=632502&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java
Fri Feb 29 16:17:11 2008
@@ -344,7 +344,9 @@
         boolean serverShouldBeUp =
             nsAutoBoot && fullEngineAutoBoot();
         
-        NetworkServerControl control = new NetworkServerControl();
+        String user = getTestConfiguration().getUserName();
+        String pw = getTestConfiguration().getUserPassword();
+        NetworkServerControl control = new NetworkServerControl(user, pw);
         
         boolean isServerUp = NetworkServerTestSetup.pingForServerStart(control);
         

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java?rev=632502&r1=632501&r2=632502&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
Fri Feb 29 16:17:11 2008
@@ -373,19 +373,20 @@
         throws Exception
     {
         TestConfiguration config = TestConfiguration.getCurrent();
+        final InetAddress host = InetAddress.getByName(config.getHostName());
+        final int port = config.getPort();
+        final String user = config.getUserName();
+        final String password = config.getUserPassword();
         if (config.getSsl() == null) {
-            return new NetworkServerControl
-                (InetAddress.getByName(config.getHostName()), 
-                 config.getPort());
+            return new NetworkServerControl(host, port, user, password);
         } else {
             // This is a hack. A NetworkServerControl constructor with
             // the needed interface to control sslMode (and possibly
             // more) would be better.
             String oldValue = BaseTestCase.getSystemProperty("derby.drda.sslMode");
             BaseTestCase.setSystemProperty("derby.drda.sslMode", config.getSsl());
-            NetworkServerControl control = new NetworkServerControl
-                (InetAddress.getByName(config.getHostName()), 
-                 config.getPort());
+            NetworkServerControl control
+                = new NetworkServerControl(host, port, user, password);
                
             if (oldValue == null) {
 
@@ -408,9 +409,10 @@
         throws Exception
     {
         TestConfiguration config = TestConfiguration.getCurrent();
-            return new NetworkServerControl
-            (InetAddress.getByName(config.getHostName()), 
-             port);
+        final InetAddress host = InetAddress.getByName(config.getHostName());
+        final String user = config.getUserName();
+        final String password = config.getUserPassword();
+        return new NetworkServerControl(host, port, user, password);
     }
     
     /**
@@ -422,7 +424,9 @@
         throws Exception
     {
         TestConfiguration config = TestConfiguration.getCurrent();
-            return new NetworkServerControl();
+        final String user = config.getUserName();
+        final String password = config.getUserPassword();
+        return new NetworkServerControl(user, password);
     }
     
     /**



Mime
View raw message