X-Git-Url: http://pileus.org/git/?p=~andy%2Fspades;a=blobdiff_plain;f=src%2Forg%2Fpileus%2Fspades%2FClient.java;h=b2d6561c45630896ba949662248bd14b8069239a;hp=c7f6e1c0f26658679f72b588c861a4208a28faca;hb=289763d6d9463eaeab8ac3ea7b99357e2105353f;hpb=606857f4ef9cecea4ae4bc7444d711a5e9cb6c06 diff --git a/src/org/pileus/spades/Client.java b/src/org/pileus/spades/Client.java index c7f6e1c..b2d6561 100644 --- a/src/org/pileus/spades/Client.java +++ b/src/org/pileus/spades/Client.java @@ -66,6 +66,8 @@ public class Client } Os.debug("Client: connected"); + if (this.usesasl) + this.raw("CAP REQ :sasl"); this.raw("USER "+this.username+" "+this.hostname+" "+this.server+" :"+this.nickname); this.raw("NICK "+this.nickname); @@ -112,6 +114,8 @@ public class Client Os.debug("> " + line); Message msg = new Message(line); this.process(msg); + if (this.usesasl) + this.dosasl(msg); return msg; } catch (SocketException e) { this.ready = false; @@ -139,4 +143,37 @@ public class Client this.raw("PING " + msg.msg); } } + + private void dosasl(Message msg) + { + switch (msg.type) { + case CAP: + if (msg.msg.equals("sasl") && msg.arg.equals("ACK")) { + Os.debug("Client: sasl - starting auth"); + this.raw("AUTHENTICATE PLAIN"); + } else { + Os.debug("Client: sasl - Server does not support sasl"); + } + break; + case AUTH: + if (msg.arg.equals("+")) { + Os.debug("Client: sasl - performin authentication"); + this.raw("AUTHENTICATE " + Os.base64( + this.authname + "\0" + + this.authname + "\0" + + this.password)); + } else { + Os.debug("Client: sasl - unexpected authenticate response"); + } + break; + case AUTHOK: + Os.debug("Client: SASL Auth Successful"); + this.raw("CAP END"); + break; + case AUTHFAIL: + Os.debug("Client: SASL Auth Failed"); + this.raw("CAP END"); + break; + } + } }