From cb4600a1612a5dd8342656241e11ec45542cd1e0 Mon Sep 17 00:00:00 2001
From: Nick Hudson <nick.hudson@isode.com>
Date: Wed, 14 Mar 2012 14:29:32 +0000
Subject: 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

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
-- 
cgit v0.10.2-6-g49f6