Search in sources :

Example 1 with TLSParams

use of com.sun.appserv.management.client.TLSParams in project Payara by payara.

the class TestRunner method testAppserverConnectionSource.

/**
 *     Comment in call to this for hard-coded test.
 */
private void testAppserverConnectionSource(final String host, final String user, final String password) throws IOException {
    MBeanServerConnection conn = null;
    final TestClientTrustStoreTrustManager tm = new TestClientTrustStoreTrustManager();
    final HandshakeCompletedListenerImpl hcl = new HandshakeCompletedListenerImpl();
    tm.setPrompt(true);
    final TLSParams tlsParams = new TLSParams(new X509TrustManager[] { tm }, hcl);
    println("\ntestAppserverConnectionSource: testing: " + AppserverConnectionSource.PROTOCOL_RMI);
    final ConnectionSource rmiSource = new AppserverConnectionSource(AppserverConnectionSource.PROTOCOL_RMI, host, 8686, user, password, null);
    conn = rmiSource.getMBeanServerConnection(true);
    conn.isRegistered(JMXUtil.getMBeanServerDelegateObjectName());
    println(AppserverConnectionSource.PROTOCOL_RMI + " OK using " + rmiSource);
    println("\ntestAppserverConnectionSource: testing: " + AppserverConnectionSource.PROTOCOL_HTTP);
    final Map<String, String> env = Collections.emptyMap();
    final ConnectionSource httpSource = new AppserverConnectionSource(AppserverConnectionSource.PROTOCOL_HTTP, host, 1234, user, password, tlsParams, env);
    conn = httpSource.getMBeanServerConnection(true);
    assert conn.isRegistered(JMXUtil.getMBeanServerDelegateObjectName());
    println(AppserverConnectionSource.PROTOCOL_HTTP + " OK using " + httpSource);
}
Also used : AppserverConnectionSource(com.sun.appserv.management.client.AppserverConnectionSource) HandshakeCompletedListenerImpl(com.sun.appserv.management.client.HandshakeCompletedListenerImpl) TLSParams(com.sun.appserv.management.client.TLSParams) ConnectionSource(com.sun.appserv.management.client.ConnectionSource) AppserverConnectionSource(com.sun.appserv.management.client.AppserverConnectionSource) MBeanServerConnection(javax.management.MBeanServerConnection)

Example 2 with TLSParams

use of com.sun.appserv.management.client.TLSParams in project Payara by payara.

the class TestMain method _getConnectionSource.

private AppserverConnectionSource _getConnectionSource(final PropertyGetter getter, final String host, final int port) throws IOException {
    final String user = getter.getString(USER_KEY);
    final String password = getter.getString(PASSWORD_KEY);
    final File trustStore = getter.getFile(TRUSTSTORE_KEY);
    final String trustStorePassword = getter.getString(TRUSTSTORE_PASSWORD_KEY);
    final boolean useTLS = getter.getboolean(USE_TLS_KEY);
    final TLSParams tlsParams = useTLS ? createTLSParams(trustStore, trustStorePassword) : null;
    AppserverConnectionSource conn = null;
    try {
        conn = connect(host, port, user, password, tlsParams);
        if (mHandshakeCompletedListener != null) {
            assert (mHandshakeCompletedListener.getLastEvent() != null);
            println("HandshakeCompletedEvent: " + toString(mHandshakeCompletedListener.getLastEvent()));
        }
    } catch (IOException e) {
        if (useTLS) {
            // try without TLS
            println("Attempting connection without TLS...");
            conn = connect(host, port, user, password, null);
        }
    }
    if (conn != null) {
        conn.getJMXConnector(false).addConnectionNotificationListener(this, null, conn);
    }
    return (conn);
}
Also used : AppserverConnectionSource(com.sun.appserv.management.client.AppserverConnectionSource) TLSParams(com.sun.appserv.management.client.TLSParams) IOException(java.io.IOException) File(java.io.File)

Example 3 with TLSParams

use of com.sun.appserv.management.client.TLSParams in project Payara by payara.

the class TestMain method createTLSParams.

private TLSParams createTLSParams(final File trustStoreFile, final String password) {
    final char[] trustStorePassword = password.toCharArray();
    mHandshakeCompletedListener = new HandshakeCompletedListenerImpl();
    final TestClientTrustStoreTrustManager trustMgr = new TestClientTrustStoreTrustManager(trustStoreFile, trustStorePassword);
    final TLSParams tlsParams = new TLSParams(trustMgr, mHandshakeCompletedListener);
    return (tlsParams);
}
Also used : HandshakeCompletedListenerImpl(com.sun.appserv.management.client.HandshakeCompletedListenerImpl) TLSParams(com.sun.appserv.management.client.TLSParams)

Aggregations

TLSParams (com.sun.appserv.management.client.TLSParams)3 AppserverConnectionSource (com.sun.appserv.management.client.AppserverConnectionSource)2 HandshakeCompletedListenerImpl (com.sun.appserv.management.client.HandshakeCompletedListenerImpl)2 ConnectionSource (com.sun.appserv.management.client.ConnectionSource)1 File (java.io.File)1 IOException (java.io.IOException)1 MBeanServerConnection (javax.management.MBeanServerConnection)1