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


Java XMPPTCPConnectionConfiguration类代码示例

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


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

示例1: getConnectionConfigBuilder

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
public XMPPTCPConnectionConfiguration.Builder getConnectionConfigBuilder() {
	if (!isBasicConfigurationDone()) return null;

	if (confBuilderCache == null) {
		XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder();

		String password = getPassword();
		builder.setUsernameAndPassword(getMyJid().getLocalpart(), password);
		builder.setXmppDomain(getMyJid().asDomainBareJid());

		builder.setSecurityMode(ConnectionConfiguration.SecurityMode.required);

		SSLContext sc;
		try {
			sc = SSLContext.getInstance("TLS");
			sc.init(null, new X509TrustManager[] { mMemorizingTrustManager }, new java.security.SecureRandom());
		} catch (KeyManagementException | NoSuchAlgorithmException e) {
			throw new IllegalStateException(e);
		}
		builder.setCustomSSLContext(sc);

		confBuilderCache = builder;
	}
	return confBuilderCache;
}
 
开发者ID:Flowdalic,项目名称:android-xmpp-iot-demo,代码行数:26,代码来源:Settings.java

示例2: configKeyStore

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
private KeyStore configKeyStore(XMPPTCPConnectionConfiguration.Builder builder) throws KeyStoreException {
    KeyStore keyStore;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        builder.setKeystorePath(null);
        builder.setKeystoreType("AndroidCAStore");
        keyStore = KeyStore.getInstance("AndroidCAStore");
    } else {
        builder.setKeystoreType("BKS");
        keyStore = KeyStore.getInstance("BKS");

        String path = System.getProperty("javax.net.ssl.trustStore");
        if (path == null)
            path = System.getProperty("java.home") + File.separator + "etc"
                    + File.separator + "security" + File.separator
                    + "cacerts.bks";
        builder.setKeystorePath(path);
    }
    return keyStore;
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:21,代码来源:XMPPSession.java

示例3: connect

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
@Override
public void connect(XmppURI uri, String password) throws IOException, XMPPException, SmackException {
    this.disconnect();

    XMPPTCPConnectionConfiguration configuration = XMPPTCPConnectionConfiguration.builder()
            .setUsernameAndPassword(uri.getNode(), password)
            .setServiceName(uri.getDomain())
            .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
            .setDebuggerEnabled(true)
            .build();
    AbstractXMPPConnection connection = new XMPPTCPConnection(configuration);
    connection.connect();
    connection.login();
    // keep connection alive
    // when connection is idle it will run into timeout
    PingManager pingManager = PingManager.getInstanceFor(connection);
    pingManager.setPingInterval(60);
    pingManager.pingMyServer();

    this.connection = connection;
}
 
开发者ID:citlab,项目名称:Intercloud,代码行数:22,代码来源:XmppConnectionManager.java

示例4: newConnectionConfiguration

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
private XMPPTCPConnectionConfiguration newConnectionConfiguration(final BindingConfiguration configuration){
	XMPPTCPConnectionConfiguration.Builder configurationBuilder = XMPPTCPConnectionConfiguration.builder();
	configurationBuilder.setHost(configuration.getUrl())
			.setPort(configuration.getPort())
			.setServiceName(configuration.getServerName())
			.setUsernameAndPassword(configuration.getUsername(),configuration.getPassword())
			.setResource(configuration.getIdentifier())
			.setDebuggerEnabled(configuration.isDebug());

	if(allowSelfSigned){
		try {
			configurationBuilder.setCustomSSLContext(SSLHelper.newAllTrustingSslContext());
		} catch (KeyManagementException | NoSuchAlgorithmException e) {
			logger.error("Error registering custom ssl context",e);
		}
	}

	return configurationBuilder.build();
}
 
开发者ID:midoricorp,项目名称:jabbot,代码行数:20,代码来源:XmppBinding.java

示例5: connect

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

示例6: setUp

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    KeyStore keyStore = KeyStore.getInstance("JKS");
    keyStore.load(XMPPIntegrationTest.class.getResourceAsStream("/server.jks"), "secret".toCharArray());

    TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    trustManagerFactory.init(keyStore);

    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, trustManagerFactory.getTrustManagers(), new SecureRandom());

    String port = AvailablePortFinder.readServerData("xmpp-port");

    ConnectionConfiguration connectionConfig = XMPPTCPConnectionConfiguration.builder()
        .setXmppDomain(JidCreate.domainBareFrom("apache.camel"))
        .setHostAddress(InetAddress.getLocalHost())
        .setPort(Integer.parseInt(port))
        .setCustomSSLContext(sslContext)
        .setHostnameVerifier((hostname, session) -> true)
        .build();

    context.bind("customConnectionConfig", connectionConfig);
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:24,代码来源:XMPPIntegrationTest.java

