From aeab1723a7efdd2eb989ff29afc7461ee4d27936 Mon Sep 17 00:00:00 2001 From: Nick Hudson Date: Mon, 13 Feb 2012 15:26:50 +0000 Subject: Tidying up based on feedback from patch for initial TLS implementation Hopefully the changes speak for themselves. Some feedback relating to JavaCertificate has not been addressed; that will be done in a separate patch Test-information: Can still establish sessions with / without TLS diff --git a/src/com/isode/stroke/elements/TLSProceed.java b/src/com/isode/stroke/elements/TLSProceed.java index 4bebc64..a6f72fd 100644 --- a/src/com/isode/stroke/elements/TLSProceed.java +++ b/src/com/isode/stroke/elements/TLSProceed.java @@ -12,7 +12,6 @@ package com.isode.stroke.elements; public class TLSProceed implements Element { - public TLSProceed() { - // + public TLSProceed() { } } diff --git a/src/com/isode/stroke/network/JavaConnection.java b/src/com/isode/stroke/network/JavaConnection.java index 9a3b5da..08cd497 100644 --- a/src/com/isode/stroke/network/JavaConnection.java +++ b/src/com/isode/stroke/network/JavaConnection.java @@ -103,7 +103,7 @@ public class JavaConnection extends Connection implements EventOwner { private void handleConnected(final boolean error) { eventLoop_.postEvent(new Callback() { public void run() { - onConnectFinished.emit(Boolean.valueOf(error)); + onConnectFinished.emit(error); } }); } diff --git a/src/com/isode/stroke/network/JavaTLSConnectionFactory.java b/src/com/isode/stroke/network/JavaTLSConnectionFactory.java deleted file mode 100644 index 56ef917..0000000 --- a/src/com/isode/stroke/network/JavaTLSConnectionFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2012, Isode Limited, London, England. - * All rights reserved. - */ - -package com.isode.stroke.network; - -import com.isode.stroke.eventloop.EventLoop; - -public class JavaTLSConnectionFactory implements ConnectionFactory { - - public JavaTLSConnectionFactory(EventLoop eventLoop) { - this.eventLoop = eventLoop; - } - - public Connection createConnection() { - return JavaConnection.create(eventLoop); - } - - private final EventLoop eventLoop; -} diff --git a/src/com/isode/stroke/tls/java/JSSEContext.java b/src/com/isode/stroke/tls/java/JSSEContext.java index 1d8fba7..e052b19 100644 --- a/src/com/isode/stroke/tls/java/JSSEContext.java +++ b/src/com/isode/stroke/tls/java/JSSEContext.java @@ -43,22 +43,22 @@ import com.isode.stroke.tls.TLSContext; public class JSSEContext extends TLSContext { private static class JSSEContextError { - public Throwable throwable; - public String message; + public final Exception exception; + public final String message; /** * Create a new object - * @param t throwable; may be null + * @param e exception; may be null * @param m message; may be null */ - public JSSEContextError(Throwable t, String m) { - throwable = t; + public JSSEContextError(Exception e, String m) { + exception = e; message = m; } @Override public String toString() { return "JSSEContextError: " + (message == null ? "No message" : message) + "; " + - (throwable == null ? "No exception" : throwable.getMessage()); + (exception == null ? "No exception" : exception.getMessage()); } } /** @@ -83,11 +83,11 @@ public class JSSEContext extends TLSContext { } /** * Emit an error, and keep track of which errors have been emitted - * @param t the Throwable which caused this error (may be null) + * @param e the Exception which caused this error (may be null) * @param m a String describing what caused this error (may be null) */ - private void emitError(Throwable t, String m) { - JSSEContextError jsseContextError = new JSSEContextError(t,m); + private void emitError(Exception e, String m) { + JSSEContextError jsseContextError = new JSSEContextError(e, m); errorsEmitted.add(jsseContextError); onError.emit(); } @@ -103,11 +103,8 @@ public class JSSEContext extends TLSContext { } private void doSetup() throws SSLException { - - // May throw NoSuchAlgorithmException - SSLContext sslContext = null; - sslContext = getSSLContext(); + SSLContext sslContext = getSSLContext(); if (sslContext == null) { throw new SSLException("Could not create SSLContext"); @@ -236,8 +233,7 @@ public class JSSEContext extends TLSContext { if (bytesProduced > 0) { unwrappedReceived.flip(); - byte[] result = new byte[0]; - result = new byte[unwrappedReceived.remaining()]; + byte[] result = new byte[unwrappedReceived.remaining()]; unwrappedReceived.get(result); unwrappedReceived.compact(); byteArray = new ByteArray(result); @@ -599,7 +595,7 @@ public class JSSEContext extends TLSContext { String errors = null; if (hasError()) { errors = "; errors emitted:"; - for (JSSEContextError e:errorsEmitted) { + for (JSSEContextError e : errorsEmitted) { errors += "\n " + e; } } -- cgit v0.10.2-6-g49f6