Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 850AF19BA3 for ; Fri, 25 Mar 2016 07:18:19 +0000 (UTC) Received: (qmail 14119 invoked by uid 500); 25 Mar 2016 07:18:19 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 14068 invoked by uid 500); 25 Mar 2016 07:18:19 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 14059 invoked by uid 99); 25 Mar 2016 07:18:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Mar 2016 07:18:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3D185DFCDD; Fri, 25 Mar 2016 07:18:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Message-Id: <3d855dc416e64dda8abf9cee3186335e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: camel git commit: CAMEL-9755: Allow for nickserv identification. Thanks to Kevin Telford for the patch. Date: Fri, 25 Mar 2016 07:18:19 +0000 (UTC) Repository: camel Updated Branches: refs/heads/master 200ddf914 -> f929278b0 CAMEL-9755: Allow for nickserv identification. Thanks to Kevin Telford for the patch. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f929278b Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f929278b Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f929278b Branch: refs/heads/master Commit: f929278b0c5e02217e47bbe3b3f12f908f4f2913 Parents: 200ddf9 Author: Claus Ibsen Authored: Fri Mar 25 08:17:55 2016 +0100 Committer: Claus Ibsen Committed: Fri Mar 25 08:17:55 2016 +0100 ---------------------------------------------------------------------- .../camel/component/irc/IrcConfiguration.java | 13 +++++++++++++ .../apache/camel/component/irc/IrcConsumer.java | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/f929278b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java index 7a214d7..4536ba2 100644 --- a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java +++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java @@ -84,6 +84,8 @@ public class IrcConfiguration implements Cloneable { @UriParam(defaultValue = "true") private boolean autoRejoin = true; private SSLContextParameters sslContextParameters; + @UriParam + private String nickPassword; public IrcConfiguration() { } @@ -440,6 +442,17 @@ public class IrcConfiguration implements Cloneable { public void setSslContextParameters(SSLContextParameters sslContextParameters) { this.sslContextParameters = sslContextParameters; } + + /** + * Your IRC server nickname password. + */ + public String getNickPassword() { + return nickPassword; + } + + public void setNickPassword(String nickPassword) { + this.nickPassword = nickPassword; + } public String toString() { return "IrcConfiguration[hostname: " + hostname + ", ports=" + Arrays.toString(ports) + ", username=" + username + "]"; http://git-wip-us.apache.org/repos/asf/camel/blob/f929278b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java index b9c6efd..e132f1a 100644 --- a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java +++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java @@ -19,6 +19,7 @@ package org.apache.camel.component.irc; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.impl.DefaultConsumer; +import org.apache.camel.util.ObjectHelper; import org.schwering.irc.lib.IRCConnection; import org.schwering.irc.lib.IRCEventAdapter; import org.schwering.irc.lib.IRCModeParser; @@ -58,6 +59,22 @@ public class IrcConsumer extends DefaultConsumer { super.doStart(); listener = getListener(); connection.addIRCEventListener(listener); + + if (ObjectHelper.isNotEmpty(configuration.getNickPassword())) { + try { + // TODO : sleep before joinChannels() may be another useful config param (even when not identifying) + // sleep for a few seconds as the server sometimes takes a moment to fully connect, print banners, etc after connection established + LOG.debug("Sleeping for 5 seconds before identifying to NickServ."); + Thread.sleep(5000); + } catch (InterruptedException ex) { + // ignore + } + LOG.debug("Identifying and enforcing nick with NickServ."); + // Identify nick and enforce, https://meta.wikimedia.org/wiki/IRC/Instructions#Register_your_nickname.2C_identify.2C_and_enforce + connection.doPrivmsg("nickserv", "identify " + configuration.getNickPassword()); + connection.doPrivmsg("nickserv", "set enforce on"); + } + endpoint.joinChannels(); }