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


Java SecurityMode类代码示例

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


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

示例1: XMPPWithIQProtocol

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入依赖的package包/类
public XMPPWithIQProtocol(String ipAddress, int port, String user,
		String password) throws XMPPException {
	
	// Connect:
	config = new ConnectionConfiguration(ipAddress, port);
	config.setSASLAuthenticationEnabled(false);
       config.setSecurityMode(SecurityMode.disabled);
       
       connection = new XMPPConnection(config);
       connection.connect();
       
       // Login:
       connection.login(user, password, "root");
       
       // Add IQ provider:
       ProviderManager.getInstance().addIQProvider("query", "iq:myOwn", new MyIQProvider());
}
 
开发者ID:tokahuke,项目名称:java-for-playwrights,代码行数:18,代码来源:XMPPWithIQProtocol.java

示例2: connect

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入依赖的package包/类
public void connect(String hostname, int port, String username, String password) throws Exception {

    purgeTask("reconnect");

    this.hostname = hostname;
    this.serviceName = hostname;
    this.port = port;
    this.username = username;
    this.password = password;

    Builder builder = XMPPTCPConnectionConfiguration.builder();
    builder.setUsernameAndPassword(username, password);
    builder.setServiceName(serviceName);
    builder.setServiceName(hostname);
    builder.setPort(port);
    builder.setSecurityMode(SecurityMode.disabled);
    builder.setDebuggerEnabled(true);

    XMPPTCPConnectionConfiguration config = builder.build();

    connection = new XMPPTCPConnection(config);
    connection.connect().login();

    roster = Roster.getInstanceFor(connection);
    chatManager = ChatManager.getInstanceFor(connection);

    roster.addRosterListener(this);

    isConnected = true;

    // not worth it - always empty right after connect
    // getContactList();

    broadcastState();
  }
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:36,代码来源:Xmpp.java

示例3: KontalkConnection

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入依赖的package包/类
public KontalkConnection(EndpointServer server,
        PrivateKey privateKey, X509Certificate bridgeCert,
        boolean acceptAnyCertificate, KeyStore trustStore) throws XMPPException {

    super(new AndroidConnectionConfiguration
            (server.getHost(),
             server.getPort(),
             server.getNetwork()));

    mServer = server;
    // disable reconnection
    config.setReconnectionAllowed(false);
    // we don't need the roster
    config.setRosterLoadedAtLogin(false);
    // enable compression
    config.setCompressionEnabled(true);
    // enable encryption
    config.setSecurityMode(SecurityMode.enabled);
    // we will send a custom presence
    config.setSendPresence(false);

    setupSSL(privateKey, bridgeCert, acceptAnyCertificate, trustStore);
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:24,代码来源:KontalkConnection.java

示例4: initConnect

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入依赖的package包/类
/**
 * 通过主机名和端口号去对服务器进行连接和一些初始化
 */
private void initConnect() {
    if (!isConnected()) {
        String connectionHost = mNotificationService.getHost();
        int connectionPort = Integer.parseInt(mNotificationService
                .getPort());
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                connectionHost, connectionPort);
        connConfig.setSecurityMode(SecurityMode.required);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);
        mConnection = new XMPPConnection(connConfig);
        try {
            mConnection.connect();
            ProviderManager.getInstance().addIQProvider(ELEMENT_NAME,
                    NAME_SPACE, new NotificationIQProvider());
        } catch (XMPPException e) {
            startReconnection();
        }
    }
}
 
开发者ID:polyvi,项目名称:openxface-android,代码行数:24,代码来源:XConnectionManager.java

示例5: run

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入依赖的package包/类
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");
    boolean connected = false;
    if (!xmppManager.isConnected()) {
        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        // connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSecurityMode(SecurityMode.required);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        xmppManager.setConnection(connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationIQProvider());
            connected = true;

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        if (connected) {
            xmppManager.runTask();
        }

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        xmppManager.runTask();
    }
}
 
开发者ID:daktak,项目名称:androidpn-client,代码行数:40,代码来源:XmppManager.java

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

示例7: run

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入依赖的package包/类
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!xmppManager.isConnected()) {
        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        // connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSecurityMode(SecurityMode.required);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        xmppManager.setConnection(connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationIQProvider());

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        xmppManager.runTask();

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        xmppManager.runTask();
    }
}
 
开发者ID:xujk2008,项目名称:MessagePushClient,代码行数:37,代码来源:XmppManager.java

示例8: run

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入依赖的package包/类
public void run() {
	Log.i(LOGTAG, "ConnectTask.run()...");

	if (!xmppManager.isConnected()) {
		// Create the configuration for this new connection
		ConnectionConfiguration connConfig = new ConnectionConfiguration(
				xmppHost, xmppPort);
		// connConfig.setSecurityMode(SecurityMode.disabled);
		connConfig.setSecurityMode(SecurityMode.required);
		connConfig.setSASLAuthenticationEnabled(false);
		connConfig.setCompressionEnabled(false);

		XMPPConnection connection = new XMPPConnection(connConfig);
		xmppManager.setConnection(connection);

		try {
			// Connect to the server
			connection.connect();
			Log.i(LOGTAG, "XMPP connected successfully");

			// packet provider
			ProviderManager.getInstance().addIQProvider("notification",
					"androidpn:iq:notification",
					new NotificationIQProvider());
			xmppManager.runTask();
		} catch (XMPPException e) {
			Log.e(LOGTAG, "XMPP connection failed", e);
			xmppManager.dropTask(2);
			xmppManager.startReconnectionThread();
			xmppManager.runTask();
		}
	} else {
		Log.i(LOGTAG, "XMPP connected already");
		xmppManager.runTask();
	}
}
 
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:37,代码来源:XmppManager.java

