summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Hudson <nick.hudson@isode.com>2012-02-13 15:26:50 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-02-13 17:02:41 (GMT)
commitaeab1723a7efdd2eb989ff29afc7461ee4d27936 (patch)
treed6b526455d5c391628b7853c0cee6056071c4359 /src/com/isode/stroke/tls
parent5d1245e7ecde8c5b41279bdad6df930084ff35a6 (diff)
downloadstroke-aeab1723a7efdd2eb989ff29afc7461ee4d27936.zip
stroke-aeab1723a7efdd2eb989ff29afc7461ee4d27936.tar.bz2
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
Diffstat (limited to 'src/com/isode/stroke/tls')
-rw-r--r--src/com/isode/stroke/tls/java/JSSEContext.java28
1 files changed, 12 insertions, 16 deletions
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;
}
}