示例7: initPrivateConnection

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
private void initPrivateConnection() {
    long currentUserId = CurrentUser.getInstance().getCurrentUserId();
    String currentUserPassword = CurrentUser.getInstance().getCurrentPassword();
    String userName = currentUserId + "-" + ApiConstants.APP_ID;
    XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
    configBuilder.setUsernameAndPassword(userName, currentUserPassword);
    configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
    configBuilder.setServiceName(ApiConstants.CHAT_END_POINT);
    configBuilder.setHost(ApiConstants.CHAT_END_POINT);
    configBuilder.setDebuggerEnabled(true);

    privateChatConnection = new XMPPTCPConnection(configBuilder.build());
    privateChatConnection.addConnectionListener(this);

    ReconnectionManager manager = ReconnectionManager.getInstanceFor(privateChatConnection);
    manager.enableAutomaticReconnection();
    manager.setReconnectionPolicy(ReconnectionManager.ReconnectionPolicy.FIXED_DELAY);
    manager.setFixedDelay(15);

    ProviderManager.addExtensionProvider(Displayed.ELEMENT, Displayed.NAMESPACE, new Displayed.Provider());
    DisplayedManager.getInstanceFor(privateChatConnection).addDisplayedListener(
            (fromJid, toJid, receiptId, receipt) -> {
                messageService.get().processDisplayed(fromJid, toJid, receiptId, receipt);
            });

    ProviderManager.addExtensionProvider(Received.ELEMENT, Received.NAMESPACE, new Received.Provider());
    ReceivedManager.getInstanceFor(privateChatConnection).addReceivedListener(
            (fromJid, toJid, receiptId, receipt) -> {
                messageService.get().processReceived(fromJid, toJid, receiptId, receipt);
            });
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:32,代码来源:QuickbloxPrivateXmppConnection.java

示例8: createManagedConnection

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
public XMPPTCPConnection createManagedConnection(XMPPTCPConnectionConfiguration configuration) {
	XMPPTCPConnection connection = new XMPPTCPConnection(configuration);
	ManagedXmppConnection managedConnection = new ManagedXmppConnection(connection);

	for (NewManagedConnectionListener newManagedConnectionListener : mNewConnectionListeners) {
		newManagedConnectionListener.newConnection(managedConnection);
	}

	synchronized (managedConnection) {
		mManagedConnections.put(connection, managedConnection);
	}

	return connection;
}
 
开发者ID:Flowdalic,项目名称:android-xmpp-iot-demo,代码行数:15,代码来源:AndroidSmackManager.java

示例9: configSSLContext

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
private void configSSLContext(XMPPTCPConnectionConfiguration.Builder builder, KeyStore keyStore) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
    TrustManagerFactory trustManagerFactory = TrustManagerFactory
            .getInstance(KeyManagerFactory.getDefaultAlgorithm());
    trustManagerFactory.init(keyStore);

    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, trustManagerFactory.getTrustManagers(), new SecureRandom());

    builder.setCustomSSLContext(sslContext);
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:11,代码来源:XMPPSession.java

示例10: buildConfiguration

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
private XMPPTCPConnectionConfiguration buildConfiguration() throws XmppStringprepException {
    XMPPTCPConnectionConfiguration.Builder builder =
            XMPPTCPConnectionConfiguration.builder();


    builder.setHost(HOST1);
    builder.setPort(PORT);
    builder.setCompressionEnabled(false);
    builder.setDebuggerEnabled(true);
    builder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
    builder.setSendPresence(true);
    if (Build.VERSION.SDK_INT >= 14) {
        builder.setKeystoreType("AndroidCAStore");
        // config.setTruststorePassword(null);
        builder.setKeystorePath(null);
    } else {
        builder.setKeystoreType("BKS");
        String str = System.getProperty("javax.net.ssl.trustStore");
        if (str == null) {
            str = System.getProperty("java.home") + File.separator + "etc" + File.separator + "security"
                    + File.separator + "cacerts.bks";
        }
        builder.setKeystorePath(str);
    }
    DomainBareJid serviceName = JidCreate.domainBareFrom(HOST);
    builder.setServiceName(serviceName);


    return builder.build();
}
 
开发者ID:saveendhiman,项目名称:XMPPSample_Studio,代码行数:31,代码来源:XMPP.java

示例11: getConnection

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
public static AbstractXMPPConnection getConnection() {

        if ( XMPPConnectionManager.isConfigured == false ) {
            Log.w(LOGTAG, "Instating unconfigured connection" );
            return null;
        }
        if ( XMPPConnectionManager.isConnected == false ) {

            // Send the configuration
            // TODO: Yes I know, this is restrictive, DNS must be working
            XMPPTCPConnectionConfiguration.Builder configBuilder =
                    XMPPTCPConnectionConfiguration.builder();
            configBuilder.setUsernameAndPassword(
                    XMPPConnectionManager.xmppUserName,
                    XMPPConnectionManager.xmppPassword);
            configBuilder.setServiceName( XMPPConnectionManager.xmppUserDomain  );
            configBuilder.setResource( "FlowsManager" );

            XMPPConnectionManager.connection = new XMPPTCPConnection(configBuilder.build());

            try {
                // Create a connection to the XMPP server.
                XMPPConnectionManager.connection.connect();
                // Log into the server
                XMPPConnectionManager.connection.login();
            } catch (Exception ex) {
                Log.w(LOGTAG, "XMPP Connection error " + ex);
                return null ;
            }
            XMPPConnectionManager.isConnected = true ;

        }

        return XMPPConnectionManager.connection ;

    }
 
