Search in sources :

Example 1 with SSLIRCConnection

use of org.schwering.irc.lib.ssl.SSLIRCConnection in project camel by apache.

the class IrcComponent method createConnection.

protected IRCConnection createConnection(IrcConfiguration configuration) {
    IRCConnection conn = null;
    IRCEventListener ircLogger;
    if (configuration.getUsingSSL()) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating SSL Connection to {} destination(s): {} nick: {} user: {}", new Object[] { configuration.getHostname(), configuration.getListOfChannels(), configuration.getNickname(), configuration.getUsername() });
        }
        if (configuration.getSslContextParameters() != null) {
            conn = new CamelSSLIRCConnection(configuration.getHostname(), configuration.getPorts(), configuration.getPassword(), configuration.getNickname(), configuration.getUsername(), configuration.getRealname(), configuration.getSslContextParameters(), getCamelContext());
        } else {
            SSLIRCConnection sconn = new SSLIRCConnection(configuration.getHostname(), configuration.getPorts(), configuration.getPassword(), configuration.getNickname(), configuration.getUsername(), configuration.getRealname());
            sconn.addTrustManager(configuration.getTrustManager());
            conn = sconn;
        }
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating Connection to {} destination(s): {} nick: {} user: {}", new Object[] { configuration.getHostname(), configuration.getListOfChannels(), configuration.getNickname(), configuration.getUsername() });
        }
        conn = new IRCConnection(configuration.getHostname(), configuration.getPorts(), configuration.getPassword(), configuration.getNickname(), configuration.getUsername(), configuration.getRealname());
    }
    conn.setEncoding("UTF-8");
    conn.setColors(configuration.isColors());
    conn.setPong(true);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Adding IRC event logging listener");
        ircLogger = createIrcLogger(configuration.getHostname());
        conn.addIRCEventListener(ircLogger);
    }
    try {
        conn.connect();
    } catch (Exception e) {
        throw new RuntimeCamelException(e);
    }
    return conn;
}
Also used : IRCEventListener(org.schwering.irc.lib.IRCEventListener) SSLIRCConnection(org.schwering.irc.lib.ssl.SSLIRCConnection) RuntimeCamelException(org.apache.camel.RuntimeCamelException) IRCConnection(org.schwering.irc.lib.IRCConnection) SSLIRCConnection(org.schwering.irc.lib.ssl.SSLIRCConnection) RuntimeCamelException(org.apache.camel.RuntimeCamelException)

Aggregations

RuntimeCamelException (org.apache.camel.RuntimeCamelException)1 IRCConnection (org.schwering.irc.lib.IRCConnection)1 IRCEventListener (org.schwering.irc.lib.IRCEventListener)1 SSLIRCConnection (org.schwering.irc.lib.ssl.SSLIRCConnection)1