Skip to content

Commit

Permalink
Client tcp/ssl option renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Feb 4, 2015
1 parent 0e063cb commit 618f744
Show file tree
Hide file tree
Showing 23 changed files with 231 additions and 246 deletions.
12 changes: 6 additions & 6 deletions src/main/asciidoc/net.adoc
Expand Up @@ -490,7 +490,7 @@ extension can also be loaded in a similar fashion than JKS trust stores:
NetServerOptions options = new NetServerOptions(). NetServerOptions options = new NetServerOptions().
setSsl(true). setSsl(true).
setClientAuthRequired(true). setClientAuthRequired(true).
setPfxCaOptions( setPfxTrustOptions(
new PfxOptions(). new PfxOptions().
setPath("/path/to/your/truststore.pfx"). setPath("/path/to/your/truststore.pfx").
setPassword("password-of-your-truststore") setPassword("password-of-your-truststore")
Expand All @@ -506,7 +506,7 @@ Buffer myTrustStoreAsABuffer = vertx.fileSystem().readFileBlocking("/path/to/you
NetServerOptions options = new NetServerOptions(). NetServerOptions options = new NetServerOptions().
setSsl(true). setSsl(true).
setClientAuthRequired(true). setClientAuthRequired(true).
setPfxCaOptions( setPfxTrustOptions(
new PfxOptions(). new PfxOptions().
setValue(myTrustStoreAsABuffer). setValue(myTrustStoreAsABuffer).
setPassword("password-of-your-truststore") setPassword("password-of-your-truststore")
Expand All @@ -521,8 +521,8 @@ Another way of providing server certificate authority using a list `.pem` files.
NetServerOptions options = new NetServerOptions(). NetServerOptions options = new NetServerOptions().
setSsl(true). setSsl(true).
setClientAuthRequired(true). setClientAuthRequired(true).
setPemCaOptions( setPemTrustOptions(
new PemCaOptions(). new PemTrustOptions().
addCertPath("/path/to/your/server-ca.pem") addCertPath("/path/to/your/server-ca.pem")
); );
NetServer server = vertx.createNetServer(options); NetServer server = vertx.createNetServer(options);
Expand All @@ -536,8 +536,8 @@ Buffer myCaAsABuffer = vertx.fileSystem().readFileBlocking("/path/to/your/server
NetServerOptions options = new NetServerOptions(). NetServerOptions options = new NetServerOptions().
setSsl(true). setSsl(true).
setClientAuthRequired(true). setClientAuthRequired(true).
setPemCaOptions( setPemTrustOptions(
new PemCaOptions(). new PemTrustOptions().
addCertValue(myCaAsABuffer) addCertValue(myCaAsABuffer)
); );
NetServer server = vertx.createNetServer(options); NetServer server = vertx.createNetServer(options);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/examples/NetExamples.java
Expand Up @@ -279,7 +279,7 @@ public void example25(Vertx vertx) {
NetServerOptions options = new NetServerOptions(). NetServerOptions options = new NetServerOptions().
setSsl(true). setSsl(true).
setClientAuthRequired(true). setClientAuthRequired(true).
setPfxCaOptions( setPfxTrustOptions(
new PfxOptions(). new PfxOptions().
setPath("/path/to/your/truststore.pfx"). setPath("/path/to/your/truststore.pfx").
setPassword("password-of-your-truststore") setPassword("password-of-your-truststore")
Expand All @@ -292,7 +292,7 @@ public void example26(Vertx vertx) {
NetServerOptions options = new NetServerOptions(). NetServerOptions options = new NetServerOptions().
setSsl(true). setSsl(true).
setClientAuthRequired(true). setClientAuthRequired(true).
setPfxCaOptions( setPfxTrustOptions(
new PfxOptions(). new PfxOptions().
setValue(myTrustStoreAsABuffer). setValue(myTrustStoreAsABuffer).
setPassword("password-of-your-truststore") setPassword("password-of-your-truststore")
Expand All @@ -304,8 +304,8 @@ public void example27(Vertx vertx) {
NetServerOptions options = new NetServerOptions(). NetServerOptions options = new NetServerOptions().
setSsl(true). setSsl(true).
setClientAuthRequired(true). setClientAuthRequired(true).
setPemCaOptions( setPemTrustOptions(
new PemCaOptions(). new PemTrustOptions().
addCertPath("/path/to/your/server-ca.pem") addCertPath("/path/to/your/server-ca.pem")
); );
NetServer server = vertx.createNetServer(options); NetServer server = vertx.createNetServer(options);
Expand All @@ -316,8 +316,8 @@ public void example28(Vertx vertx) {
NetServerOptions options = new NetServerOptions(). NetServerOptions options = new NetServerOptions().
setSsl(true). setSsl(true).
setClientAuthRequired(true). setClientAuthRequired(true).
setPemCaOptions( setPemTrustOptions(
new PemCaOptions(). new PemTrustOptions().
addCertValue(myCaAsABuffer) addCertValue(myCaAsABuffer)
); );
NetServer server = vertx.createNetServer(options); NetServer server = vertx.createNetServer(options);
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/io/vertx/core/http/HttpClientOptions.java
Expand Up @@ -20,11 +20,9 @@
import io.vertx.core.json.JsonObject; import io.vertx.core.json.JsonObject;
import io.vertx.core.net.ClientOptionsBase; import io.vertx.core.net.ClientOptionsBase;
import io.vertx.core.net.JksOptions; import io.vertx.core.net.JksOptions;
import io.vertx.core.net.PemCaOptions; import io.vertx.core.net.PemTrustOptions;
import io.vertx.core.net.PemKeyCertOptions; import io.vertx.core.net.PemKeyCertOptions;
import io.vertx.core.net.PfxOptions; import io.vertx.core.net.PfxOptions;
import io.vertx.core.net.CaOptions;
import io.vertx.core.net.TCPSSLOptions;


/** /**
* Options describing how an {@link HttpClient} will make connections. * Options describing how an {@link HttpClient} will make connections.
Expand Down Expand Up @@ -215,13 +213,13 @@ public HttpClientOptions setTrustStoreOptions(JksOptions options) {
} }


@Override @Override
public HttpClientOptions setPfxCaOptions(PfxOptions options) { public HttpClientOptions setPfxTrustOptions(PfxOptions options) {
return (HttpClientOptions) super.setPfxCaOptions(options); return (HttpClientOptions) super.setPfxTrustOptions(options);
} }


@Override @Override
public HttpClientOptions setPemCaOptions(PemCaOptions options) { public HttpClientOptions setPemTrustOptions(PemTrustOptions options) {
return (HttpClientOptions) super.setPemCaOptions(options); return (HttpClientOptions) super.setPemTrustOptions(options);
} }


@Override @Override
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/io/vertx/core/http/HttpServerOptions.java
Expand Up @@ -19,11 +19,10 @@
import io.vertx.codegen.annotations.DataObject; import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject; import io.vertx.core.json.JsonObject;
import io.vertx.core.net.JksOptions; import io.vertx.core.net.JksOptions;
import io.vertx.core.net.PemCaOptions; import io.vertx.core.net.PemTrustOptions;
import io.vertx.core.net.PemKeyCertOptions; import io.vertx.core.net.PemKeyCertOptions;
import io.vertx.core.net.NetServerOptions; import io.vertx.core.net.NetServerOptions;
import io.vertx.core.net.PfxOptions; import io.vertx.core.net.PfxOptions;
import io.vertx.core.net.CaOptions;


/** /**
* Represents options used by an {@link io.vertx.core.http.HttpServer} instance * Represents options used by an {@link io.vertx.core.http.HttpServer} instance
Expand Down Expand Up @@ -170,13 +169,13 @@ public HttpServerOptions setTrustStoreOptions(JksOptions options) {
} }


@Override @Override
public HttpServerOptions setPemCaOptions(PemCaOptions options) { public HttpServerOptions setPemTrustOptions(PemTrustOptions options) {
return (HttpServerOptions) super.setPemCaOptions(options); return (HttpServerOptions) super.setPemTrustOptions(options);
} }


@Override @Override
public HttpServerOptions setPfxCaOptions(PfxOptions options) { public HttpServerOptions setPfxTrustOptions(PfxOptions options) {
return (HttpServerOptions) super.setPfxCaOptions(options); return (HttpServerOptions) super.setPfxTrustOptions(options);
} }


@Override @Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/vertx/core/http/impl/HttpClientImpl.java
Expand Up @@ -91,7 +91,7 @@ public class HttpClientImpl implements HttpClient {
public HttpClientImpl(VertxInternal vertx, HttpClientOptions options) { public HttpClientImpl(VertxInternal vertx, HttpClientOptions options) {
this.vertx = vertx; this.vertx = vertx;
this.options = new HttpClientOptions(options); this.options = new HttpClientOptions(options);
this.sslHelper = new SSLHelper(options, KeyStoreHelper.create(vertx, options.getKeyCertOptions()), KeyStoreHelper.create(vertx, options.getCaOptions())); this.sslHelper = new SSLHelper(options, KeyStoreHelper.create(vertx, options.getKeyCertOptions()), KeyStoreHelper.create(vertx, options.getTrustOptions()));
this.creatingContext = vertx.getContext(); this.creatingContext = vertx.getContext();
closeHook = completionHandler -> { closeHook = completionHandler -> {
HttpClientImpl.this.close(); HttpClientImpl.this.close();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/vertx/core/http/impl/HttpServerImpl.java
Expand Up @@ -131,7 +131,7 @@ public HttpServerImpl(VertxInternal vertx, HttpServerOptions options) {
} }
creatingContext.addCloseHook(this); creatingContext.addCloseHook(this);
} }
this.sslHelper = new SSLHelper(options, KeyStoreHelper.create(vertx, options.getKeyCertOptions()), KeyStoreHelper.create(vertx, options.getCaOptions())); this.sslHelper = new SSLHelper(options, KeyStoreHelper.create(vertx, options.getKeyCertOptions()), KeyStoreHelper.create(vertx, options.getTrustOptions()));
this.subProtocols = options.getWebsocketSubProtocols(); this.subProtocols = options.getWebsocketSubProtocols();
this.metrics = vertx.metricsSPI().createMetrics(this, options); this.metrics = vertx.metricsSPI().createMetrics(this, options);
} }
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/vertx/core/net/JksOptions.java
Expand Up @@ -45,7 +45,7 @@
* @author <a href="http://tfox.org">Tim Fox</a> * @author <a href="http://tfox.org">Tim Fox</a>
*/ */
@DataObject @DataObject
public class JksOptions implements KeyCertOptions, CaOptions, Cloneable { public class JksOptions implements KeyCertOptions, TrustOptions, Cloneable {


private String password; private String password;
private String path; private String path;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/io/vertx/core/net/NetClientOptions.java
Expand Up @@ -154,13 +154,13 @@ public NetClientOptions setTrustStoreOptions(JksOptions options) {
} }


@Override @Override
public NetClientOptions setPemCaOptions(PemCaOptions options) { public NetClientOptions setPemTrustOptions(PemTrustOptions options) {
return (NetClientOptions) super.setPemCaOptions(options); return (NetClientOptions) super.setPemTrustOptions(options);
} }


@Override @Override
public NetClientOptions setPfxCaOptions(PfxOptions options) { public NetClientOptions setPfxTrustOptions(PfxOptions options) {
return (NetClientOptions) super.setPfxCaOptions(options); return (NetClientOptions) super.setPfxTrustOptions(options);
} }


@Override @Override
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/io/vertx/core/net/NetServerOptions.java
Expand Up @@ -174,13 +174,13 @@ public NetServerOptions setTrustStoreOptions(JksOptions options) {
} }


@Override @Override
public NetServerOptions setPfxCaOptions(PfxOptions options) { public NetServerOptions setPfxTrustOptions(PfxOptions options) {
return (NetServerOptions) super.setPfxCaOptions(options); return (NetServerOptions) super.setPfxTrustOptions(options);
} }


@Override @Override
public NetServerOptions setPemCaOptions(PemCaOptions options) { public NetServerOptions setPemTrustOptions(PemTrustOptions options) {
return (NetServerOptions) super.setPemCaOptions(options); return (NetServerOptions) super.setPemTrustOptions(options);
} }


@Override @Override
Expand Down
Expand Up @@ -29,7 +29,7 @@


/** /**
* Certificate Authority options configuring certificates based on * Certificate Authority options configuring certificates based on
* <i>Privacy-enhanced Electronic Email</i> (PEM) files. The store is configured with a list of * <i>Privacy-enhanced Electronic Email</i> (PEM) files. The options is configured with a list of
* validating certificates. * validating certificates.
* <p> * <p>
* Validating certificates must contain X.509 certificates wrapped in a PEM block:<p> * Validating certificates must contain X.509 certificates wrapped in a PEM block:<p>
Expand All @@ -46,7 +46,7 @@
* <p> * <p>
* <pre> * <pre>
* HttpServerOptions options = new HttpServerOptions(); * HttpServerOptions options = new HttpServerOptions();
* options.setPemCaOptions(new PemCaOptions().addCertPath("/cert.pem")); * options.setPemTrustOptions(new PemTrustOptions().addCertPath("/cert.pem"));
* </pre> * </pre>
* *
* Or directly provided as a buffer: * Or directly provided as a buffer:
Expand All @@ -55,22 +55,22 @@
* <pre> * <pre>
* Buffer cert = vertx.fileSystem().readFileSync("/cert.pem"); * Buffer cert = vertx.fileSystem().readFileSync("/cert.pem");
* HttpServerOptions options = new HttpServerOptions(); * HttpServerOptions options = new HttpServerOptions();
* options.setPemCaOptions(new PemCaOptions().addCertValue(cert)); * options.setPemTrustOptions(new PemTrustOptions().addCertValue(cert));
* </pre> * </pre>
* *
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a> * @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
* @author <a href="http://tfox.org">Tim Fox</a> * @author <a href="http://tfox.org">Tim Fox</a>
*/ */
@DataObject @DataObject
public class PemCaOptions implements CaOptions, Cloneable { public class PemTrustOptions implements TrustOptions, Cloneable {


private ArrayList<String> certPaths; private ArrayList<String> certPaths;
private ArrayList<Buffer> certValues; private ArrayList<Buffer> certValues;


/** /**
* Default constructor * Default constructor
*/ */
public PemCaOptions() { public PemTrustOptions() {
super(); super();
this.certPaths = new ArrayList<>(); this.certPaths = new ArrayList<>();
this.certValues = new ArrayList<>(); this.certValues = new ArrayList<>();
Expand All @@ -81,7 +81,7 @@ public PemCaOptions() {
* *
* @param other the options to copy * @param other the options to copy
*/ */
public PemCaOptions(PemCaOptions other) { public PemTrustOptions(PemTrustOptions other) {
super(); super();
this.certPaths = new ArrayList<>(other.getCertPaths()); this.certPaths = new ArrayList<>(other.getCertPaths());
this.certValues = new ArrayList<>(other.getCertValues()); this.certValues = new ArrayList<>(other.getCertValues());
Expand All @@ -92,7 +92,7 @@ public PemCaOptions(PemCaOptions other) {
* *
* @param json the JSON * @param json the JSON
*/ */
public PemCaOptions(JsonObject json) { public PemTrustOptions(JsonObject json) {
super(); super();
this.certPaths = new ArrayList<>(); this.certPaths = new ArrayList<>();
this.certValues = new ArrayList<>(); this.certValues = new ArrayList<>();
Expand All @@ -118,7 +118,7 @@ public List<String> getCertPaths() {
* @return a reference to this, so the API can be used fluently * @return a reference to this, so the API can be used fluently
* @throws NullPointerException * @throws NullPointerException
*/ */
public PemCaOptions addCertPath(String certPath) throws NullPointerException { public PemTrustOptions addCertPath(String certPath) throws NullPointerException {
Objects.requireNonNull(certPath, "No null certificate accepted"); Objects.requireNonNull(certPath, "No null certificate accepted");
Arguments.require(!certPath.isEmpty(), "No empty certificate path accepted"); Arguments.require(!certPath.isEmpty(), "No empty certificate path accepted");
certPaths.add(certPath); certPaths.add(certPath);
Expand All @@ -140,15 +140,15 @@ public List<Buffer> getCertValues() {
* @return a reference to this, so the API can be used fluently * @return a reference to this, so the API can be used fluently
* @throws NullPointerException * @throws NullPointerException
*/ */
public PemCaOptions addCertValue(Buffer certValue) throws NullPointerException { public PemTrustOptions addCertValue(Buffer certValue) throws NullPointerException {
Objects.requireNonNull(certValue, "No null certificate accepted"); Objects.requireNonNull(certValue, "No null certificate accepted");
certValues.add(certValue); certValues.add(certValue);
return this; return this;
} }


@Override @Override
public PemCaOptions clone() { public PemTrustOptions clone() {
return new PemCaOptions(this); return new PemTrustOptions(this);
} }


} }
2 changes: 1 addition & 1 deletion src/main/java/io/vertx/core/net/PfxOptions.java
Expand Up @@ -45,7 +45,7 @@
* @author <a href="http://tfox.org">Tim Fox</a> * @author <a href="http://tfox.org">Tim Fox</a>
*/ */
@DataObject @DataObject
public class PfxOptions implements KeyCertOptions, CaOptions, Cloneable { public class PfxOptions implements KeyCertOptions, TrustOptions, Cloneable {


private String password; private String password;
private String path; private String path;
Expand Down

0 comments on commit 618f744

Please sign in to comment.