You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2006/03/01 14:55:09 UTC
svn commit: r382019 - in /db/derby/code/trunk/java:
drda/org/apache/derby/impl/drda/ engine/org/apache/derby/iapi/reference/
testing/org/apache/derbyTesting/functionTests/master/
testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ testing/or...
Author: kmarsden
Date: Wed Mar 1 05:55:05 2006
New Revision: 382019
URL: http://svn.apache.org/viewcvs?rev=382019&view=rev
Log:
DERBY-928 Add ability to network server to accept connections with a certain security mechanism.
Add derby.drda.securityMechanism property to restrict securityMechanisms accepted from client
Detailed description of patch in bug
https://issues.apache.org/jira/browse/DERBY-928#action_12366294
Contrbuted by Sunitha Kambhampati
Added:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/sysinfo_withproperties.out (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_app.properties (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_derby.properties (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_sed.properties (with props)
Modified:
db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/testSecMec.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/testSecMec.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/copyfiles.ant
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testSecMec.java
Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=382019&r1=382018&r2=382019&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Wed Mar 1 05:55:05 2006
@@ -1571,27 +1571,44 @@
securityMechanism = reader.readNetworkShort();
if (SanityManager.DEBUG)
trace("Security mechanism = " + securityMechanism);
- // for plain text userid,password USRIDPWD, and USRIDONL
- // no need of decryptionManager
- if (securityMechanism != CodePoint.SECMEC_USRIDPWD &&
- securityMechanism != CodePoint.SECMEC_USRIDONL)
- {
- //this is the only other one we understand
- if (securityMechanism != CodePoint.SECMEC_EUSRIDPWD)
- securityCheckCode = CodePoint.SECCHKCD_NOTSUPPORTED;
- else
- {
- try {
- if (decryptionManager == null)
- decryptionManager = new DecryptionManager();
- myPublicKey = decryptionManager.obtainPublicKey();
- } catch (SQLException e) {
- println2Log(null, session.drdaID, e.getMessage());
- // Local security service non-retryable error.
- securityCheckCode = CodePoint.SECCHKCD_0A;
- }
- }
- }
+
+ // if Property.DRDA_PROP_SECURITYMECHANISM has been set, then
+ // network server only accepts connections which use that
+ // security mechanism. No other types of connections
+ // are accepted.
+ // Make check to see if this property has been set.
+ // if set, and if the client requested security mechanism
+ // is not the same, then return a security check code
+ // that the server does not support/allow this security
+ // mechanism
+ if ( (server.getSecurityMechanism() !=
+ NetworkServerControlImpl.INVALID_OR_NOTSET_SECURITYMECHANISM)
+ && securityMechanism != server.getSecurityMechanism())
+ securityCheckCode = CodePoint.SECCHKCD_NOTSUPPORTED;
+ else
+ {
+ // for plain text userid,password USRIDPWD, and USRIDONL
+ // no need of decryptionManager
+ if (securityMechanism != CodePoint.SECMEC_USRIDPWD &&
+ securityMechanism != CodePoint.SECMEC_USRIDONL)
+ {
+ //this is the only other one we understand
+ if (securityMechanism != CodePoint.SECMEC_EUSRIDPWD)
+ securityCheckCode = CodePoint.SECCHKCD_NOTSUPPORTED;
+ else
+ {
+ try {
+ if (decryptionManager == null)
+ decryptionManager = new DecryptionManager();
+ myPublicKey = decryptionManager.obtainPublicKey();
+ } catch (SQLException e) {
+ println2Log(null, session.drdaID, e.getMessage());
+ // Local security service non-retryable error.
+ securityCheckCode = CodePoint.SECCHKCD_0A;
+ }
+ }
+ }
+ }
break;
//optional (currently required for Cloudscape - may need to revisit)
case CodePoint.RDBNAM:
@@ -2487,10 +2504,25 @@
writer.writeScalar2Bytes(CodePoint.SECMEC, database.securityMechanism);
else
{
- // these are the ones we know about
- writer.writeScalar2Bytes(CodePoint.SECMEC, CodePoint.SECMEC_USRIDPWD);
- writer.writeScalar2Bytes(CodePoint.SECMEC, CodePoint.SECMEC_EUSRIDPWD);
- writer.writeScalar2Bytes(CodePoint.SECMEC, CodePoint.SECMEC_USRIDONL);
+ // if server doesnt recognize or allow the client requested security mechanism,
+ // then need to return the list of security mechanisms supported/allowed by the server
+
+ // check if server is set to accept connections from client at a certain
+ // security mechanism, if so send only the security mechanism that the
+ // server will accept, to the client
+ if ( server.getSecurityMechanism() != NetworkServerControlImpl.INVALID_OR_NOTSET_SECURITYMECHANISM )
+ writer.writeScalar2Bytes(CodePoint.SECMEC,server.getSecurityMechanism());
+ else
+ {
+ // note: per the DDM manual , ACCSECRD response is of
+ // form SECMEC (value{value..})
+ // Need to fix the below to send a list of supported security
+ // mechanisms for value of one SECMEC codepoint (JIRA 926)
+ // these are the ones we know about
+ writer.writeScalar2Bytes(CodePoint.SECMEC, CodePoint.SECMEC_USRIDPWD);
+ writer.writeScalar2Bytes(CodePoint.SECMEC, CodePoint.SECMEC_EUSRIDPWD);
+ writer.writeScalar2Bytes(CodePoint.SECMEC, CodePoint.SECMEC_USRIDONL);
+ }
}
if (securityCheckCode != 0)
{
Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=382019&r1=382018&r2=382019&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 Wed Mar 1 05:55:05 2006
@@ -243,6 +243,11 @@
private boolean cleanupOnStart = false; // Should we clean up when starting the server?
private boolean restartFlag = false;
+ protected final static int INVALID_OR_NOTSET_SECURITYMECHANISM = -1;
+ // variable to store value set to derby.drda.securityMechanism
+ // default value is -1 which indicates that this property isnt set or
+ // the value is invalid
+ private int allowOnlySecurityMechanism = INVALID_OR_NOTSET_SECURITYMECHANISM;
//
// variables for a client command session
//
@@ -2484,8 +2489,60 @@
if (propval != null && StringUtil.SQLEqualsIgnoreCase(propval, "true"))
debugOutput = true;
+ propval = PropertyUtil.getSystemProperty(
+ Property.DRDA_PROP_SECURITYMECHANISM);
+ if (propval != null){
+ setSecurityMechanism(propval);
+ }
+
}
+ /**
+ * Retrieve the SECMEC integer value from the
+ * user friendly security mechanism name
+ * @param s security mechanism name
+ * @return integer value , return the SECMEC value for
+ * the security mechanism as defined by DRDA spec
+ * or INVALID_OR_NOTSET_SECURITYMECHANISM if 's'
+ * passed is invalid or not supported security
+ * mechanism
+ */
+ private int getSecMecValue(String s)
+ {
+ int secmec = INVALID_OR_NOTSET_SECURITYMECHANISM;
+ if( StringUtil.SQLEqualsIgnoreCase(s,"USER_ONLY_SECURITY"))
+ secmec = CodePoint.SECMEC_USRIDONL;
+ else if( StringUtil.SQLEqualsIgnoreCase(s,"CLEAR_TEXT_PASSWORD_SECURITY"))
+ secmec = CodePoint.SECMEC_USRIDPWD;
+ else if( StringUtil.SQLEqualsIgnoreCase(s,"ENCRYPTED_USER_AND_PASSWORD_SECURITY"))
+ secmec = CodePoint.SECMEC_EUSRIDPWD;
+
+ return secmec;
+ }
+
+ /**
+ * Retrieve the string name for the integer
+ * secmec value
+ * @param secmecVal secmec value
+ * @return String - return the string name corresponding
+ * to the secmec value if recognized else returns null
+ */
+ private String getStringValueForSecMec(int secmecVal)
+ {
+ switch(secmecVal)
+ {
+ case CodePoint.SECMEC_USRIDONL:
+ return "USER_ONLY_SECURITY";
+
+ case CodePoint.SECMEC_USRIDPWD:
+ return "CLEAR_TEXT_PASSWORD_SECURITY";
+
+ case CodePoint.SECMEC_EUSRIDPWD:
+ return "ENCRYPTED_USER_AND_PASSWORD_SECURITY";
+ }
+ return null;
+ }
+
/**
* Get integer property values
*
@@ -2819,6 +2876,38 @@
}
/**
+ * Set the security mechanism for derby.drda.securityMechanism
+ * If this property is set, server will only allow connections
+ * from client with this security mechanism.
+ * This method will map the user friendly string representing
+ * the security mechanism to the corresponding drda secmec value
+ * @param s security mechanism string value
+ * @throws Exception if value to set is invalid
+ * @see Property#DRDA_PROP_SECURITYMECHANISM
+ */
+ private void setSecurityMechanism(String s)
+ throws Exception
+ {
+ allowOnlySecurityMechanism = getSecMecValue(s);
+
+ if (allowOnlySecurityMechanism == INVALID_OR_NOTSET_SECURITYMECHANISM)
+ consolePropertyMessage("DRDA_InvalidValue.U", new String []
+ {s, Property.DRDA_PROP_SECURITYMECHANISM});
+ }
+
+ /**
+ * get the security mechanism (secmec value) that the server
+ * will accept connections from.
+ * @return the securitymechanism value. It is value that
+ * the derby.drda.securityMechanism was set to, if it is not set, then
+ * it is equal to INVALID_OR_NOTSET_SECURITYMECHANISM
+ * @see Property#DRDA_PROP_SECURITYMECHANISM
+ */
+ protected int getSecurityMechanism()
+ {
+ return allowOnlySecurityMechanism;
+ }
+ /**
* Set the trace on/off for all sessions, or one session, depending on
* whether we got -s argument.
*
@@ -2991,6 +3080,8 @@
}
}
+
+
/**
* Connect to a database to test whether a connection can be made
*
@@ -3172,6 +3263,12 @@
retval.put(Property.START_DRDA, (startDRDA == null)? "false" : startDRDA);
+ // if Property.DRDA_PROP_SECURITYMECHANISM has been set on server
+ // then put it in retval else the default behavior is as though
+ // it is not set
+ if ( getSecurityMechanism() != INVALID_OR_NOTSET_SECURITYMECHANISM )
+ retval.put( Property.DRDA_PROP_SECURITYMECHANISM, getStringValueForSecMec(getSecurityMechanism()));
+
//get the trace value for each session if tracing for all is not set
if (!getTraceAll())
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java?rev=382019&r1=382018&r2=382019&view=diff
==============================================================================
--- 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 Wed Mar 1 05:55:05 2006
@@ -762,6 +762,29 @@
public final static String DRDA_PROP_TIMESLICE = "derby.drda.timeSlice";
/**
+ * derby.drda.securityMechanism
+ *<BR>
+ * This property can be set to one of the following values
+ * USER_ONLY_SECURITY
+ * CLEAR_TEXT_PASSWORD_SECURITY
+ * ENCRYPTED_USER_AND_PASSWORD_SECURITY
+ * <BR>
+ * if derby.drda.securityMechanism is set to a valid mechanism, then
+ * the Network Server accepts only connections which use that
+ * security mechanism. No other types of connections are accepted.
+ * <BR>
+ * if the derby.drda.securityMechanism is not set at all, then the
+ * Network Server accepts any connection which uses a valid
+ * security mechanism.
+ * <BR>
+ * E.g derby.drda.securityMechanism=USER_ONLY_SECURITY
+ * This property is static. Server must be restarted for the property to take effect.
+ * Default value for this property is as though it is not set - in which case
+ * the server will allow clients with supported security mechanisms to connect
+ */
+ public final static String DRDA_PROP_SECURITYMECHANISM = "derby.drda.securityMechanism";
+
+ /**
* derby.drda.portNumber
*<BR>
* The port number used by the network server.
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/testSecMec.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/testSecMec.out?rev=382019&r1=382018&r2=382019&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/testSecMec.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/testSecMec.out Wed Mar 1 05:55:05 2006
@@ -1,3 +1,5 @@
+-----
+Testing with derby.drda.securityMechanism=null
Checking security mechanism authentication with DriverManager
T4: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;create=true:user=neelima;password=lee;securityMechanism=3;
T1: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat - EXCEPTION null userid not supported
@@ -6,4 +8,40 @@
T6: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;securityMechanism=4;
T8: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;password=lee;securityMechanism=4;
SECMEC_USRIDPWD: OK
+-----
+Testing with derby.drda.securityMechanism=USER_ONLY_SECURITY
+Checking security mechanism authentication with DriverManager
+T4: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;password=lee;securityMechanism=3; - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T1: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat - EXCEPTION null userid not supported
+T2: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=max; - EXCEPTION null password not supported
+T3: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;password=lee; - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T6: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;securityMechanism=4;
+T8: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;password=lee;securityMechanism=4;
+SECMEC_USRIDPWD:EXCEPTION testSecurityMechanism() Connection authorization failure occurred. Reason: security mechanism not supported
+-----
+Testing with derby.drda.securityMechanism=CLEAR_TEXT_PASSWORD_SECURITY
+Checking security mechanism authentication with DriverManager
+T4: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;password=lee;securityMechanism=3;
+T1: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat - EXCEPTION null userid not supported
+T2: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=max; - EXCEPTION null password not supported
+T3: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;password=lee;
+T6: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;securityMechanism=4; - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T8: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;password=lee;securityMechanism=4; - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+SECMEC_USRIDPWD: OK
+-----
+Testing with derby.drda.securityMechanism=ENCRYPTED_USER_AND_PASSWORD_SECURITY
+Checking security mechanism authentication with DriverManager
+T4: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;password=lee;securityMechanism=3; - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T1: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat - EXCEPTION null userid not supported
+T2: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=max; - EXCEPTION null password not supported
+T3: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;password=lee; - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T6: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;securityMechanism=4; - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T8: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat:user=neelima;password=lee;securityMechanism=4; - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+SECMEC_USRIDPWD:EXCEPTION testSecurityMechanism() Connection authorization failure occurred. Reason: security mechanism not supported
+-----
+Testing with derby.drda.securityMechanism=INVALID_VALUE
+EXPECTED EXCEPTION DRDA_InvalidValue.U:Invalid value, INVALID_VALUE, for derby.drda.securityMechanism.
+-----
+Testing with derby.drda.securityMechanism=
+EXPECTED EXCEPTION DRDA_InvalidValue.U:Invalid value, , for derby.drda.securityMechanism.
Completed testSecMec
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/testSecMec.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/testSecMec.out?rev=382019&r1=382018&r2=382019&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/testSecMec.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/testSecMec.out Wed Mar 1 05:55:05 2006
@@ -1,3 +1,5 @@
+-----
+Testing with derby.drda.securityMechanism=null
Checking security mechanism authentication with DriverManager
T4: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;create=true;user=neelima;password=lee;securityMechanism=3
T1: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat
@@ -6,4 +8,40 @@
T6: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;securityMechanism=4
T8: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;password=lee;securityMechanism=4
SECMEC_USRIDPWD: OK
+-----
+Testing with derby.drda.securityMechanism=USER_ONLY_SECURITY
+Checking security mechanism authentication with DriverManager
+T4: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;password=lee;securityMechanism=3 - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T1: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat
+T2: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=max
+T3: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;password=lee - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T6: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;securityMechanism=4
+T8: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;password=lee;securityMechanism=4 - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+SECMEC_USRIDPWD:EXCEPTION testSecurityMechanism() Connection authorization failure occurred. Reason: security mechanism not supported
+-----
+Testing with derby.drda.securityMechanism=CLEAR_TEXT_PASSWORD_SECURITY
+Checking security mechanism authentication with DriverManager
+T4: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;password=lee;securityMechanism=3
+T1: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T2: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=max - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T3: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;password=lee
+T6: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;securityMechanism=4 - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T8: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;password=lee;securityMechanism=4
+SECMEC_USRIDPWD: OK
+-----
+Testing with derby.drda.securityMechanism=ENCRYPTED_USER_AND_PASSWORD_SECURITY
+Checking security mechanism authentication with DriverManager
+T4: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;password=lee;securityMechanism=3 - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T1: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T2: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=max - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T3: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;password=lee - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T6: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;securityMechanism=4 - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+T8: jdbc:derby://xxxFILTERED_HOSTNAMExxx:xxxFILTEREDPORTxxx/wombat;user=neelima;password=lee;securityMechanism=4 - EXCEPTION Connection authorization failure occurred. Reason: security mechanism not supported
+SECMEC_USRIDPWD:EXCEPTION testSecurityMechanism() Connection authorization failure occurred. Reason: security mechanism not supported
+-----
+Testing with derby.drda.securityMechanism=INVALID_VALUE
+EXPECTED EXCEPTION DRDA_InvalidValue.U:Invalid value, INVALID_VALUE, for derby.drda.securityMechanism.
+-----
+Testing with derby.drda.securityMechanism=
+EXPECTED EXCEPTION DRDA_InvalidValue.U:Invalid value, , for derby.drda.securityMechanism.
Completed testSecMec
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/sysinfo_withproperties.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/sysinfo_withproperties.out?rev=382019&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/sysinfo_withproperties.out (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/sysinfo_withproperties.out Wed Mar 1 05:55:05 2006
@@ -0,0 +1,86 @@
+Testing Sysinfo
+org.apache.derby.drda.NetworkServerControl sysinfo
+----- Derby Network Server Information --------
+----- listing properties --
+derby.drda.securityMechanism=USER_ONLY_SECURITY
+derby.drda.maxThreads=0
+derby.drda.keepAlive=true
+derby.drda.minThreads=0
+derby.drda.portNumber=1527
+derby.drda.logConnections=false
+derby.drda.timeSlice=0
+derby.drda.startNetworkServer=false
+derby.drda.host=xxxFILTERED_HOSTNAMExxx
+derby.drda.traceAll=false
+----- Derby Information --------
+-----
+----- Locale Information -----------------
+Current Locale : [English/United States [en_US]]
+Found support for locale: [de_DE]
+Found support for locale: [es]
+Found support for locale: [fr]
+Found support for locale: [it]
+Found support for locale: [ja_JP]
+Found support for locale: [ko_KR]
+Found support for locale: [pt_BR]
+Found support for locale: [zh_CN]
+Found support for locale: [zh_TW]
+-----
+End test
+Testing Sysinfo (method)
+----- Derby Network Server Information --------
+----- listing properties --
+derby.drda.securityMechanism=USER_ONLY_SECURITY
+derby.drda.maxThreads=0
+derby.drda.keepAlive=true
+derby.drda.minThreads=0
+derby.drda.portNumber=1527
+derby.drda.logConnections=false
+derby.drda.timeSlice=0
+derby.drda.startNetworkServer=false
+derby.drda.host=xxxFILTERED_HOSTNAMExxx
+derby.drda.traceAll=false
+----- Derby Information --------
+-----
+----- Locale Information -----------------
+Current Locale : [English/United States [en_US]]
+Found support for locale: [de_DE]
+Found support for locale: [es]
+Found support for locale: [fr]
+Found support for locale: [it]
+Found support for locale: [ja_JP]
+Found support for locale: [ko_KR]
+Found support for locale: [pt_BR]
+Found support for locale: [zh_CN]
+Found support for locale: [zh_TW]
+-----
+End test (method)
+Testing Sysinfo (locale)
+-----Duser.language=err -Duser.country=DE org.apache.derby.drda.NetworkServerControl sysinfo
+----- Derby Network Server Information --------
+----- listing properties --
+derby.drda.securityMechanism=USER_ONLY_SECURITY
+derby.drda.maxThreads=0
+derby.drda.keepAlive=true
+derby.drda.minThreads=0
+derby.drda.portNumber=1527
+derby.drda.logConnections=false
+derby.drda.timeSlice=0
+derby.drda.startNetworkServer=false
+derby.drda.host=xxxFILTERED_HOSTNAMExxx
+derby.drda.traceAll=false
+----- Derby Information --------
+-----
+----- Locale Information -----------------
+Current Locale : [English/United States [en_US]]
+Found support for locale: [de_DE]
+Found support for locale: [es]
+Found support for locale: [fr]
+Found support for locale: [it]
+Found support for locale: [ja_JP]
+Found support for locale: [ko_KR]
+Found support for locale: [pt_BR]
+Found support for locale: [zh_CN]
+Found support for locale: [zh_TW]
+-----
+End test (locale)
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/sysinfo_withproperties.out
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall?rev=382019&r1=382018&r2=382019&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall Wed Mar 1 05:55:05 2006
@@ -13,6 +13,7 @@
derbynet/prepStmt.java
derbynet/runtimeinfo.java
derbynet/sysinfo.java
+derbynet/sysinfo_withproperties.java
derbynet/testProtocol.java
derbynet/testProperties.java
derbynet/testconnection.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/copyfiles.ant
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/copyfiles.ant?rev=382019&r1=382018&r2=382019&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/copyfiles.ant (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/copyfiles.ant Wed Mar 1 05:55:05 2006
@@ -14,6 +14,9 @@
runtimeinfo_sed.properties
sysinfo_app.properties
sysinfo_sed.properties
+sysinfo_withproperties_app.properties
+sysinfo_withproperties_sed.properties
+sysinfo_withproperties_derby.properties
testij.sql
testclientij.sql
testconnection_app.properties
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo.java?rev=382019&r1=382018&r2=382019&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo.java Wed Mar 1 05:55:05 2006
@@ -96,7 +96,12 @@
}
- public static void main (String args[]) throws Exception
+ /*
+ * Test calling server's sysinfo
+ *
+ */
+ public static void test (String args[])
+ throws Exception
{
if ((System.getProperty("java.vm.name") != null) && System.getProperty("java.vm.name").equals("J9"))
jvm = jvm.getJvm("j9_13");
@@ -137,5 +142,11 @@
e.printStackTrace();
}
}
+
+ public static void main(String[] args)
+ throws Exception
+ {
+ test(args);
+ }
}
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.java?rev=382019&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.java Wed Mar 1 05:55:05 2006
@@ -0,0 +1,41 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.tests.derbynet.sysinfo_withproperties
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed 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.derbyTesting.functionTests.tests.derbynet;
+
+/**
+ Purpose of this class is to test the sysinfo command when
+ server is started with some drda properties. The derby properties
+ in the test harness framework are added to
+ sysinfo_withproperties_derby.properties.
+
+ Most of the work of calling sysinfo is done in sysinfo.
+ @see sysinfo#test
+*/
+
+public class sysinfo_withproperties
+{
+ public static void main (String args[]) throws Exception
+ {
+ // test the sysinfo calls.
+ sysinfo.test(args);
+
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_app.properties?rev=382019&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_app.properties (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_app.properties Wed Mar 1 05:55:05 2006
@@ -0,0 +1,9 @@
+usedefaults=true
+
+#exclude with SecurityManager
+# test execs another jvm with a relative path that means
+# the permission FilePermission("<<ALL FILES>>","execute")
+# would be required. Don't want to grant such a wide permission
+# to the testing jar.
+noSecurityManager=true
+
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_app.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_derby.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_derby.properties?rev=382019&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_derby.properties (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_derby.properties Wed Mar 1 05:55:05 2006
@@ -0,0 +1,10 @@
+#
+# *** DO NOT PUT PROPERTIES FOR THE JAVA ENVIRONMENT IN THIS FILE.
+# *** THEY BELONG IN default_app.properties.
+#
+#defaults
+derby.infolog.append=true
+derby.locks.waitTimeout=120
+derby.language.logStatementText=true
+#drda property ,test for it in sysinfo output
+derby.drda.securityMechanism=USER_ONLY_SECURITY
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_derby.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_sed.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_sed.properties?rev=382019&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_sed.properties (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_sed.properties Wed Mar 1 05:55:05 2006
@@ -0,0 +1 @@
+delete=Version,version,Java,OS,[0-9*].[0-9*].[0-9*],JRE - JDBC,traceDirectory
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_sed.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testSecMec.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testSecMec.java?rev=382019&r1=382018&r2=382019&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testSecMec.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testSecMec.java Wed Mar 1 05:55:05 2006
@@ -53,6 +53,15 @@
{
+ // Need this to keep track of database has been created or not
+ // to avoid case of DERBY-300
+ private static boolean dbNotCreated = true;
+
+ // values for derby.drda.securityMechanism property
+ private static String[] derby_drda_securityMechanism = { null, //not set
+ "USER_ONLY_SECURITY", "CLEAR_TEXT_PASSWORD_SECURITY",
+ "ENCRYPTED_USER_AND_PASSWORD_SECURITY", "INVALID_VALUE", "" };
+
private static int NETWORKSERVER_PORT;
private static NetworkServerControl networkServer = null;
@@ -113,52 +122,82 @@
System.setOut( consoleLogStream );
System.setErr( consoleErrLogStream );
- // Start the NetworkServer on another thread, unless it's a remote host
- if (hostName.equals("localhost"))
+
+ // Start server with a specific value for derby.drda.securityMechanism
+ // and run tests. Note connections will be successful or not depending on
+ // derby.drda.securityMechanism property specified on the server (DERBY-928)
+ // @see
+ // org.apache.derby.iapi.reference.Property#DRDA_PROP_SECURITYMECHANISM
+ for ( int i = 0; i < derby_drda_securityMechanism.length; i++)
{
- networkServer = new NetworkServerControl(InetAddress.getByName(hostName),NETWORKSERVER_PORT);
- networkServer.start(null);
-
- // Wait for the NetworkServer to start.
- if (!isServerStarted(networkServer, 60))
- System.exit(-1);
- }
-
- // Now, go ahead and run the test.
- try {
- testSecMec tester =
- new testSecMec(consoleLogStream,
- originalStream,
- shutdownLogStream,
- consoleErrLogStream,
- originalErrStream,
- shutdownErrLogStream);
- tester.runTest();
-
- } catch (Exception e) {
- // if we catch an exception of some sort, we need to make sure to
- // close our streams before returning; otherwise, we can get
- // hangs in the harness. SO, catching all exceptions here keeps
- // us from exiting before closing the necessary streams.
- System.out.println("FAIL - Exiting due to unexpected error: " +
- e.getMessage());
- e.printStackTrace();
- }
-
- // Shutdown the server.
- if (hostName.equals("localhost"))
+ if (derby_drda_securityMechanism[i]!=null)
+ System.setProperty("derby.drda.securityMechanism",derby_drda_securityMechanism[i]);
+
+ System.out.println("----------------------------------------------");
+ System.out.println("Testing with derby.drda.securityMechanism="+
+ System.getProperty("derby.drda.securityMechanism"));
+ // Start the NetworkServer on another thread, unless it's a remote host
+ if (hostName.equals("localhost"))
{
- consoleLogStream.switchOutput( shutdownLogStream );
- consoleErrLogStream.switchOutput( shutdownErrLogStream );
-
- networkServer.shutdown();
- // how do we do this with the new api?
- //networkServer.join();
- Thread.sleep(5000);
-
- consoleLogStream.switchOutput( originalStream );
- consoleErrLogStream.switchOutput( originalErrStream );
-
+ try
+ {
+ networkServer = new NetworkServerControl(InetAddress.getByName(hostName),NETWORKSERVER_PORT);
+ networkServer.start(null);
+ }catch(Exception e)
+ {
+ if ( derby_drda_securityMechanism[i].equals("INVALID_VALUE")||
+ derby_drda_securityMechanism[i].equals(""))
+ {
+ System.out.println("EXPECTED EXCEPTION "+ e.getMessage());
+ continue;
+ }
+ }
+
+ // Wait for the NetworkServer to start.
+ if (!isServerStarted(networkServer, 60))
+ System.exit(-1);
+ }
+
+ // Now, go ahead and run the test.
+ try {
+ testSecMec tester =
+ new testSecMec(consoleLogStream,
+ originalStream,
+ shutdownLogStream,
+ consoleErrLogStream,
+ originalErrStream,
+ shutdownErrLogStream);
+ // Now run the test, note connections will be successful or
+ // throw an exception depending on derby.drda.securityMechanism
+ // property specified on the server
+ tester.runTest();
+
+ } catch (Exception e) {
+ // if we catch an exception of some sort, we need to make sure to
+ // close our streams before returning; otherwise, we can get
+ // hangs in the harness. SO, catching all exceptions here keeps
+ // us from exiting before closing the necessary streams.
+ System.out.println("FAIL - Exiting due to unexpected error: " +
+ e.getMessage());
+ e.printStackTrace();
+ }
+
+ // Shutdown the server.
+ if (hostName.equals("localhost"))
+ {
+ consoleLogStream.switchOutput( shutdownLogStream );
+ consoleErrLogStream.switchOutput( shutdownErrLogStream );
+
+ networkServer.shutdown();
+ consoleLogStream.flush();
+ // how do we do this with the new api?
+ //networkServer.join();
+ Thread.sleep(5000);
+
+ consoleLogStream.switchOutput( originalStream );
+ consoleErrLogStream.switchOutput( originalErrStream );
+
+ }
}
System.out.println("Completed testSecMec");
@@ -200,6 +239,11 @@
* Test with datasource as well as DriverManager
* T8 - user,password security mechanism set to SECMEC_USRIDONL PASS
* Test with datasource as well as DriverManager
+ * Note, that with DERBY928, the pass/fail for the connections
+ * will depend on the security mechanism specified at the server by property
+ * derby.drda.securityMechanism. Please check out the following html file
+ * http://issues.apache.org/jira/secure/attachment/12322971/Derby928_Table_SecurityMechanisms..htm
+ * for a combination of url/security mechanisms and the expected results
*/
protected void runTest()
@@ -208,7 +252,18 @@
// different security mechanisms.
// Network server supports SECMEC_USRIDPWD, SECMEC_USRIDONL,SECMEC_EUSRIDPWD
System.out.println("Checking security mechanism authentication with DriverManager");
- getConnectionUsingDriverManager(getJDBCUrl("wombat;create=true","user=neelima;password=lee;securityMechanism="+SECMEC_USRIDPWD),"T4:");
+
+ // DERBY-300; Creation of SQLWarning on a getConnection causes hang on
+ // 131 vms when server and client are in same vm.
+ // To avoid hitting this case with 1.3.1 vms, dont try to send create=true
+ // if database is already created as otherwise it will lead to a SQLWarning
+ if ( dbNotCreated )
+ {
+ getConnectionUsingDriverManager(getJDBCUrl("wombat;create=true","user=neelima;password=lee;securityMechanism="+SECMEC_USRIDPWD),"T4:");
+ dbNotCreated = false;
+ }
+ else
+ getConnectionUsingDriverManager(getJDBCUrl("wombat","user=neelima;password=lee;securityMechanism="+SECMEC_USRIDPWD),"T4:");
getConnectionUsingDriverManager(getJDBCUrl("wombat",null),"T1:");
getConnectionUsingDriverManager(getJDBCUrl("wombat","user=max"),"T2:");
getConnectionUsingDriverManager(getJDBCUrl("wombat","user=neelima;password=lee"),"T3:");