Skip to content
Permalink
Browse files
Add support for SASL authentication
[FIXED JENKINS-33667]
  • Loading branch information
ddeva-vistar committed Jul 19, 2017
1 parent 929ee39 commit ceb74d78feb78176d7087493047682ae00fc209a
@@ -32,6 +32,7 @@
import java.util.List;
import java.util.SortedMap;
import java.util.logging.Logger;
import java.util.logging.Level;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -172,6 +173,8 @@ protected Object readResolve() {

String password = null;

private boolean sasl;

String nick = "jenkins-bot";

String nickServPassword = null;
@@ -267,6 +270,7 @@ public boolean configure(StaplerRequest req, JSONObject formData) throws FormExc
this.login = req.getParameter("irc_publisher.login");
this.password = Scrambler.scramble(
req.getParameter("irc_publisher.password"));
this.sasl = "on".equals(req.getParameter("irc_publisher.sasl"));
this.nick = req.getParameter("irc_publisher.nick");
this.nickServPassword = Scrambler.scramble(
req.getParameter(PARAMETERNAME_NICKSERV_PASSWORD));
@@ -471,6 +475,10 @@ public String getPassword() {
return Scrambler.descramble(password);
}

public boolean isSasl() {
return this.sasl;
}

//@Override
public int getPort() {
return port;
@@ -41,6 +41,7 @@
import org.pircbotx.PircBotX;
import org.pircbotx.ProxySocketFactory;
import org.pircbotx.UtilSSLSocketFactory;
import org.pircbotx.cap.SASLCapHandler;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.ConnectEvent;

@@ -91,8 +92,12 @@ public IRCConnection(DescriptorImpl descriptor, AuthenticationHolder authenticat

config.setServerHostname(descriptor.getHost());
config.setServerPort(descriptor.getPort());
String password = Util.fixEmpty(this.descriptor.getPassword());
config.setServerPassword(password);
if (this.descriptor.isSasl()) {
config.addCapHandler(new SASLCapHandler(this.descriptor.getLogin(), this.descriptor.getPassword()));
} else {
String password = Util.fixEmpty(this.descriptor.getPassword());
config.setServerPassword(password);
}
final String nickServPassword = Util.fixEmpty(this.descriptor.getNickServPassword());
config.setNickservPassword(nickServPassword);

@@ -55,6 +55,10 @@
description="Password for the IRC server">
<f:password name="irc_publisher.password" value="${descriptor.getPassword()}" />
</f:entry>
<f:entry title="SASL"
description="Enable SASL for authentication">
<f:checkbox name="irc_publisher.sasl" checked="${descriptor.isSasl()}" />
</f:entry>
<f:entry title="NickServ Password" description="On connection, try to identify with NickServ with this password" help="/plugin/ircbot/help-globalConfigNickServ.html">
<f:password name="irc_publisher.nickServPassword" value="${descriptor.nickServPassword}"/>
</f:entry>
@@ -94,4 +98,4 @@
</f:advanced>
</f:optionalBlock>
</f:section>
</j:jelly>
</j:jelly>

0 comments on commit ceb74d7

Please sign in to comment.