summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Hudson <nick.hudson@isode.com>2012-03-14 14:29:32 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-03-19 11:21:49 (GMT)
commitcb4600a1612a5dd8342656241e11ec45542cd1e0 (patch)
tree1e2c1b2658f166ef97d7d5cf513cc6bdce80bc0b
parent843382f762f88f37d9b363fe3fc1418326894d21 (diff)
downloadstroke-cb4600a1612a5dd8342656241e11ec45542cd1e0.zip
stroke-cb4600a1612a5dd8342656241e11ec45542cd1e0.tar.bz2
Add "isTLSEncrypted" and "getPeerCertificate" to CoreClient
Corresponding with change in Swiften (assuming that is approved; it's not yet been integrated at the time of writing) Test-information: Works as expected in my test applications
-rw-r--r--src/com/isode/stroke/client/CoreClient.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/com/isode/stroke/client/CoreClient.java b/src/com/isode/stroke/client/CoreClient.java
index cae1bdb..453307e 100644
--- a/src/com/isode/stroke/client/CoreClient.java
+++ b/src/com/isode/stroke/client/CoreClient.java
@@ -30,6 +30,7 @@ import com.isode.stroke.signals.Signal1;
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 com.isode.stroke.tls.CertificateTrustChecker;
import com.isode.stroke.tls.CertificateVerificationError;
import com.isode.stroke.tls.CertificateWithKey;
@@ -403,6 +404,25 @@ public class CoreClient {
public boolean isAvailable() {
return stanzaChannel_.isAvailable();
}
+
+ /**
+ * Determine whether the underlying session is encrypted with TLS
+ * @return true if the session is initialized and encrypted with TLS,
+ * false otherwise.
+ */
+ public boolean isSessionTLSEncrypted() {
+ 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 (sessionStream_ == null ? null : sessionStream_.getPeerCertificate());
+ }
+
/**
* @return JID of the client, will never be null. After the session was