当前位置: 首页>>代码示例>>Java>>正文


Java StartTls类代码示例

本文整理汇总了Java中org.jivesoftware.smack.packet.StartTls的典型用法代码示例。如果您正苦于以下问题:Java StartTls类的具体用法?Java StartTls怎么用?Java StartTls使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StartTls类属于org.jivesoftware.smack.packet包,在下文中一共展示了StartTls类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseStartTlsFeature

import org.jivesoftware.smack.packet.StartTls; //导入依赖的package包/类
public static StartTls parseStartTlsFeature(XmlPullParser parser)
                throws XmlPullParserException, IOException {
    assert (parser.getEventType() == XmlPullParser.START_TAG);
    assert (parser.getNamespace().equals(StartTls.NAMESPACE));
    int initalDepth = parser.getDepth();
    boolean required = false;
    outerloop: while (true) {
        int event = parser.next();
        switch (event) {
        case XmlPullParser.START_TAG:
            String name = parser.getName();
            switch (name) {
            case "required":
                required = true;
                break;
            }
            break;
        case XmlPullParser.END_TAG:
            if (parser.getDepth() == initalDepth) {
                break outerloop;
            }
        }
    }
    assert(parser.getEventType() == XmlPullParser.END_TAG);
    return new StartTls(required);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:PacketParserUtils.java

示例2: afterFeaturesReceived

import org.jivesoftware.smack.packet.StartTls; //导入依赖的package包/类
@Override
protected void afterFeaturesReceived() throws SecurityRequiredException, NotConnectedException {
    StartTls startTlsFeature = getFeature(StartTls.ELEMENT, StartTls.NAMESPACE);
    if (startTlsFeature != null) {
        if (startTlsFeature.required() && config.getSecurityMode() == SecurityMode.disabled) {
            notifyConnectionError(new SecurityRequiredByServerException());
            return;
        }
        // 发送StartTLS的封包
        // 让我们进入TLS链接
        if (config.getSecurityMode() != ConnectionConfiguration.SecurityMode.disabled) {
            send(new StartTls());
        }
    }
    // If TLS is required but the server doesn't offer it, disconnect
    // from the server and throw an error. First check if we've already negotiated TLS
    // and are secure, however (features get parsed a second time after TLS is established).
    if (!isSecureConnection() && startTlsFeature == null
                    && getConfiguration().getSecurityMode() == SecurityMode.required) {
        throw new SecurityRequiredByClientException();
    }

    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();
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:30,代码来源:XMPPTCPConnection.java

示例3: afterFeaturesReceived

import org.jivesoftware.smack.packet.StartTls; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:28,代码来源:XMPPTCPConnection.java

示例4: parseFeatures

import org.jivesoftware.smack.packet.StartTls; //导入依赖的package包/类
protected final void parseFeatures(XmlPullParser parser) throws XmlPullParserException,
                IOException, SmackException {
    streamFeatures.clear();
    final int initialDepth = parser.getDepth();
    while (true) {
        int eventType = parser.next();

        if (eventType == XmlPullParser.START_TAG && parser.getDepth() == initialDepth + 1) {
            ExtensionElement streamFeature = null;
            String name = parser.getName();
            String namespace = parser.getNamespace();
            switch (name) {
            case StartTls.ELEMENT:
                streamFeature = PacketParserUtils.parseStartTlsFeature(parser);
                break;
            case Mechanisms.ELEMENT:
                streamFeature = new Mechanisms(PacketParserUtils.parseMechanisms(parser));
                break;
            case Bind.ELEMENT:
                streamFeature = Bind.Feature.INSTANCE;
                break;
            case Session.ELEMENT:
                streamFeature = PacketParserUtils.parseSessionFeature(parser);
                break;
            case Compress.Feature.ELEMENT:
                streamFeature = PacketParserUtils.parseCompressionFeature(parser);
                break;
            default:
                ExtensionElementProvider<ExtensionElement> provider = ProviderManager.getStreamFeatureProvider(name, namespace);
                if (provider != null) {
                    streamFeature = provider.parse(parser);
                }
                break;
            }
            if (streamFeature != null) {
                // 将特性放入列表中
                addStreamFeature(streamFeature);
            }
        }
        else if (eventType == XmlPullParser.END_TAG && parser.getDepth() == initialDepth) {
            break;
        }
    }

    if (hasFeature(Mechanisms.ELEMENT, Mechanisms.NAMESPACE)) {
        // Only proceed with SASL auth if TLS is disabled or if the server doesn't announce it
        if (!hasFeature(StartTls.ELEMENT, StartTls.NAMESPACE)
                        || config.getSecurityMode() == SecurityMode.disabled) {
            // connecting算事完成了
            saslFeatureReceived.reportSuccess();
        }
    }

    // If the server reported the bind feature then we are that that we did SASL and maybe
    // STARTTLS. We can then report that the last 'stream:features' have been parsed
    if (hasFeature(Bind.ELEMENT, Bind.NAMESPACE)) {
        if (!hasFeature(Compress.Feature.ELEMENT, Compress.NAMESPACE)
                        || !config.isCompressionEnabled()) {
            // This was was last features from the server is either it did not contain
            // compression or if we disabled it
            lastFeaturesReceived.reportSuccess();
        }
    }
    afterFeaturesReceived();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:66,代码来源:AbstractXMPPConnection.java


注:本文中的org.jivesoftware.smack.packet.StartTls类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。