當前位置: 首頁>>代碼示例>>Java>>正文


Java ConnectionConfiguration.setSASLAuthenticationEnabled方法代碼示例

本文整理匯總了Java中org.jivesoftware.smack.ConnectionConfiguration.setSASLAuthenticationEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java ConnectionConfiguration.setSASLAuthenticationEnabled方法的具體用法?Java ConnectionConfiguration.setSASLAuthenticationEnabled怎麽用?Java ConnectionConfiguration.setSASLAuthenticationEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jivesoftware.smack.ConnectionConfiguration的用法示例。


在下文中一共展示了ConnectionConfiguration.setSASLAuthenticationEnabled方法的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: getXMPPConnection

import org.jivesoftware.smack.ConnectionConfiguration; //導入方法依賴的package包/類
/**
 * Gets the XMPP connection.
 *
 * @return the XMPP connection
 */
public XMPPConnection getXMPPConnection()
{
	if (this.xmpp == null)
	{
		ConnectionConfiguration config = new ConnectionConfiguration(serverConfigPrefsItem.getClusterHost(), serverConfigPrefsItem.getPort());
		config.setSASLAuthenticationEnabled(false);
		config.setDebuggerEnabled(false);
		this.xmpp = new XMPPConnection(config);
		try
		{
			xmpp.connect();
			xmpp.login(identity, serverConfigPrefsItem.getClusterPassword());
		}
		catch (XMPPException e)
		{
			e.printStackTrace();
		}
	}
	return xmpp;
}
 
開發者ID:synergynet,項目名稱:synergynet3.1,代碼行數:26,代碼來源:SynergyNetCluster.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: ConnectionManager

import org.jivesoftware.smack.ConnectionConfiguration; //導入方法依賴的package包/類
public ConnectionManager(Context context,
		ConnectionStatusCallback statusCallback,
		CommunicationManager communicationManager) {
	this.statusCallback = statusCallback;
	this.communicationManager = communicationManager;

	smack = SmackAndroid.init(context);

	SASLAuthentication.registerSASLMechanism(GTalkOAuthSASLMechanism.NAME,
			GTalkOAuthSASLMechanism.class);
	SASLAuthentication
			.supportSASLMechanism(GTalkOAuthSASLMechanism.NAME, 0);

	ConnectionConfiguration configuration = new ConnectionConfiguration(
			"talk.google.com", 5222, "gmail.com");
	configuration.setSASLAuthenticationEnabled(true);

	connection = new XMPPConnection(configuration);
}
 
開發者ID:nickglobal,項目名稱:TvPoo,代碼行數:20,代碼來源:ConnectionManager.java

示例7: makeXMPPConnection

import org.jivesoftware.smack.ConnectionConfiguration; //導入方法依賴的package包/類
private Connection makeXMPPConnection(String username, String password){
	// Create the configuration for this new connection
	ConnectionConfiguration config = new ConnectionConfiguration("libraryh3lp.com", 5222);
	config.setCompressionEnabled(true);
	config.setSASLAuthenticationEnabled(true);
	
	// Create the connection and log in
	Connection con = new XMPPConnection(config);
	try {
		con.connect();
		con.login(username, password);
	} catch (XMPPException e) {
		e.printStackTrace();
		con = null;
	}
	
	return con;
}
 
開發者ID:jswelker,項目名稱:LibraryH3lp-Transfer-Bot,代碼行數:19,代碼來源:Chat.java

示例8: 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

示例9: init

import org.jivesoftware.smack.ConnectionConfiguration; //導入方法依賴的package包/類
/**
 * <b>function:</b> ��ʼSmack��openfire���������ӵĻ�������
 * 
 * @author hoojo
 * @createDate 2012-6-25 ����04:06:42
 */

public static void init() {
	try {
		// connection = new XMPPConnection(server);
		// connection.connect();

		/**
		 * 5222��openfire������Ĭ�ϵ�ͨ�Ŷ˿ڣ�����Ե�¼http://192.168.8.32:9090/
		 * ������Ա����̨�鿴�ͻ��˵��������˿�
		 */
		config = new ConnectionConfiguration(server, 5222);

		/** �Ƿ�����ѹ�� */
		config.setCompressionEnabled(true);
		/** �Ƿ����ð�ȫ��֤ */
		config.setSASLAuthenticationEnabled(false);
		/** �Ƿ����õ��� */
		config.setDebuggerEnabled(false);
		// config.setReconnectionAllowed(true);
		// config.setRosterLoadedAtLogin(true);

		/** ����connection���� */
		connection = new XMPPConnection(config);
		/** �������� */
		connection.connect();
	} catch (XMPPException e) {
		e.printStackTrace();
	}
	// fail(connection);
	// fail(connection.getConnectionID());
}
 
開發者ID:jiangzehui,項目名稱:xmpp,代碼行數:38,代碼來源:XmppTool.java

示例10: 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

示例11: 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

示例12: 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

示例13: lazyInit

import org.jivesoftware.smack.ConnectionConfiguration; //導入方法依賴的package包/類
private synchronized void lazyInit() {
if (this.connection != null && this.connection.isConnected()
	&& this.connection.isAuthenticated()) {
    return;
}

if (this.connection != null) {
    this.connection.disconnect();
}

final ConnectionConfiguration config = new ConnectionConfiguration(
	"talk.google.com", 5222, "gmail.com");
config.setSASLAuthenticationEnabled(true);

SASLAuthentication.supportSASLMechanism("PLAIN", 0);

this.connection = new XMPPConnection(config);

try {
    this.connection.connect();
    this.connection.login("[email protected]", "sybase365");

    LOG.debug("XMPP connection established");
} catch (final XMPPException e) {
    LOG.warn("Connection error: " + e.getMessage(), e);
}

   }
 
開發者ID:SAP,項目名稱:smp_mobiliser_template,代碼行數:29,代碼來源:GtalkAuthenticationHandler.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());

        } 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

示例15: 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


注:本文中的org.jivesoftware.smack.ConnectionConfiguration.setSASLAuthenticationEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。