mirror of https://github.com/sipwise/jitsi.git
parent
421e57d093
commit
a86f01c1a9
@ -1,208 +0,0 @@
|
|||||||
http://irc-api.googlecode.com/svn/trunk@179
|
|
||||||
|
|
||||||
Additional modifications:
|
|
||||||
-------------------------
|
|
||||||
commit 99062b621dcf6722fc0b8c868abc806092369086
|
|
||||||
Author: Danny van Heumen <danny@dannyvanheumen.nl>
|
|
||||||
Date: Sun Jan 26 22:46:28 2014 +0100
|
|
||||||
|
|
||||||
Added support for providing custom SSLContext.
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/ircclouds/irc/api/AbstractIRCSession.java b/src/main/java/com/ircclouds/irc/api/AbstractIRCSession.java
|
|
||||||
index 67bdecd..08b5030 100644
|
|
||||||
--- a/src/main/java/com/ircclouds/irc/api/AbstractIRCSession.java
|
|
||||||
+++ b/src/main/java/com/ircclouds/irc/api/AbstractIRCSession.java
|
|
||||||
@@ -2,6 +2,8 @@ package com.ircclouds.irc.api;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
+import javax.net.ssl.*;
|
|
||||||
+
|
|
||||||
import com.ircclouds.irc.api.commands.*;
|
|
||||||
import com.ircclouds.irc.api.comms.*;
|
|
||||||
import com.ircclouds.irc.api.domain.*;
|
|
||||||
@@ -90,7 +92,7 @@ public abstract class AbstractIRCSession implements IIRCSession
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
- public boolean open(IRCServer aServer) throws IOException
|
|
||||||
+ public boolean open(IRCServer aServer, SSLContext aCustomContext) throws IOException
|
|
||||||
{
|
|
||||||
if (!aServer.isSSL())
|
|
||||||
{
|
|
||||||
@@ -98,7 +100,7 @@ public abstract class AbstractIRCSession implements IIRCSession
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
- conn = new SSLSocketChannelConnection();
|
|
||||||
+ conn = new SSLSocketChannelConnection(aCustomContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conn.open(aServer.getHostname(), aServer.getPort()))
|
|
||||||
diff --git a/src/main/java/com/ircclouds/irc/api/IIRCSession.java b/src/main/java/com/ircclouds/irc/api/IIRCSession.java
|
|
||||||
index eafb171..b17f1ae 100644
|
|
||||||
--- a/src/main/java/com/ircclouds/irc/api/IIRCSession.java
|
|
||||||
+++ b/src/main/java/com/ircclouds/irc/api/IIRCSession.java
|
|
||||||
@@ -2,6 +2,8 @@ package com.ircclouds.irc.api;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
+import javax.net.ssl.*;
|
|
||||||
+
|
|
||||||
import com.ircclouds.irc.api.domain.*;
|
|
||||||
import com.ircclouds.irc.api.filters.*;
|
|
||||||
import com.ircclouds.irc.api.listeners.*;
|
|
||||||
@@ -14,7 +16,7 @@ public interface IIRCSession
|
|
||||||
|
|
||||||
void removeListener(IMessageListener aListener);
|
|
||||||
|
|
||||||
- boolean open(IRCServer aServer) throws IOException;
|
|
||||||
+ boolean open(IRCServer aServer, SSLContext aCustomContext) throws IOException;
|
|
||||||
|
|
||||||
void close() throws IOException;
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/ircclouds/irc/api/IRCApiImpl.java b/src/main/java/com/ircclouds/irc/api/IRCApiImpl.java
|
|
||||||
index 8b60c05..4bb1408 100644
|
|
||||||
--- a/src/main/java/com/ircclouds/irc/api/IRCApiImpl.java
|
|
||||||
+++ b/src/main/java/com/ircclouds/irc/api/IRCApiImpl.java
|
|
||||||
@@ -96,7 +96,7 @@ public class IRCApiImpl implements IRCApi
|
|
||||||
boolean _isOpen = false;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
- if (_isOpen = session.open(aServerParameters.getServer()))
|
|
||||||
+ if (_isOpen = session.open(aServerParameters.getServer(), aServerParameters.getCustomContext()))
|
|
||||||
{
|
|
||||||
executeAsync(new ConnectCmd(aServerParameters), aCallback, _d);
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/com/ircclouds/irc/api/IServerParameters.java b/src/main/java/com/ircclouds/irc/api/IServerParameters.java
|
|
||||||
index b3bc942..2338ed5 100644
|
|
||||||
--- a/src/main/java/com/ircclouds/irc/api/IServerParameters.java
|
|
||||||
+++ b/src/main/java/com/ircclouds/irc/api/IServerParameters.java
|
|
||||||
@@ -2,6 +2,8 @@ package com.ircclouds.irc.api;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
+import javax.net.ssl.*;
|
|
||||||
+
|
|
||||||
import com.ircclouds.irc.api.domain.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@@ -41,4 +43,10 @@ public interface IServerParameters
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
IRCServer getServer();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Returns the custom SSL context if it is specified, or null otherwise.
|
|
||||||
+ * @return returns SSLContext instance or null
|
|
||||||
+ */
|
|
||||||
+ SSLContext getCustomContext();
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/com/ircclouds/irc/api/comms/SSLSocketChannelConnection.java b/src/main/java/com/ircclouds/irc/api/comms/SSLSocketChannelConnection.java
|
|
||||||
index c9096ac..abec187 100644
|
|
||||||
--- a/src/main/java/com/ircclouds/irc/api/comms/SSLSocketChannelConnection.java
|
|
||||||
+++ b/src/main/java/com/ircclouds/irc/api/comms/SSLSocketChannelConnection.java
|
|
||||||
@@ -14,7 +14,8 @@ import org.slf4j.*;
|
|
||||||
public class SSLSocketChannelConnection implements IConnection
|
|
||||||
{
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(SSLSocketChannelConnection.class);
|
|
||||||
-
|
|
||||||
+
|
|
||||||
+ private final SSLContext customContext;
|
|
||||||
private SocketChannel sChannel;
|
|
||||||
private SSLEngine sslEngine;
|
|
||||||
|
|
||||||
@@ -25,12 +26,23 @@ public class SSLSocketChannelConnection implements IConnection
|
|
||||||
|
|
||||||
private HandshakeStatus hStatus;
|
|
||||||
private int remaingUnwraps;
|
|
||||||
+
|
|
||||||
+ public SSLSocketChannelConnection(SSLContext customContext)
|
|
||||||
+ {
|
|
||||||
+ this.customContext = customContext;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
public boolean open(String aHostname, int aPort) throws IOException
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
- sslEngine = getInitializedSSLContext().createSSLEngine(aHostname, aPort);
|
|
||||||
+ SSLContext context = this.customContext;
|
|
||||||
+ if (context == null)
|
|
||||||
+ {
|
|
||||||
+ // initialize default SSLContext
|
|
||||||
+ context = getInitializedSSLContext();
|
|
||||||
+ }
|
|
||||||
+ sslEngine = context.createSSLEngine(aHostname, aPort);
|
|
||||||
sslEngine.setNeedClientAuth(false);
|
|
||||||
sslEngine.setUseClientMode(true);
|
|
||||||
sslEngine.beginHandshake();
|
|
||||||
diff --git a/src/test/java/com/ircclouds/irc/api/MockServerParametersImpl.java b/src/test/java/com/ircclouds/irc/api/MockServerParametersImpl.java
|
|
||||||
index 105b509..68dd46b 100644
|
|
||||||
--- a/src/test/java/com/ircclouds/irc/api/MockServerParametersImpl.java
|
|
||||||
+++ b/src/test/java/com/ircclouds/irc/api/MockServerParametersImpl.java
|
|
||||||
@@ -2,6 +2,8 @@ package com.ircclouds.irc.api;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
+import javax.net.ssl.*;
|
|
||||||
+
|
|
||||||
import com.ircclouds.irc.api.domain.*;
|
|
||||||
|
|
||||||
class MockServerParametersImpl implements IServerParameters
|
|
||||||
@@ -11,6 +13,7 @@ class MockServerParametersImpl implements IServerParameters
|
|
||||||
private String ident;
|
|
||||||
private String realname;
|
|
||||||
private IRCServer server;
|
|
||||||
+ private SSLContext customContext;
|
|
||||||
|
|
||||||
public MockServerParametersImpl(String aNickname, List<String> aAltNicks, String aIdent, String aRealname, IRCServer aServer)
|
|
||||||
{
|
|
||||||
@@ -19,6 +22,7 @@ class MockServerParametersImpl implements IServerParameters
|
|
||||||
ident = aIdent;
|
|
||||||
realname = aRealname;
|
|
||||||
server = aServer;
|
|
||||||
+ customContext = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@@ -51,4 +55,9 @@ class MockServerParametersImpl implements IServerParameters
|
|
||||||
return server;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ @Override
|
|
||||||
+ public SSLContext getCustomContext()
|
|
||||||
+ {
|
|
||||||
+ return customContext;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
commit f7d5d330e98607e54f7eea24c34ed28cc3e702f6
|
|
||||||
Author: Danny van Heumen <danny@dannyvanheumen.nl>
|
|
||||||
Date: Fri Mar 7 23:28:23 2014 +0100
|
|
||||||
|
|
||||||
Check if channel is open before closing.
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/ircclouds/irc/api/comms/SSLSocketChannelConnection.java b/src/main/java/com/ircclouds/irc/api/comms/SSLSocketChannelConnection.java
|
|
||||||
index abec187..d9e3f30 100644
|
|
||||||
--- a/src/main/java/com/ircclouds/irc/api/comms/SSLSocketChannelConnection.java
|
|
||||||
+++ b/src/main/java/com/ircclouds/irc/api/comms/SSLSocketChannelConnection.java
|
|
||||||
@@ -106,7 +106,10 @@ public class SSLSocketChannelConnection implements IConnection
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
- sChannel.close();
|
|
||||||
+ if (sChannel.isOpen())
|
|
||||||
+ {
|
|
||||||
+ sChannel.close();
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -227,4 +230,4 @@ public class SSLSocketChannelConnection implements IConnection
|
|
||||||
|
|
||||||
return _sslCtx;
|
|
||||||
}
|
|
||||||
-}
|
|
||||||
\ No newline at end of file
|
|
||||||
+}
|
|
||||||
Loading…
Reference in new issue