Search in sources :

Example 6 with AppserverConnectionSource

use of com.sun.appserv.management.client.AppserverConnectionSource 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 7 with AppserverConnectionSource

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

the class TestMain method connect.

/**
 *     @param host      hostname or IP address of Domain Admin Server
 *     @param port      RMI administrative port
 *     @param user      admin user
 *     @param password  admin user password
 *     @param tlsParams TLS parameters, may be null
 *     @return AppserverConnectionSource
 */
public static AppserverConnectionSource connect(final String host, final int port, final String user, final String password, final TLSParams tlsParams) throws IOException {
    final String info = "host=" + host + ", port=" + port + ", user=" + user + ", password=" + password + ", tls=" + (tlsParams != null);
    println("Connecting: " + info + "...");
    final AppserverConnectionSource conn = new AppserverConnectionSource(AppserverConnectionSource.PROTOCOL_JMXMP, host, port, user, password, tlsParams, null);
    conn.getJMXConnector(false);
    return (conn);
}
Also used : AppserverConnectionSource(com.sun.appserv.management.client.AppserverConnectionSource)

Aggregations

AppserverConnectionSource (com.sun.appserv.management.client.AppserverConnectionSource)7 IOException (java.io.IOException)3 TLSParams (com.sun.appserv.management.client.TLSParams)2 FileNotFoundException (java.io.FileNotFoundException)2 MBeanServerConnection (javax.management.MBeanServerConnection)2 ConnectionSource (com.sun.appserv.management.client.ConnectionSource)1 HandshakeCompletedListenerImpl (com.sun.appserv.management.client.HandshakeCompletedListenerImpl)1 ConfigConfig (com.sun.appserv.management.config.ConfigConfig)1 JMXConnectorConfig (com.sun.appserv.management.config.JMXConnectorConfig)1 NodeAgentConfig (com.sun.appserv.management.config.NodeAgentConfig)1 NodeAgentsConfig (com.sun.appserv.management.config.NodeAgentsConfig)1 ResourceRefConfig (com.sun.appserv.management.config.ResourceRefConfig)1 StandaloneServerConfig (com.sun.appserv.management.config.StandaloneServerConfig)1 AttributeResolverHelper (com.sun.appserv.management.helper.AttributeResolverHelper)1 File (java.io.File)1 HashMap (java.util.HashMap)1