本文整理汇总了Java中org.jivesoftware.smack.ConnectionConfiguration.SecurityMode.disabled方法的典型用法代码示例。如果您正苦于以下问题:Java SecurityMode.disabled方法的具体用法?Java SecurityMode.disabled怎么用?Java SecurityMode.disabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.ConnectionConfiguration.SecurityMode
的用法示例。
在下文中一共展示了SecurityMode.disabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterFeaturesReceived
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入方法依赖的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();
}
}
示例2: afterFeaturesReceived
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入方法依赖的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();
}
}
示例3: parseFeatures
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入方法依赖的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();
}
示例4: ConnectionHandler
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入方法依赖的package包/类
/**
* Instantiates a connection handler with the given connection configuration and user credentials.
* @param user XMPP username of the user to log in when connecting to the server.
* @param password Password of the user to log in.
* @param connectionConfiguration Connection configuration.
*/
public ConnectionHandler(String user, String password, de.imc.mirror.sdk.ConnectionConfiguration connectionConfiguration){
this.connectionConfiguration = connectionConfiguration;
this.password = password;
listeners = new ArrayList<ConnectionStatusListener>();
setConnectionStatus(ConnectionStatus.OFFLINE);
ProviderInitializer.initializeProviderManager();
org.jivesoftware.smack.ConnectionConfiguration config =
new org.jivesoftware.smack.ConnectionConfiguration(connectionConfiguration.getHost(),
connectionConfiguration.getPort());
SecurityMode mode;
if (connectionConfiguration.isSecureConnection()){
mode = SecurityMode.required;
} else {
mode = SecurityMode.disabled;
}
userInfo = new de.imc.mirror.sdk.android.UserInfo(user,
connectionConfiguration.getDomain(),
connectionConfiguration.getApplicationID());
config.setSecurityMode(mode);
config.setSelfSignedCertificateEnabled(connectionConfiguration.isSelfSignedCertificateEnabled());
config.setReconnectionAllowed(true);
connection = new XMPPConnection(config);
networkInformation = null;
pendingIQRequests = new HashMap<String, RequestFuture<Element>>();
iqPacketListener = new PacketListener() {
@Override
public void processPacket(Packet packet) {
if (pendingIQRequests.containsKey(packet.getPacketID())){
RequestFuture<Element> iqFuture = pendingIQRequests.get(packet.getPacketID());
pendingIQRequests.remove(packet.getPacketID());
SAXBuilder reader = new SAXBuilder();
Document document = null;
try {
document = reader.build(new StringReader(packet.toXML()));
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to parse incoming IQ packet.", e);
}
Element childElement = document.getRootElement();
if (childElement != null) {
iqFuture.setResponse(childElement);
}
}
}
};
connection.addPacketListener(iqPacketListener, new PacketTypeFilter(IQ.class));
}