private static void sendElement(Session session, String element, byte[] data) {
        final Element reply = DocumentHelper.createElement(QName.get(element, "urn:ietf:params:xml:ns:xmpp-sasl"));
        if (data != null) {
            String data_b64 = Base64.getEncoder().encodeToString(data).trim();
            if (data_b64.isEmpty()) {
                data_b64 = "=";
            }
            reply.addText(data_b64);
        }
        session.deliverRawText(reply.asXML());
    }
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