Search in sources :

Example 91 with QName

use of org.dom4j.QName in project Openfire by igniterealtime.

the class SASLAuthentication method getSASLMechanismsElement.

public static Element getSASLMechanismsElement(ClientSession session) {
    final Element result = DocumentHelper.createElement(new QName("mechanisms", new Namespace("", SASL_NAMESPACE)));
    for (String mech : getSupportedMechanisms()) {
        if (mech.equals("EXTERNAL")) {
            boolean trustedCert = false;
            if (session.isSecure()) {
                final Connection connection = ((LocalClientSession) session).getConnection();
                if (SKIP_PEER_CERT_REVALIDATION_CLIENT.getValue()) {
                    // Trust that the peer certificate has been validated when TLS got established.
                    trustedCert = connection.getPeerCertificates() != null && connection.getPeerCertificates().length > 0;
                } else {
                    // Re-evaluate the validity of the peer certificate.
                    final TrustStore trustStore = connection.getConfiguration().getTrustStore();
                    trustedCert = trustStore.isTrusted(connection.getPeerCertificates());
                }
            }
            if (!trustedCert) {
                // Do not offer EXTERNAL.
                continue;
            }
        }
        final Element mechanism = result.addElement("mechanism");
        mechanism.setText(mech);
    }
    // OF-2072: Return null instead of an empty element, if so configured.
    if (JiveGlobals.getBooleanProperty("sasl.client.suppressEmpty", false) && result.elements().isEmpty()) {
        return null;
    }
    return result;
}
Also used : LocalClientSession(org.jivesoftware.openfire.session.LocalClientSession) QName(org.dom4j.QName) Element(org.dom4j.Element) Connection(org.jivesoftware.openfire.Connection) TrustStore(org.jivesoftware.openfire.keystore.TrustStore) Namespace(org.dom4j.Namespace)

Aggregations

QName (org.dom4j.QName)91 Element (org.dom4j.Element)66 Namespace (org.dom4j.Namespace)18 FieldSet (org.collectionspace.chain.csp.schema.FieldSet)11 Document (org.dom4j.Document)10 HashMap (java.util.HashMap)9 ServiceException (com.zimbra.common.service.ServiceException)7 Element (com.zimbra.common.soap.Element)7 XMLElement (com.zimbra.common.soap.Element.XMLElement)6 Record (org.collectionspace.chain.csp.schema.Record)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 Attribute (org.dom4j.Attribute)5 Test (org.junit.Test)5 JSONElement (com.zimbra.common.soap.Element.JSONElement)4 DavException (com.zimbra.cs.dav.DavException)4 Field (org.collectionspace.chain.csp.schema.Field)4 ZMailbox (com.zimbra.client.ZMailbox)3 ExceptionToString (com.zimbra.common.util.ExceptionToString)3 List (java.util.List)3