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


Java ConnectionConfiguration.setSecurityMode方法代码示例

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


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

示例1: createXMPPConnection

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
/**
 * 工厂模式获取连接对象 还没有连接服务器
 * @param connectionTimeOut   连接超时的时间
 * @param reconnectionAllowed 是否准许重连接
 * @param isPresence          是否在线
 * @param debugEnable         是否调试
 * @param securityMode        安全模式
 * @param connectionListener  连接监听器
 * @return
 */
public static XMPPConnection createXMPPConnection(int connectionTimeOut, boolean reconnectionAllowed, boolean isPresence, boolean debugEnable,
                                                  ConnectionConfiguration.SecurityMode securityMode, ConnectionListener connectionListener) {
    //设置是否开启DEBUG模式
    XMPPConnection.DEBUG_ENABLED = debugEnable;
    //设置连接地址、端口
    ConnectionConfiguration configuration = new ConnectionConfiguration(SERVERADDRESS, PORT);
    //设置服务器名称
    configuration.setServiceName(SERVERNAME);
    //设置是否需要SAS验证
    configuration.setSASLAuthenticationEnabled(false);
    //设置安全类型
    configuration.setSecurityMode(securityMode);
    //设置用户状态
    configuration.setSendPresence(isPresence);
    //设置是否准许重连接
    configuration.setReconnectionAllowed(reconnectionAllowed);
    //实例化连接对象
    XMPPConnection xmppConnection = new XMPPConnection(configuration);
    //添加连接监听器
    if (connectionListener != null) {
        xmppConnection.addConnectionListener(connectionListener);
    }
    return xmppConnection;
}
 
开发者ID:FanHuaRan,项目名称:SmackStudy,代码行数:35,代码来源:XMPPUtil.java

示例2: XMPPWithIQProtocol

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的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

示例3: init

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
/**
 * 初始化连接
 * @param loginConfig
 * @return
 */
public XMPPConnection init(IMConfig loginConfig) {
	Connection.DEBUG_ENABLED = false;
	ProviderManager pm = ProviderManager.getInstance();
	configure(pm);

	connectionConfig = new ConnectionConfiguration(
			loginConfig.getXmppHost(), loginConfig.getXmppPort(),
			loginConfig.getXmppServiceName());
	//connectionConfig.setSASLAuthenticationEnabled(false);// 不使用SASL验证,设置为false
	connectionConfig
			.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
	// 允许自动连接
	connectionConfig.setReconnectionAllowed(false);
	// 允许登陆成功后更新在线状态
	connectionConfig.setSendPresence(true);
	// 收到好友邀请后manual表示需要经过同意,accept_all表示不经同意自动为好友
	Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual);
	connection = new XMPPConnection(connectionConfig);
	return connection;
}
 
开发者ID:jingshauizh,项目名称:androidsummary,代码行数:26,代码来源:XmppConnectionManager.java

示例4: connect

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public static XMPPConnection connect(String host) throws XMPPException
{
    ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration(host, 5222, "excalibur.org");
    connectionConfiguration.setCompressionEnabled(false);
    connectionConfiguration.setSelfSignedCertificateEnabled(true);
    connectionConfiguration.setExpiredCertificatesCheckEnabled(false);
    connectionConfiguration.setDebuggerEnabled(false);
    connectionConfiguration.setSASLAuthenticationEnabled(true);
    connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
    //XMPPConnection.DEBUG_ENABLED = false;
    
    XMPPConnection connection = new XMPPConnection(connectionConfiguration);
    connection.connect();
    
    return connection;
}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:17,代码来源:Client.java

示例5: build

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public ConnectionConfiguration build()
{
    Preconditions.checkArgument(!Strings.isNullOrEmpty(this.host_) && !Strings.isNullOrEmpty(this.serviceName_));
    ConnectionConfiguration configuration = new ConnectionConfiguration(host_, port_, serviceName_);

    configuration.setCompressionEnabled(this.compressionEnabled_);
    configuration.setSelfSignedCertificateEnabled(this.selfSignedCertificateEnabled_);
    configuration.setExpiredCertificatesCheckEnabled(this.expiredCertificatesCheckEnabled_);
    configuration.setSASLAuthenticationEnabled(this.saaslAuthenticationEnabled_);
    configuration.setSecurityMode(this.securityMode_);
    configuration.setRosterLoadedAtLogin(this.loadRosterAtLogin_);
    configuration.setSendPresence(this.sendPresence_);

    return configuration;

}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:17,代码来源:XMPPConnectionConfigurationBuilder.java

示例6: LolChat

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
/**
 * Represents a single connection to a League of Legends chatserver.
 * 
 * @param server
 *            The chatserver of the region you want to connect to
 * @param friendRequestPolicy
 *            Determines how new Friend requests are treated.
 * @param riotApiKey
 *            Your apiKey used to convert summonerId's to name. You can get
 *            your key here <a
 *            href="https://developer.riotgames.com/">developer
 *            .riotgames.com</a>
 * 
 * @see LolChat#setFriendRequestPolicy(FriendRequestPolicy)
 * @see LolChat#setFriendRequestListener(FriendRequestListener)
 */
