Java Code Examples for org.jivesoftware.smack.ConnectionConfiguration#Builder
The following examples show how to use
org.jivesoftware.smack.ConnectionConfiguration#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmppConnectionManager.java From Smack with Apache License 2.0 | 5 votes |
public static boolean addConnectionDescriptor( XmppConnectionDescriptor<? extends AbstractXMPPConnection, ? extends ConnectionConfiguration, ? extends ConnectionConfiguration.Builder<?, ?>> connectionDescriptor) { String nickname = connectionDescriptor.getNickname(); Class<? extends AbstractXMPPConnection> connectionClass = connectionDescriptor.getConnectionClass(); boolean alreadyExisted; synchronized (CONNECTION_DESCRIPTORS) { alreadyExisted = removeConnectionDescriptor(nickname); CONNECTION_DESCRIPTORS.put(connectionClass, connectionDescriptor); NICKNAME_CONNECTION_DESCRIPTORS.put(connectionDescriptor.getNickname(), connectionDescriptor); } return alreadyExisted; }
Example 2
Source File: XmppConnectionManager.java From Smack with Apache License 2.0 | 5 votes |
private <C extends AbstractXMPPConnection> C constructConnectedConnection( XmppConnectionDescriptor<C, ? extends ConnectionConfiguration, ? extends ConnectionConfiguration.Builder<?, ?>> connectionDescriptor) throws InterruptedException, SmackException, IOException, XMPPException { C connection = constructConnection(connectionDescriptor, null); connection.connect(); connection.login(); return connection; }
Example 3
Source File: XmppConnectionManager.java From Smack with Apache License 2.0 | 5 votes |
private <C extends AbstractXMPPConnection> C constructConnection( XmppConnectionDescriptor<C, ? extends ConnectionConfiguration, ? extends ConnectionConfiguration.Builder<?, ?>> connectionDescriptor, Collection<ConnectionConfigurationBuilderApplier> customConnectionConfigurationAppliers) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { String username = "sinttest-" + testRunId + '-' + (connections.size() + 1); String password = StringUtils.randomString(24); return constructConnection(username, password, connectionDescriptor, customConnectionConfigurationAppliers); }
Example 4
Source File: XmppConnectionDescriptor.java From Smack with Apache License 2.0 | 4 votes |
public static <C extends AbstractXMPPConnection, CC extends ConnectionConfiguration, CCB extends ConnectionConfiguration.Builder<?, CC>> Builder<C, CC, CCB> buildWith(Class<C> connectionClass, Class<CC> connectionConfigurationClass) { return buildWith(connectionClass, connectionConfigurationClass, null); }
Example 5
Source File: XmppConnectionDescriptor.java From Smack with Apache License 2.0 | 4 votes |
public static <C extends AbstractXMPPConnection, CC extends ConnectionConfiguration, CCB extends ConnectionConfiguration.Builder<?, CC>> Builder<C, CC, CCB> buildWith(Class<C> connectionClass, Class<CC> connectionConfigurationClass, Class<CCB> connectionConfigurationBuilderClass) { return new Builder<>(connectionClass, connectionConfigurationClass, connectionConfigurationBuilderClass); }
Example 6
Source File: XmppConnectionManager.java From Smack with Apache License 2.0 | 4 votes |
public XmppConnectionDescriptor<? extends AbstractXMPPConnection, ? extends ConnectionConfiguration, ? extends ConnectionConfiguration.Builder<?, ?>> getDefaultConnectionDescriptor() { return defaultConnectionDescriptor; }
Example 7
Source File: XmppConnectionManager.java From Smack with Apache License 2.0 | 4 votes |
public Collection<XmppConnectionDescriptor<? extends AbstractXMPPConnection, ? extends ConnectionConfiguration, ? extends ConnectionConfiguration.Builder<?, ?>>> getConnectionDescriptors() { return Collections.unmodifiableCollection(nicknameConnectionDescriptors.values()); }
Example 8
Source File: XmppConnectionManager.java From Smack with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public <C extends AbstractXMPPConnection> XmppConnectionDescriptor<C, ? extends ConnectionConfiguration, ? extends ConnectionConfiguration.Builder<?, ?>> getConnectionDescriptorFor( Class<C> connectionClass) { return (XmppConnectionDescriptor<C, ? extends ConnectionConfiguration, ? extends ConnectionConfiguration.Builder<?, ?>>) connectionDescriptors.getFirst( connectionClass); }
Example 9
Source File: XmppConnectionManager.java From Smack with Apache License 2.0 | 4 votes |
<C extends AbstractXMPPConnection> C constructConnection( XmppConnectionDescriptor<C, ? extends ConnectionConfiguration, ? extends ConnectionConfiguration.Builder<?, ?>> connectionDescriptor) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return constructConnection(connectionDescriptor, null); }
Example 10
Source File: TLSUtils.java From Smack with Apache License 2.0 | 3 votes |
/** * Enable only TLS. Connections created with the given ConnectionConfiguration will only support TLS. * <p> * According to the <a * href="https://raw.githubusercontent.com/stpeter/manifesto/master/manifesto.txt">Encrypted * XMPP Manifesto</a>, TLSv1.2 shall be deployed, providing fallback support for SSLv3 and * TLSv1.1. This method goes one step beyond and upgrades the handshake to use TLSv1 or better. * This method requires the underlying OS to support all of TLSv1.2 , 1.1 and 1.0. * </p> * * @param builder the configuration builder to apply this setting to * @param <B> Type of the ConnectionConfiguration builder. * * @return the given builder * @deprecated use {@link #setEnabledTlsProtocolsToRecommended(org.jivesoftware.smack.ConnectionConfiguration.Builder)} instead. */ // TODO: Remove in Smack 4.5. @Deprecated public static <B extends ConnectionConfiguration.Builder<B, ?>> B setTLSOnly(B builder) { builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1 }); return builder; }
Example 11
Source File: TLSUtils.java From Smack with Apache License 2.0 | 3 votes |
/** * Enable only TLS and SSLv3. Connections created with the given ConnectionConfiguration will * only support TLS and SSLv3. * <p> * According to the <a * href="https://raw.githubusercontent.com/stpeter/manifesto/master/manifesto.txt">Encrypted * XMPP Manifesto</a>, TLSv1.2 shall be deployed, providing fallback support for SSLv3 and * TLSv1.1. * </p> * * @param builder the configuration builder to apply this setting to * @param <B> Type of the ConnectionConfiguration builder. * * @return the given builder * @deprecated use {@link #setEnabledTlsProtocolsToRecommended(org.jivesoftware.smack.ConnectionConfiguration.Builder)} instead. */ // TODO: Remove in Smack 4.5. @Deprecated public static <B extends ConnectionConfiguration.Builder<B, ?>> B setSSLv3AndTLSOnly(B builder) { builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1, PROTO_SSL3 }); return builder; }
Example 12
Source File: TLSUtils.java From Smack with Apache License 2.0 | 3 votes |
/** * Disable the hostname verification of TLS certificates. * <p> * <b>Warning:</b> Use with care. This disables hostname verification of TLS certificates and essentially * <b>invalidates all security guarantees provided by TLS</b>. Only use this method if you understand the * implications. * </p> * * @param builder a connection configuration builder. * @param <B> Type of the ConnectionConfiguration builder. * @return the given builder. */ public static <B extends ConnectionConfiguration.Builder<B, ?>> B disableHostnameVerificationForTlsCertificates(B builder) { builder.setHostnameVerifier((hostname, session) -> { return true; }); return builder; }
Example 13
Source File: TLSUtils.java From Smack with Apache License 2.0 | 2 votes |
/** * Enable the recommended TLS protocols. * * @param builder the configuration builder to apply this setting to * @param <B> Type of the ConnectionConfiguration builder. * * @return the given builder */ public static <B extends ConnectionConfiguration.Builder<B, ?>> B setEnabledTlsProtocolsToRecommended(B builder) { builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_3, PROTO_TLSV1_2 }); return builder; }
Example 14
Source File: TLSUtils.java From Smack with Apache License 2.0 | 2 votes |
/** * Accept all TLS certificates. * <p> * <b>Warning:</b> Use with care. This method make the Connection use {@link AcceptAllTrustManager} and essentially * <b>invalidates all security guarantees provided by TLS</b>. Only use this method if you understand the * implications. * </p> * * @param builder a connection configuration builder. * @param <B> Type of the ConnectionConfiguration builder. * @return the given builder. */ public static <B extends ConnectionConfiguration.Builder<B, ?>> B acceptAllCertificates(B builder) { builder.setCustomX509TrustManager(new AcceptAllTrustManager()); return builder; }
Example 15
Source File: ConnectionConfigurationBuilderApplier.java From Smack with Apache License 2.0 | votes |
void applyConfigurationTo(ConnectionConfiguration.Builder<?, ?> connectionConfigurationBuilder);