示例9: run

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入依赖的package包/类
public void run() {

			if (!xmppManager.isConnected()) {
				// Create the configuration for this new connection
				ConnectionConfiguration connConfig = new ConnectionConfiguration(xmppHost, xmppPort);
				// connConfig.setSecurityMode(SecurityMode.disabled);
				// connConfig.setSecurityMode(SecurityMode.required);
				connConfig.setSASLAuthenticationEnabled(false);
				connConfig.setCompressionEnabled(false);
				connConfig.setSecurityMode(SecurityMode.disabled);

				XMPPConnection connection = new XMPPConnection(connConfig);
				xmppManager.setConnection(connection);

				try {
					// Connect to the server
					connection.connect();

					// packet provider
					ProviderManager.getInstance().addIQProvider("notification", "androidpn:iq:notification", new NotificationIQProvider());
					reconnection.waiting = 0;
					reconnection.needWork.set(false);
				} catch (XMPPException e) {
					e.printStackTrace();
				}

				xmppManager.runTask();

			} else {
				xmppManager.runTask();
			}
		}
 
开发者ID:bestarandyan,项目名称:ShoppingMall,代码行数:33,代码来源:XmppManager.java

示例10: 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();
    }
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:28,代码来源:XMPPTCPConnection.java

示例11: run

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入依赖的package包/类
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!XmppManager.isConnected(xmppManager)) {

        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        XmppManager.setXMPPConnection(xmppManager, connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationProvider());

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        XmppManager.runTask(xmppManager);

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        XmppManager.runTask(xmppManager);
    }

}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:38,代码来源:XmppManager.java

示例12: run

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入依赖的package包/类
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!xmppManager.isConnected()) {
        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        xmppManager.setConnection(connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationIQProvider());

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        xmppManager.runTask();

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        xmppManager.runTask();
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:36,代码来源:XmppManager.java

示例13: run

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入依赖的package包/类
public void run() {
    Log.i(LOGTAG, "ConnectTask.run()...");

    if (!XmppManager.isConnected(xmppManager)) {

        // Create the configuration for this new connection
        ConnectionConfiguration connConfig = new ConnectionConfiguration(
                xmppHost, xmppPort);
        connConfig.setSecurityMode(SecurityMode.disabled);
        connConfig.setSASLAuthenticationEnabled(false);
        connConfig.setCompressionEnabled(false);

        XMPPConnection connection = new XMPPConnection(connConfig);
        XmppManager.setXMPPConnection(xmppManager, connection);

        try {
            // Connect to the server
            connection.connect();
            Log.i(LOGTAG, "XMPP connected successfully");

            // packet provider
            ProviderManager.getInstance().addIQProvider("notification",
                    "androidpn:iq:notification",
                    new NotificationIQProvider());

        } catch (XMPPException e) {
            Log.e(LOGTAG, "XMPP connection failed", e);
        }

        XmppManager.runTask(xmppManager);

    } else {
        Log.i(LOGTAG, "XMPP connected already");
        XmppManager.runTask(xmppManager);
    }

}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:38,代码来源:XmppManager.java

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

示例15: updated

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public void updated(Dictionary config) throws ConfigurationException {
	if (config == null) {
		return;
	}
	XMPPConnect.servername = (String) config.get("servername");
	XMPPConnect.proxy = (String) config.get("proxy");
	String portString = (String) config.get("port");
	if (portString != null) {
		XMPPConnect.port = Integer.valueOf(portString);
	}
	XMPPConnect.username = (String) config.get("username");
	XMPPConnect.password = (String) config.get("password");
	XMPPConnect.chatroom = (String) config.get("chatroom");
	XMPPConnect.chatnickname = (String) config.get("chatnickname");
	XMPPConnect.chatpassword = (String) config.get("chatpassword");

	String securityModeString = (String) config.get("securitymode");
	if (securityModeString != null) {
		securityMode = SecurityMode.valueOf(securityModeString);
	}
	XMPPConnect.tlsPin = (String) config.get("tlspin");

	String users = (String) config.get("consoleusers");

	if (!StringUtils.isEmpty(users)) {
		XMPPConnect.consoleUsers = users.split(",");
	} else {
		XMPPConnect.consoleUsers = new String[0];
	}

	// check mandatory settings
	if (StringUtils.isEmpty(servername)) return;
	if (StringUtils.isEmpty(username)) return;
	if (StringUtils.isEmpty(password)) return;

	// set defaults for optional settings
	if (port == null) {
		port = 5222;
	}
	if (StringUtils.isEmpty(chatnickname)) {
		chatnickname = "openhab-bot";
	}

	establishConnection();
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:47,代码来源:XMPPConnect.java


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