public LolChat(ChatServer server, FriendRequestPolicy friendRequestPolicy,
		RiotApiKey riotApiKey) {
	this.friendRequestPolicy = friendRequestPolicy;
	this.server = server;
	if (riotApiKey != null && server.api != null) {
		this.riotApi = RiotApi.build(riotApiKey, server);
	}
	Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
	final ConnectionConfiguration config = new ConnectionConfiguration(
			server.host, 5223, "pvp.net");
	config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
	config.setSocketFactory(SSLSocketFactory.getDefault());
	config.setCompressionEnabled(true);
	connection = new XMPPTCPConnection(config);

	addListeners();
}
 
开发者ID:TheHolyWaffle,项目名称:League-of-Legends-XMPP-Chat-Library,代码行数:34,代码来源:LolChat.java

示例7: initConnect

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的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

示例8: build

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public MessageSender build() {
  final ConnectionConfiguration configuration = new ConnectionConfiguration(
      this.host,
      this.port,
      this.serviceName == null ? this.host : this.serviceName);
  configuration.setSASLAuthenticationEnabled(this.isSASLAuthenticationEnabled);
  configuration.setSendPresence(this.isSendPresence);
  configuration.setSecurityMode(this.securityMode.getConfigurationValue());
  return new MessageSender(
      configuration,
      this.userName,
      this.password,
      this.saslAuthenticationTypes,
      this.receivers);
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:16,代码来源:MessageSenderBuilder.java

示例9: run

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的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

示例10: testManyResources

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public void testManyResources() throws Exception {
        // Create 5 more connections for user2
        XMPPTCPConnection[] conns = new XMPPConnection[5];
        for (int i = 0; i < conns.length; i++) {
            ConnectionConfiguration connectionConfiguration =
                    new ConnectionConfiguration(getHost(), getPort(), getServiceName());
            connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
            conns[i] = new XMPPTCPConnection(connectionConfiguration);
            conns[i].connect();
            conns[i].login(getUsername(1), getPassword(1), "resource-" + i);
            Thread.sleep(20);
        }

        // Join the 5 connections to the same room
        MultiUserChat[] mucs = new MultiUserChat[5];
        for (int i = 0; i < mucs.length; i++) {
            mucs[i] = new MultiUserChat(conns[i], room);
            mucs[i].join("resource-" + i);
        }

        Thread.sleep(200);

        // Each connection has something to say
        for (int i = 0; i < mucs.length; i++) {
            mucs[i].sendMessage("I'm resource-" + i);
        }

        Thread.sleep(200);

        // Each connection leaves the room and closes the connection
        for (MultiUserChat muc1 : mucs) {
            muc1.leave();
        }

        Thread.sleep(200);

        for (int i = 0; i < mucs.length; i++) {
            conns[i].disconnect();
        }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:41,代码来源:MultiUserChatTest.java

示例11: init

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public XMPPConnection init(LoginConfig loginConfig) {

		Connection.DEBUG_ENABLED = false;
		ProviderManager pm = ProviderManager.getInstance();
		configure(pm);
		connectionConfig = new ConnectionConfiguration(
				loginConfig.getXmppHost(), loginConfig.getXmppPort(),
				loginConfig.getXmppServiceName());
		 try {
			Class.forName("org.jivesoftware.smackx.ServiceDiscoveryManager", true, XmppConnectionManager.class.getClassLoader());
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	/// ServiceDiscoveryManager discoManager = new ServiceDiscoveryManager(connection);
		connectionConfig.setSASLAuthenticationEnabled(false);// ��ʹ��SASL��֤������Ϊfalse
		connectionConfig
				.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
		// �����Զ�����
		connectionConfig.setReconnectionAllowed(false);
		// �����½�ɹ����������״̬
		connectionConfig.setSendPresence(true);
		// connectionConfig.setSendPresence(false);
		// �յ����������manual��ʾ��Ҫ����ͬ��,accept_all��ʾ����ͬ���Զ�Ϊ����
		Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual);
		connection = new XMPPConnection(connectionConfig);
		return connection;
	}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:29,代码来源:XmppConnectionManager.java

示例12: run

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的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

示例13: initXMPPClient

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
/**
	 * Initializes the XMPP Client. Sets the time-out-limit whilst waiting for XMPP-replies from
	 * server. Sets the XMPP configurations to connect to the server and creates the
	 * XMPPConnection object used for connecting and Logging-In.
	 */
	private void initXMPPClient() {
		log.info(String.format("Initializing connection to XMPP Server at %1$s via port " +
				                       "%2$d......",
		                       server, port));
		SmackConfiguration.setPacketReplyTimeout(timeoutInterval);
		config = new ConnectionConfiguration(server, port);
//		TODO:: Need to enable SASL-Authentication appropriately
		config.setSASLAuthenticationEnabled(false);
		config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
		connection = new XMPPConnection(config);
	}
 
开发者ID:wso2-incubator,项目名称:iot-server-appliances,代码行数:17,代码来源:XMPPCommunicationHandler.java

示例14: run

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的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

示例15: run

import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的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


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