Search in sources :

Example 1 with StartTls

use of org.jivesoftware.smack.packet.StartTls in project Smack by igniterealtime.

the class XMPPTCPConnection method afterFeaturesReceived.

@Override
protected void afterFeaturesReceived() throws NotConnectedException, InterruptedException {
    StartTls startTlsFeature = getFeature(StartTls.ELEMENT, StartTls.NAMESPACE);
    if (startTlsFeature != null) {
        if (startTlsFeature.required() && config.getSecurityMode() == SecurityMode.disabled) {
            SmackException smackException = new SecurityRequiredByServerException();
            tlsHandled.reportFailure(smackException);
            notifyConnectionError(smackException);
            return;
        }
        if (config.getSecurityMode() != ConnectionConfiguration.SecurityMode.disabled) {
            sendNonza(new StartTls());
        } else {
            tlsHandled.reportSuccess();
        }
    } else {
        tlsHandled.reportSuccess();
    }
    if (getSASLAuthentication().authenticationSuccessful()) {
        // If we have received features after the SASL has been successfully completed, then we
        // have also *maybe* received, as it is an optional feature, the compression feature
        // from the server.
        maybeCompressFeaturesReceived.reportSuccess();
    }
}
Also used : SecurityRequiredByServerException(org.jivesoftware.smack.SmackException.SecurityRequiredByServerException) SmackException(org.jivesoftware.smack.SmackException) StartTls(org.jivesoftware.smack.packet.StartTls)

Aggregations

SmackException (org.jivesoftware.smack.SmackException)1 SecurityRequiredByServerException (org.jivesoftware.smack.SmackException.SecurityRequiredByServerException)1 StartTls (org.jivesoftware.smack.packet.StartTls)1