public static boolean verifyCertificates(Certificate[] chain, String hostname, boolean isS2S) {
        final CertificateStoreManager certificateStoreManager = XMPPServer.getInstance().getCertificateStoreManager();
        final ConnectionType connectionType = isS2S ? ConnectionType.SOCKET_S2S : ConnectionType.SOCKET_C2S;
        final TrustStore trustStore = certificateStoreManager.getTrustStore( connectionType );
        final X509Certificate trusted = trustStore.getEndEntityCertificate( chain );
        if (trusted != null) {
            return verifyCertificate(trusted, hostname);
        }
        return false;
    }
Handles the SASL authentication packet. The entity may be sending an initial
authentication request or a response to a challenge made by the server. The returned
value indicates whether the authentication has finished either successfully or not or
if the entity is expected to send a response to a challenge.

@param session the session that is authenticating with the server.
@param doc the stanza sent by the authenticating entity.
@return value that indicates whether the authentication has finished either successfully
        or not or if the entity is expected to send a response to a challenge.
xmppserver/src/main/java/org/jivesoftware/openfire/net/SASLAuthentication.java