Search in sources :

Example 11 with XMPPTCPConnectionConfiguration

use of org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration in project Smack by igniterealtime.

the class XmppTools method createAccount.

public static boolean createAccount(DomainBareJid xmppDomain, Localpart username, String password) throws KeyManagementException, NoSuchAlgorithmException, SmackException, IOException, XMPPException, InterruptedException {
    XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder().setXmppDomain(xmppDomain);
    TLSUtils.acceptAllCertificates(configBuilder);
    XMPPTCPConnectionConfiguration config = configBuilder.build();
    XMPPTCPConnection connection = new XMPPTCPConnection(config);
    connection.connect();
    try {
        if (!supportsIbr(connection))
            return false;
        AccountManager accountManager = AccountManager.getInstance(connection);
        accountManager.createAccount(username, password);
        return true;
    } finally {
        connection.disconnect();
    }
}
Also used : XMPPTCPConnection(org.jivesoftware.smack.tcp.XMPPTCPConnection) XMPPTCPConnectionConfiguration(org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration) AccountManager(org.jivesoftware.smackx.iqregister.AccountManager)

Example 12 with XMPPTCPConnectionConfiguration

use of org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration in project Smack by igniterealtime.

the class XmppTools method supportsIbr.

public static boolean supportsIbr(DomainBareJid xmppDomain) throws SmackException, IOException, XMPPException, InterruptedException, KeyManagementException, NoSuchAlgorithmException {
    XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder().setXmppDomain(xmppDomain);
    TLSUtils.acceptAllCertificates(configBuilder);
    XMPPTCPConnectionConfiguration config = configBuilder.build();
    XMPPTCPConnection connection = new XMPPTCPConnection(config);
    connection.connect();
    try {
        return supportsIbr(connection);
    } finally {
        connection.disconnect();
    }
}
Also used : XMPPTCPConnection(org.jivesoftware.smack.tcp.XMPPTCPConnection) XMPPTCPConnectionConfiguration(org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration)

Aggregations

XMPPTCPConnectionConfiguration (org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration)12 XMPPTCPConnection (org.jivesoftware.smack.tcp.XMPPTCPConnection)11 SmackException (org.jivesoftware.smack.SmackException)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 IOException (java.io.IOException)3 XMPPException (org.jivesoftware.smack.XMPPException)3 KeyManagementException (java.security.KeyManagementException)2 KeyStoreException (java.security.KeyStoreException)2 NoSuchProviderException (java.security.NoSuchProviderException)2 UnrecoverableKeyException (java.security.UnrecoverableKeyException)2 SSLContext (javax.net.ssl.SSLContext)2 SparkSSLContext (org.jivesoftware.sparkimpl.certificates.SparkSSLContext)2 SparkSSLSocketFactory (org.jivesoftware.sparkimpl.certificates.SparkSSLSocketFactory)2 XmppStringprepException (org.jxmpp.stringprep.XmppStringprepException)2 Config (com.sun.enterprise.config.serverbeans.Config)1 MessageAcknowledgementEvent (com.yellowmessenger.sdk.events.MessageAcknowledgementEvent)1 XMPPUser (com.yellowmessenger.sdk.models.XMPPUser)1 ChatMessage (com.yellowmessenger.sdk.models.db.ChatMessage)1 CustomSCRAMSHA1Mechanism (com.yellowmessenger.sdk.xmpp.CustomSCRAMSHA1Mechanism)1 BlockingQueueHandler (fish.payara.nucleus.notification.BlockingQueueHandler)1