开发者ID:marevalo,项目名称:FlowsManager,代码行数:37,代码来源:XMPPConnectionManager.java

示例12: createConnection

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
private void createConnection() {
    Logger.debug(TAG, "creating new connection to " + mAccount.getHost() + ":" + mAccount.getPort());

    XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder()
            .setServiceName(mAccount.getServiceName())
            .setResource(mAccount.getResourceName())
            .setHost(mAccount.getHost())
            .setPort(mAccount.getPort())
            .setUsernameAndPassword(mAccount.getXmppJid(), mAccount.getPassword())
            .setConnectTimeout(XmppService.CONNECT_TIMEOUT);

    if (XmppService.CUSTOM_SSL_CONTEXT != null) {
        Logger.debug(TAG, "setting custom SSL context");
        builder.setCustomSSLContext(XmppService.CUSTOM_SSL_CONTEXT);
    }

    if (XmppService.CUSTOM_HOSTNAME_VERIFIER != null) {
        Logger.debug(TAG, "setting custom hostname verifier");
        builder.setHostnameVerifier(XmppService.CUSTOM_HOSTNAME_VERIFIER);
    }

    mConnection = new XMPPTCPConnection(builder.build());
    mConnection.setUseStreamManagement(XmppService.USE_STREAM_MANAGEMENT);
    mConnection.setUseStreamManagementResumption(XmppService.USE_STREAM_MANAGEMENT);
    mConnection.setPreferredResumptionTime(XmppService.STREAM_MANAGEMENT_RESUMPTION_TIME);

    mConnection.addConnectionListener(this);
}
 
开发者ID:VoiSmart,项目名称:xmpp-service,代码行数:29,代码来源:XmppServiceConnection.java

示例13: setup

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
public void setup() {
	this.configBuilder = XMPPTCPConnectionConfiguration.builder();
	this.configBuilder.setUsernameAndPassword(XMPPConnectionHandler.username, XMPPConnectionHandler.password);
	this.configBuilder.setResource(XMPPConnectionHandler.resource);
	this.configBuilder.setServiceName(XMPPConnectionHandler.service);
	this.configBuilder.setHost(XMPPConnectionHandler.host);
	this.configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
	this.connection = new XMPPTCPConnection(this.configBuilder.build());
}
 
开发者ID:fatcat32594,项目名称:MineXMPP,代码行数:10,代码来源:XMPPConnectionHandler.java

示例14: XMPPTCPConnection

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
/**
 * Creates a new XMPP connection over TCP (optionally using proxies).
 * <p>
 * Note that XMPPTCPConnection constructors do not establish a connection to the server
 * and you must call {@link #connect()}.
 * </p>
 *
 * @param config the connection configuration.
 */
public XMPPTCPConnection(XMPPTCPConnectionConfiguration config) {
    super(config);
    this.config = config;
    addConnectionListener(new AbstractConnectionListener() {
        @Override
        public void connectionClosedOnError(Exception e) {
            if (e instanceof XMPPException.StreamErrorException || e instanceof StreamManagementException) {
                dropSmState();
            }
        }
    });
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:22,代码来源:XMPPTCPConnection.java

示例15: login

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入依赖的package包/类
private XMPPConnection login(final Configuration config) throws IOException, XMPPException, SmackException, KeyManagementException, NoSuchAlgorithmException {
    final String serviceName = isNullOrEmpty(config.getString(CK_SERVICE_NAME))
            ? config.getString(CK_HOSTNAME) : config.getString(CK_SERVICE_NAME);

    final XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder()
            .setHost(config.getString(CK_HOSTNAME))
            .setPort(config.getInt(CK_PORT))
            .setServiceName(serviceName)
            .setSendPresence(false);

    if (config.getBoolean(CK_ACCEPT_SELFSIGNED)) {
        TLSUtils.acceptAllCertificates(configBuilder);
    }

    final boolean requireSecurity = config.getBoolean(CK_REQUIRE_SECURITY);
    configBuilder.setSecurityMode(requireSecurity ?
            ConnectionConfiguration.SecurityMode.required : ConnectionConfiguration.SecurityMode.ifpossible);

    final XMPPTCPConnectionConfiguration connectionConfiguration = configBuilder.build();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Supported SASL authentications: {}", SASLAuthentication.getRegisterdSASLMechanisms());
        LOG.debug("require_security: {}", requireSecurity);
        LOG.debug("Security mode: {}", connectionConfiguration.getSecurityMode());
        LOG.debug("Socket factory: {}", connectionConfiguration.getSocketFactory());
        LOG.debug("Keystore: {}", connectionConfiguration.getKeystorePath());
        LOG.debug("Keystore type: {}", connectionConfiguration.getKeystoreType());
    }

    final XMPPTCPConnection xmppConnection = new XMPPTCPConnection(connectionConfiguration);

    xmppConnection.connect();
    xmppConnection.login(config.getString(CK_USERNAME), config.getString(CK_PASSWORD));

    return xmppConnection;
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-jabber,代码行数:36,代码来源:JabberAlarmCallback.java


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