From a73dcd6f53bf09b5a427681f0a6fafc4280c8344 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 24 Jun 2015 10:56:02 +0200 Subject: [PATCH] Shrink try body in XmppHostnameVerifier --- .../smack/java7/XmppHostnameVerifier.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/smack-java7/src/main/java/org/jivesoftware/smack/java7/XmppHostnameVerifier.java b/smack-java7/src/main/java/org/jivesoftware/smack/java7/XmppHostnameVerifier.java index 61ba37994..71a120bfe 100644 --- a/smack-java7/src/main/java/org/jivesoftware/smack/java7/XmppHostnameVerifier.java +++ b/smack-java7/src/main/java/org/jivesoftware/smack/java7/XmppHostnameVerifier.java @@ -78,19 +78,20 @@ public class XmppHostnameVerifier implements HostnameVerifier { } catch (SSLPeerUnverifiedException e) { // Not using certificates for peers, try verifying the principal + Principal peerPrincipal = null; try { - Principal peerPrincipal = session.getPeerPrincipal(); - if (peerPrincipal instanceof KerberosPrincipal) { - validPrincipal = match(hostname, (KerberosPrincipal) peerPrincipal); - } - else { - LOGGER.info("Can't verify principal for " + hostname + ". Not kerberos"); - } + peerPrincipal = session.getPeerPrincipal(); } catch (SSLPeerUnverifiedException e2) { LOGGER.log(Level.INFO, "Can't verify principal for " + hostname + ". Not kerberos", e2); } + if (peerPrincipal instanceof KerberosPrincipal) { + validPrincipal = match(hostname, (KerberosPrincipal) peerPrincipal); + } + else { + LOGGER.info("Can't verify principal for " + hostname + ". Not kerberos"); + } } return validCertificate || validPrincipal;