mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +01:00
Rename ConnectionConfigurationBuilder to Builder
This commit is contained in:
parent
31c53f094c
commit
a87227c531
8 changed files with 38 additions and 41 deletions
|
@ -35,7 +35,7 @@ public class BOSHConfiguration extends ConnectionConfiguration {
|
||||||
private final boolean https;
|
private final boolean https;
|
||||||
private final String file;
|
private final String file;
|
||||||
|
|
||||||
private BOSHConfiguration(BOSHConfigurationBuilder builder) {
|
private BOSHConfiguration(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
https = builder.https;
|
https = builder.https;
|
||||||
if (builder.file.charAt(0) != '/') {
|
if (builder.file.charAt(0) != '/') {
|
||||||
|
@ -69,27 +69,27 @@ public class BOSHConfiguration extends ConnectionConfiguration {
|
||||||
return new URI((https ? "https://" : "http://") + this.host + ":" + this.port + file);
|
return new URI((https ? "https://" : "http://") + this.host + ":" + this.port + file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BOSHConfigurationBuilder builder() {
|
public static Builder builder() {
|
||||||
return new BOSHConfigurationBuilder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BOSHConfigurationBuilder extends ConnectionConfigurationBuilder<BOSHConfigurationBuilder, BOSHConfiguration> {
|
public static class Builder extends ConnectionConfiguration.Builder<Builder, BOSHConfiguration> {
|
||||||
private boolean https;
|
private boolean https;
|
||||||
private String file;
|
private String file;
|
||||||
|
|
||||||
private BOSHConfigurationBuilder() {
|
private Builder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BOSHConfigurationBuilder setUseHttps(boolean useHttps) {
|
public Builder setUseHttps(boolean useHttps) {
|
||||||
https = useHttps;
|
https = useHttps;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BOSHConfigurationBuilder useHttps() {
|
public Builder useHttps() {
|
||||||
return setUseHttps(true);
|
return setUseHttps(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BOSHConfigurationBuilder setFile(String file) {
|
public Builder setFile(String file) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ public class BOSHConfiguration extends ConnectionConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BOSHConfigurationBuilder getThis() {
|
protected Builder getThis() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.ConnectionConfiguration.ConnectionConfigurationBuilder;
|
|
||||||
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
|
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
|
||||||
import org.jivesoftware.smack.SmackException.AlreadyConnectedException;
|
import org.jivesoftware.smack.SmackException.AlreadyConnectedException;
|
||||||
import org.jivesoftware.smack.SmackException.AlreadyLoggedInException;
|
import org.jivesoftware.smack.SmackException.AlreadyLoggedInException;
|
||||||
|
@ -348,12 +347,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
* Before logging in (i.e. authenticate) to the server the connection must be connected.
|
* Before logging in (i.e. authenticate) to the server the connection must be connected.
|
||||||
*
|
*
|
||||||
* It is possible to log in without sending an initial available presence by using
|
* It is possible to log in without sending an initial available presence by using
|
||||||
* {@link ConnectionConfigurationBuilder#setSendPresence(boolean)}. If this connection is
|
* {@link ConnectionConfiguration.Builder#setSendPresence(boolean)}. If this connection is
|
||||||
* not interested in loading its roster upon login then use
|
* not interested in loading its roster upon login then use
|
||||||
* {@link ConnectionConfigurationBuilder#setRosterLoadedAtLogin(boolean)}.
|
* {@link ConnectionConfiguration.Builder#setRosterLoadedAtLogin(boolean)}.
|
||||||
* Finally, if you want to not pass a password and instead use a more advanced mechanism
|
* Finally, if you want to not pass a password and instead use a more advanced mechanism
|
||||||
* while using SASL then you may be interested in using
|
* while using SASL then you may be interested in using
|
||||||
* {@link ConnectionConfigurationBuilder#setCallbackHandler(javax.security.auth.callback.CallbackHandler)}.
|
* {@link ConnectionConfiguration.Builder#setCallbackHandler(javax.security.auth.callback.CallbackHandler)}.
|
||||||
* For more advanced login settings see {@link ConnectionConfiguration}.
|
* For more advanced login settings see {@link ConnectionConfiguration}.
|
||||||
*
|
*
|
||||||
* @throws XMPPException if an error occurs on the XMPP protocol level.
|
* @throws XMPPException if an error occurs on the XMPP protocol level.
|
||||||
|
|
|
@ -93,7 +93,7 @@ public abstract class ConnectionConfiguration {
|
||||||
// Holds the proxy information (such as proxyhost, proxyport, username, password etc)
|
// Holds the proxy information (such as proxyhost, proxyport, username, password etc)
|
||||||
protected final ProxyInfo proxy;
|
protected final ProxyInfo proxy;
|
||||||
|
|
||||||
protected ConnectionConfiguration(ConnectionConfigurationBuilder<?,?> builder) {
|
protected ConnectionConfiguration(Builder<?,?> builder) {
|
||||||
if (builder.username != null) {
|
if (builder.username != null) {
|
||||||
// Do partial version of nameprep on the username.
|
// Do partial version of nameprep on the username.
|
||||||
username = builder.username.toLowerCase(Locale.US).trim();
|
username = builder.username.toLowerCase(Locale.US).trim();
|
||||||
|
@ -196,7 +196,7 @@ public abstract class ConnectionConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the custom SSLContext previously set with {@link ConnectionConfigurationBuilder#setCustomSSLContext(SSLContext)} for
|
* Gets the custom SSLContext previously set with {@link ConnectionConfiguration.Builder#setCustomSSLContext(SSLContext)} for
|
||||||
* SSL sockets. This is null by default.
|
* SSL sockets. This is null by default.
|
||||||
*
|
*
|
||||||
* @return the custom SSLContext or null.
|
* @return the custom SSLContext or null.
|
||||||
|
@ -390,7 +390,7 @@ public abstract class ConnectionConfiguration {
|
||||||
* @param <B> the builder type parameter.
|
* @param <B> the builder type parameter.
|
||||||
* @param <C> the resulting connection configuration type parameter.
|
* @param <C> the resulting connection configuration type parameter.
|
||||||
*/
|
*/
|
||||||
public static abstract class ConnectionConfigurationBuilder<B extends ConnectionConfigurationBuilder<B, C>, C extends ConnectionConfiguration> {
|
public static abstract class Builder<B extends Builder<B, C>, C extends ConnectionConfiguration> {
|
||||||
private SecurityMode securityMode = SecurityMode.enabled;
|
private SecurityMode securityMode = SecurityMode.enabled;
|
||||||
private String keystorePath = System.getProperty("javax.net.ssl.keyStore");
|
private String keystorePath = System.getProperty("javax.net.ssl.keyStore");
|
||||||
private String keystoreType = "jks";
|
private String keystoreType = "jks";
|
||||||
|
@ -415,7 +415,7 @@ public abstract class ConnectionConfiguration {
|
||||||
private String host;
|
private String host;
|
||||||
private int port = 5222;
|
private int port = 5222;
|
||||||
|
|
||||||
protected ConnectionConfigurationBuilder() {
|
protected Builder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,7 +28,6 @@ import java.util.Set;
|
||||||
|
|
||||||
import javax.net.ssl.HostnameVerifier;
|
import javax.net.ssl.HostnameVerifier;
|
||||||
|
|
||||||
import org.jivesoftware.smack.ConnectionConfiguration.ConnectionConfigurationBuilder;
|
|
||||||
import org.jivesoftware.smack.compression.XMPPInputOutputStream;
|
import org.jivesoftware.smack.compression.XMPPInputOutputStream;
|
||||||
import org.jivesoftware.smack.debugger.ReflectionDebuggerFactory;
|
import org.jivesoftware.smack.debugger.ReflectionDebuggerFactory;
|
||||||
import org.jivesoftware.smack.debugger.SmackDebugger;
|
import org.jivesoftware.smack.debugger.SmackDebugger;
|
||||||
|
@ -268,7 +267,7 @@ public final class SmackConfiguration {
|
||||||
* Set the default HostnameVerifier that will be used by XMPP connections to verify the hostname
|
* Set the default HostnameVerifier that will be used by XMPP connections to verify the hostname
|
||||||
* of a TLS certificate. XMPP connections are able to overwrite this settings by supplying a
|
* of a TLS certificate. XMPP connections are able to overwrite this settings by supplying a
|
||||||
* HostnameVerifier in their ConnecitonConfiguration with
|
* HostnameVerifier in their ConnecitonConfiguration with
|
||||||
* {@link ConnectionConfigurationBuilder#setHostnameVerifier(HostnameVerifier)}.
|
* {@link ConnectionConfiguration.Builder#setHostnameVerifier(HostnameVerifier)}.
|
||||||
*/
|
*/
|
||||||
public static void setDefaultHostnameVerifier(HostnameVerifier verifier) {
|
public static void setDefaultHostnameVerifier(HostnameVerifier verifier) {
|
||||||
defaultHostnameVerififer = verifier;
|
defaultHostnameVerififer = verifier;
|
||||||
|
|
|
@ -30,7 +30,7 @@ import javax.net.ssl.SSLSocket;
|
||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
import org.jivesoftware.smack.ConnectionConfiguration.ConnectionConfigurationBuilder;
|
import org.jivesoftware.smack.ConnectionConfiguration;
|
||||||
import org.jivesoftware.smack.SmackException.SecurityNotPossibleException;
|
import org.jivesoftware.smack.SmackException.SecurityNotPossibleException;
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class TLSUtils {
|
||||||
*
|
*
|
||||||
* @param builder the configuration builder to apply this setting to
|
* @param builder the configuration builder to apply this setting to
|
||||||
*/
|
*/
|
||||||
public static <B extends ConnectionConfigurationBuilder<B,?>> B setTLSOnly(B builder) {
|
public static <B extends ConnectionConfiguration.Builder<B,?>> B setTLSOnly(B builder) {
|
||||||
builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1 });
|
builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1 });
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class TLSUtils {
|
||||||
*
|
*
|
||||||
* @param builder the configuration builder to apply this setting to
|
* @param builder the configuration builder to apply this setting to
|
||||||
*/
|
*/
|
||||||
public static <B extends ConnectionConfigurationBuilder<B,?>> B setSSLv3AndTLSOnly(B builder) {
|
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 });
|
builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1, PROTO_SSL3 });
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public class TLSUtils {
|
||||||
* @throws NoSuchAlgorithmException
|
* @throws NoSuchAlgorithmException
|
||||||
* @throws KeyManagementException
|
* @throws KeyManagementException
|
||||||
*/
|
*/
|
||||||
public static <B extends ConnectionConfigurationBuilder<B,?>> B acceptAllCertificates(B builder) throws NoSuchAlgorithmException, KeyManagementException {
|
public static <B extends ConnectionConfiguration.Builder<B,?>> B acceptAllCertificates(B builder) throws NoSuchAlgorithmException, KeyManagementException {
|
||||||
SSLContext context = SSLContext.getInstance(TLS);
|
SSLContext context = SSLContext.getInstance(TLS);
|
||||||
context.init(null, new TrustManager[] { new AcceptAllTrustManager() }, new SecureRandom());
|
context.init(null, new TrustManager[] { new AcceptAllTrustManager() }, new SecureRandom());
|
||||||
builder.setCustomSSLContext(context);
|
builder.setCustomSSLContext(context);
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jivesoftware.smack.ConnectionConfiguration.ConnectionConfigurationBuilder;
|
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.packet.PlainStreamElement;
|
import org.jivesoftware.smack.packet.PlainStreamElement;
|
||||||
import org.jivesoftware.smack.packet.TopLevelStreamElement;
|
import org.jivesoftware.smack.packet.TopLevelStreamElement;
|
||||||
|
@ -54,7 +53,7 @@ public class DummyConnection extends AbstractXMPPConnection {
|
||||||
|
|
||||||
private final BlockingQueue<TopLevelStreamElement> queue = new LinkedBlockingQueue<TopLevelStreamElement>();
|
private final BlockingQueue<TopLevelStreamElement> queue = new LinkedBlockingQueue<TopLevelStreamElement>();
|
||||||
|
|
||||||
public static ConnectionConfigurationBuilder<?,?> getDummyConfigurationBuilder() {
|
public static ConnectionConfiguration.Builder<?,?> getDummyConfigurationBuilder() {
|
||||||
return DummyConnectionConfiguration.builder().setServiceName("example.org").setUsernameAndPassword("dummy",
|
return DummyConnectionConfiguration.builder().setServiceName("example.org").setUsernameAndPassword("dummy",
|
||||||
"dummypass");
|
"dummypass");
|
||||||
}
|
}
|
||||||
|
@ -232,19 +231,19 @@ public class DummyConnection extends AbstractXMPPConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DummyConnectionConfiguration extends ConnectionConfiguration {
|
public static class DummyConnectionConfiguration extends ConnectionConfiguration {
|
||||||
protected DummyConnectionConfiguration(DummyConnectionConfigurationBuilder builder) {
|
protected DummyConnectionConfiguration(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DummyConnectionConfigurationBuilder builder() {
|
public static Builder builder() {
|
||||||
return new DummyConnectionConfigurationBuilder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DummyConnectionConfigurationBuilder
|
public static class Builder
|
||||||
extends
|
extends
|
||||||
ConnectionConfigurationBuilder<DummyConnectionConfigurationBuilder, DummyConnectionConfiguration> {
|
ConnectionConfiguration.Builder<Builder, DummyConnectionConfiguration> {
|
||||||
|
|
||||||
private DummyConnectionConfigurationBuilder() {
|
private Builder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -253,7 +252,7 @@ public class DummyConnection extends AbstractXMPPConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DummyConnectionConfigurationBuilder getThis() {
|
protected Builder getThis() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import org.jivesoftware.smack.ConnectionConfiguration.ConnectionConfigurationBuilder;
|
import org.jivesoftware.smack.ConnectionConfiguration.Builder;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.IQ.Type;
|
import org.jivesoftware.smack.packet.IQ.Type;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
|
@ -65,7 +65,7 @@ public class RosterVersioningTest {
|
||||||
DirectoryRosterStore store = DirectoryRosterStore.init(tmpFolder.newFolder("store"));
|
DirectoryRosterStore store = DirectoryRosterStore.init(tmpFolder.newFolder("store"));
|
||||||
populateStore(store);
|
populateStore(store);
|
||||||
|
|
||||||
ConnectionConfigurationBuilder<?, ?> builder = DummyConnection.getDummyConfigurationBuilder();
|
Builder<?, ?> builder = DummyConnection.getDummyConfigurationBuilder();
|
||||||
builder.setRosterStore(store);
|
builder.setRosterStore(store);
|
||||||
connection = new DummyConnection(builder.build());
|
connection = new DummyConnection(builder.build());
|
||||||
connection.connect();
|
connection.connect();
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class XMPPTCPConnectionConfiguration extends ConnectionConfiguration {
|
||||||
|
|
||||||
private final boolean compressionEnabled;
|
private final boolean compressionEnabled;
|
||||||
|
|
||||||
private XMPPTCPConnectionConfiguration(XMPPTCPConnectionConfigurationBuilder builder) {
|
private XMPPTCPConnectionConfiguration(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
compressionEnabled = builder.compressionEnabled;
|
compressionEnabled = builder.compressionEnabled;
|
||||||
}
|
}
|
||||||
|
@ -40,14 +40,14 @@ public class XMPPTCPConnectionConfiguration extends ConnectionConfiguration {
|
||||||
return compressionEnabled;
|
return compressionEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XMPPTCPConnectionConfigurationBuilder builder() {
|
public static Builder builder() {
|
||||||
return new XMPPTCPConnectionConfigurationBuilder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class XMPPTCPConnectionConfigurationBuilder extends ConnectionConfigurationBuilder<XMPPTCPConnectionConfigurationBuilder, XMPPTCPConnectionConfiguration> {
|
public static class Builder extends ConnectionConfiguration.Builder<Builder, XMPPTCPConnectionConfiguration> {
|
||||||
private boolean compressionEnabled = false;
|
private boolean compressionEnabled = false;
|
||||||
|
|
||||||
private XMPPTCPConnectionConfigurationBuilder() {
|
private Builder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,13 +58,13 @@ public class XMPPTCPConnectionConfiguration extends ConnectionConfiguration {
|
||||||
*
|
*
|
||||||
* @param compressionEnabled if the connection is going to use stream compression.
|
* @param compressionEnabled if the connection is going to use stream compression.
|
||||||
*/
|
*/
|
||||||
public XMPPTCPConnectionConfigurationBuilder setCompressionEnabled(boolean compressionEnabled) {
|
public Builder setCompressionEnabled(boolean compressionEnabled) {
|
||||||
this.compressionEnabled = compressionEnabled;
|
this.compressionEnabled = compressionEnabled;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected XMPPTCPConnectionConfigurationBuilder getThis() {
|
protected Builder getThis() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue