diff options
author | Gurmeen Bindra <gurmeen.bindra@isode.com> | 2014-08-08 11:04:07 (GMT) |
---|---|---|
committer | Gurmeen Bindra <gurmeen.bindra@isode.com> | 2014-08-08 11:26:31 (GMT) |
commit | c0293fade7b437e5687e7121c9f6b9de7344ad47 (patch) | |
tree | 7ba46f47aa973aeef7842618f7246959212d8bbb /src/com | |
parent | 77959428b7f4150569dda9fac35becf7e10b96c7 (diff) | |
download | stroke-c0293fade7b437e5687e7121c9f6b9de7344ad47.zip stroke-c0293fade7b437e5687e7121c9f6b9de7344ad47.tar.bz2 |
Update stroke as per swiften wrt getting certificate chain
This patch updates Stroke as per the Swiften code to get peerCertificate chain.
Test-information:
tested using M-Link Console (XMPP client) to look at the certificate and chain
Change-Id: I2662511b72f9ca6d176a9f4c1e02d10b5df5d2c7
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/isode/stroke/client/ClientSession.java | 4 | ||||
-rw-r--r-- | src/com/isode/stroke/client/ClientSessionStanzaChannel.java | 13 | ||||
-rw-r--r-- | src/com/isode/stroke/client/CoreClient.java | 14 | ||||
-rw-r--r-- | src/com/isode/stroke/client/DummyStanzaChannel.java | 10 | ||||
-rw-r--r-- | src/com/isode/stroke/client/StanzaChannel.java | 6 |
5 files changed, 32 insertions, 15 deletions
diff --git a/src/com/isode/stroke/client/ClientSession.java b/src/com/isode/stroke/client/ClientSession.java index c0caeb6..9ceecf0 100644 --- a/src/com/isode/stroke/client/ClientSession.java +++ b/src/com/isode/stroke/client/ClientSession.java @@ -176,6 +176,10 @@ public class ClientSession { public boolean getRosterVersioningSuported() { return rosterVersioningSupported; } + + public List<Certificate> getPeerCertificateChain() { + return stream.getPeerCertificateChain(); + } public JID getLocalJID() { return localJID; diff --git a/src/com/isode/stroke/client/ClientSessionStanzaChannel.java b/src/com/isode/stroke/client/ClientSessionStanzaChannel.java index 95f59d8..0aa024f 100644 --- a/src/com/isode/stroke/client/ClientSessionStanzaChannel.java +++ b/src/com/isode/stroke/client/ClientSessionStanzaChannel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Isode Limited, London, England. + * Copyright (c) 2010-2014, Isode Limited, London, England. * All rights reserved. */ /* @@ -16,6 +16,10 @@ import com.isode.stroke.elements.Stanza; import com.isode.stroke.signals.SignalConnection; import com.isode.stroke.signals.Slot; import com.isode.stroke.signals.Slot1; +import com.isode.stroke.tls.Certificate; + +import java.util.ArrayList; +import java.util.List; import java.util.logging.Logger; /** @@ -77,6 +81,13 @@ public class ClientSessionStanzaChannel extends StanzaChannel { } return false; } + + public List<Certificate> getPeerCertificateChain() { + if (session != null) { + return session.getPeerCertificateChain(); + } + return new ArrayList<Certificate>(); + } public boolean isAvailable() { return session != null && ClientSession.State.Initialized.equals(session.getState()); diff --git a/src/com/isode/stroke/client/CoreClient.java b/src/com/isode/stroke/client/CoreClient.java index 646f8fe..a1c6d0a 100644 --- a/src/com/isode/stroke/client/CoreClient.java +++ b/src/com/isode/stroke/client/CoreClient.java @@ -3,7 +3,7 @@ * All rights reserved. */ /* - * Copyright (c) 2010, Remko Tronçon. + * Copyright (c) 2010-2014, Remko Tronçon. * All rights reserved. */ package com.isode.stroke.client; @@ -29,7 +29,6 @@ import com.isode.stroke.signals.SignalConnection; import com.isode.stroke.signals.Slot; import com.isode.stroke.signals.Slot1; import com.isode.stroke.signals.Slot2; -import com.isode.stroke.tls.Certificate; import com.isode.stroke.tls.CertificateTrustChecker; import com.isode.stroke.tls.CertificateVerificationError; import com.isode.stroke.tls.CertificateWithKey; @@ -468,18 +467,9 @@ public class CoreClient { * @return true if the session is initialized and encrypted with TLS, * false otherwise. */ - public boolean isSessionTLSEncrypted() { + public boolean isStreamEncrypted() { return (sessionStream_ != null && sessionStream_.isTLSEncrypted()); } - - /** - * If the session is initialized and encrypted with TLS, then the - * certificate presented by the peer is returned - * @return the peer certificate, if one is available, otherwise null. - */ - public Certificate getSessionCertificate() { - return (isSessionTLSEncrypted() ? sessionStream_.getPeerCertificate() : null); - } private void resetConnector() { if (connectorConnectFinishedConnection_ != null) { diff --git a/src/com/isode/stroke/client/DummyStanzaChannel.java b/src/com/isode/stroke/client/DummyStanzaChannel.java index 25fb817..ac1fc1c 100644 --- a/src/com/isode/stroke/client/DummyStanzaChannel.java +++ b/src/com/isode/stroke/client/DummyStanzaChannel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Isode Limited, London, England. + * Copyright (c) 2014, Isode Limited, London, England. * All rights reserved. */ /* @@ -8,6 +8,8 @@ */ package com.isode.stroke.client; +import java.util.ArrayList; +import java.util.List; import java.util.Vector; import com.isode.stroke.elements.IQ; @@ -16,6 +18,7 @@ import com.isode.stroke.elements.Payload; import com.isode.stroke.elements.Presence; import com.isode.stroke.elements.Stanza; import com.isode.stroke.jid.JID; +import com.isode.stroke.tls.Certificate; /** * Dummy Stanza Channel for Unit Testing @@ -111,5 +114,10 @@ public class DummyStanzaChannel extends StanzaChannel { return (T)(sentStanzas.get(index)); } return null; + } + + @Override + public List<Certificate> getPeerCertificateChain() { + return new ArrayList<Certificate>(); } } diff --git a/src/com/isode/stroke/client/StanzaChannel.java b/src/com/isode/stroke/client/StanzaChannel.java index 62984b5..5a1d270 100644 --- a/src/com/isode/stroke/client/StanzaChannel.java +++ b/src/com/isode/stroke/client/StanzaChannel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Isode Limited, London, England. + * Copyright (c) 2010-2014, Isode Limited, London, England. * All rights reserved. */ /* @@ -9,11 +9,14 @@ package com.isode.stroke.client; +import java.util.List; + import com.isode.stroke.elements.Message; import com.isode.stroke.elements.Presence; import com.isode.stroke.elements.Stanza; import com.isode.stroke.queries.IQChannel; import com.isode.stroke.signals.Signal1; +import com.isode.stroke.tls.Certificate; public abstract class StanzaChannel extends IQChannel { @@ -25,6 +28,7 @@ public abstract class StanzaChannel extends IQChannel { public abstract boolean isAvailable(); public abstract boolean getStreamManagementEnabled(); + public abstract List<Certificate> getPeerCertificateChain(); public final Signal1<Message> onMessageReceived = new Signal1<Message>(); public final Signal1<Presence> onPresenceReceived = new Signal1<Presence>(); |