/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import javax.management.*;
import util.TestLogger;
/**
* <p>This class implements unit test for RMI Bootstrap.
* When called with no arguments main() looks in the directory indicated
* by the "test.src" system property for files called management*ok.properties
* or management*ko.properties. The *ok.properties files are assumed to be
* valid Java M&M config files for which the bootstrap should succeed.
* The *ko.properties files are assumed to be configurations for which the
* bootstrap & connection test will fail.</p>
*
* <p>The rmi port number can be specified with the "rmi.port" system property.
* If not, this test will use 12424</p>
*
* <p>When called with some argument, the main() will interprete its args to
* be Java M&M configuration file names. The filenames are expected to end
* with ok.properties or ko.properties - and are interpreted as above.</p>
*
* <p>Note that a limitation of the RMI registry (bug 4267864) prevent
* this test from succeeding if more than 1 configuration is used.
* As long as 4267864 isn't fix, this test must be called as many times
* as needed but with a single argument (no arguments, or several arguments
* will fail).</p>
*
* <p>Debug traces are logged in "sun.management.test"</p>
**/
public class RmiSslNoKeyStoreTest {
new TestLogger("RmiSslNoKeyStoreTest");
/**
* When launching several registries, we increment the port number
* to avoid falling into "port number already in use" problems.
**/
/**
* Default values for RMI configuration properties.
**/
public static interface DefaultValues {
}
/**
* Names of RMI configuration properties.
**/
public static interface PropertyNames {
"com.sun.management.config.file";
"com.sun.management.jmxremote.authenticate";
"com.sun.management.jmxremote.password.file";
"com.sun.management.jmxremote.access.file";
"com.sun.management.instrumentall";
"jmx.remote.credentials";
"javax.net.ssl.keyStorePassword";
"javax.net.ssl.trustStorePassword";
}
/**
* Compute the full path name for a default file.
* @param basename basename (with extension) of the default file.
* @return ${JRE}/lib/management/${basename}
**/
final StringBuffer defaultFileName =
return defaultFileName.toString();
}
/**
* Compute the full path name for a default file.
* @param basename basename (with extension) of the default file.
* @return ${JRE}/lib/management/${basename}
**/
final StringBuffer defaultFileName =
return defaultFileName.toString();
}
throws IOException, GeneralSecurityException {
throw new IllegalArgumentException("System property " +
" not specified");
final String keyStorePass =
if (keyStorePass == null) {
// We don't have the password, we can only check whether the
// file exists...
//
throw new IllegalArgumentException("System property " +
" not specified");
}
// Now we're going to load the keyStore - just to check it's
// correct.
//
final String keyStoreType =
try {
} finally {
}
}
final String defaultConf =
}
// Do we use SSL?
final boolean useSsl =
if (useSsl == false) {
throw new IllegalArgumentException(msg);
}
try {
} catch (Exception x) {
// Ok!
return;
}
throw new IllegalArgumentException(msg);
}
/**
* Test the configuration indicated by `file'.
* Sets the appropriate System properties for config file and
* port and then calls ConnectorBootstrap.initialize().
* eventually cleans up by calling ConnectorBootstrap.terminate().
* @return null if the test succeeds, an error message otherwise.
**/
try {
else
remove("com.sun.management.config.file");
"com.sun.management.config.file="+path);
final JMXConnectorServer cs;
try {
} catch (AgentConfigurationError x) {
"\n\tcom.sun.management.jmxremote.port=" + port +
"\n\t"+config) +
"\n\tError is: " + x;
return null;
} catch (Exception x) {
return x.toString();
}
try {
} catch (IOException x) {
"\n\tcom.sun.management.jmxremote.port=" + port +
"\n\t"+config) +
"\n\tError is: " + x;
return null;
} catch (Exception x) {
return x.toString();
}
try {
} catch (Exception x) {
}
"\n\tcom.sun.management.jmxremote.port=" + port +
"\n\t"+config);
return err;
} catch (Exception x) {
"\n\tcom.sun.management.jmxremote.port=" + port +
"\n\t"+config)+
"\n\tError is: " + x;
return err;
}
}
/**
* Test a configuration file. Determines whether the bootstrap
* should succeed or fail depending on the file name:
* *ok.properties: bootstrap should succeed.
* *ko.properties: bootstrap or connection should fail.
* @return null if the test succeeds, an error message otherwise.
**/
}
/**
* Tests the specified configuration files.
* If args[] is not empty, each element in args[] is expected to be
* a filename ending either by ok.properties or ko.properties.
* Otherwise, the configuration files will be automatically determined
* by looking at all *.properties files located in the directory
* indicated by the System property "test.src".
* @throws RuntimeException if the test fails.
**/
final String defaultKeyStore =
throw new RuntimeException(errStr);
}
try {
// Specify the keystore, but don't specify the
// password.
//
throw new RuntimeException(errStr);
}
} finally {
}
}
}
}
/**
* Calls run(args[]).
* exit(1) if the test fails.
**/
try {
} catch (RuntimeException r) {
} catch (Throwable t) {
t.printStackTrace();
}
}
}