Example usage for io.vertx.core.net JksOptions JksOptions

List of usage examples for io.vertx.core.net JksOptions JksOptions

Introduction

In this page you can find the example usage for io.vertx.core.net JksOptions JksOptions.

Prototype

public JksOptions() 

Source Link

Document

Default constructor

Usage

From source file:eu.rethink.mn.MsgNode.java

License:Apache License

@Override
public void start() throws Exception {
    final PipeRegistry register = new PipeRegistry(vertx, mgr, config.getDomain());
    register.installComponent(new SubscriptionManager(register));
    register.installComponent(new SessionManager(register));
    register.installComponent(new HypertyAllocationManager(register));
    register.installComponent(new ObjectAllocationManager(register));
    register.installComponent(new AllocationManager(register));

    final RegistryConnector rc = new RegistryConnector(register);
    register.installComponent(rc);//from  w  w w. j  ava  2 s  . c  om

    final GlobalRegistryConnector grc = new GlobalRegistryConnector(register);
    register.installComponent(grc);

    final Pipeline pipeline = new Pipeline(register).addHandler(new ValidatorPipeHandler()) //validation of mandatory fields
            .addHandler(new TransitionPipeHandler()) //inter-domain allocator and routing
            .addHandler(new PoliciesPipeHandler()).failHandler(error -> {
                out.println("PIPELINE-FAIL: " + error);
            });

    //HTTPS security configurations
    final JksOptions jksOptions = new JksOptions().setPath("server-keystore.jks").setPassword("rethink2015");

    final HttpServerOptions httpOptions = new HttpServerOptions().setTcpKeepAlive(true).setSsl(true)
            .setKeyStoreOptions(jksOptions).setMaxWebsocketFrameSize(6553600);

    final HttpServer server = vertx.createHttpServer(httpOptions);
    server.requestHandler(req -> {
        //just a land page to test connection
        System.out.println("HTTP-PING");
        req.response().putHeader("content-type", "text/html").end("<html><body><h1>Hello</h1></body></html>");
    });

    WebSocketServer.init(server, pipeline);
    server.listen(config.getPort());
    System.out.println("[Message-Node] Running with config: " + config);
}

From source file:examples.ConfigVaultExamples.java

License:Apache License

public void example1WithConfig(Vertx vertx) {
    JsonObject vault_config = new JsonObject().put("host", "127.0.0.1") // The host name
            .put("port", 8200) // The port
            .put("ssl", true); // Whether or not SSL is used (disabled by default)

    // Certificates
    PemKeyCertOptions certs = new PemKeyCertOptions().addCertPath("target/vault/config/ssl/client-cert.pem")
            .addKeyPath("target/vault/config/ssl/client-privatekey.pem");
    vault_config.put("pemKeyCertOptions", certs.toJson());

    // Truststore
    JksOptions jks = new JksOptions().setPath("target/vault/config/ssl/truststore.jks");
    vault_config.put("trustStoreOptions", jks.toJson());

    // Path to the secret to read.
    vault_config.put("path", "secret/my-secret");

    ConfigStoreOptions store = new ConfigStoreOptions().setType("vault").setConfig(vault_config);

    ConfigRetriever retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(store));
}

From source file:examples.ConfigVaultExamples.java

License:Apache License

public void exampleWithCerts(Vertx vertx) {
    JsonObject vault_config = new JsonObject();

    // ...//from  ww  w .  j a va 2s.c o m

    PemKeyCertOptions certs = new PemKeyCertOptions().addCertPath("target/vault/config/ssl/client-cert.pem")
            .addKeyPath("target/vault/config/ssl/client-privatekey.pem");
    vault_config.put("pemKeyCertOptions", certs.toJson());

    PemTrustOptions trust = new PemTrustOptions().addCertPath("target/vault/config/ssl/cert.pem");
    vault_config.put("pemTrustStoreOptions", trust.toJson());

    JksOptions jks = new JksOptions().setPath("target/vault/config/ssl/truststore.jks");
    vault_config.put("trustStoreOptions", jks.toJson());

    vault_config.put("auth-backend", "cert");

    // Path to the secret to read.
    vault_config.put("path", "secret/my-secret");

    ConfigStoreOptions store = new ConfigStoreOptions().setType("vault").setConfig(vault_config);

    ConfigRetriever retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(store));
}

From source file:examples.EventBusExamples.java

License:Open Source License

public void example13() {
    VertxOptions options = new VertxOptions().setEventBusOptions(new EventBusOptions().setSsl(true)
            .setKeyStoreOptions(new JksOptions().setPath("keystore.jks").setPassword("wibble"))
            .setTrustStoreOptions(new JksOptions().setPath("keystore.jks").setPassword("wibble"))
            .setClientAuth(ClientAuth.REQUIRED));

    Vertx.clusteredVertx(options, res -> {
        if (res.succeeded()) {
            Vertx vertx = res.result();/*from   w w w  . ja  v a2 s .  c  o  m*/
            EventBus eventBus = vertx.eventBus();
            System.out.println("We now have a clustered event bus: " + eventBus);
        } else {
            System.out.println("Failed: " + res.cause());
        }
    });
}

From source file:examples.HTTP2Examples.java

License:Open Source License

public void example0(Vertx vertx) {
    HttpServerOptions options = new HttpServerOptions().setUseAlpn(true).setSsl(true)
            .setKeyStoreOptions(new JksOptions().setPath("/path/to/my/keystore"));

    HttpServer server = vertx.createHttpServer(options);
}

From source file:examples.NetExamples.java

License:Open Source License

public void example17(Vertx vertx) {
    NetServerOptions options = new NetServerOptions().setSsl(true).setKeyStoreOptions(new JksOptions()
            .setPath("/path/to/your/server-keystore.jks").setPassword("password-of-your-keystore"));
    NetServer server = vertx.createNetServer(options);
}

From source file:examples.NetExamples.java

License:Open Source License

public void example18(Vertx vertx) {
    Buffer myKeyStoreAsABuffer = vertx.fileSystem().readFileBlocking("/path/to/your/server-keystore.jks");
    JksOptions jksOptions = new JksOptions().setValue(myKeyStoreAsABuffer)
            .setPassword("password-of-your-keystore");
    NetServerOptions options = new NetServerOptions().setSsl(true).setKeyStoreOptions(jksOptions);
    NetServer server = vertx.createNetServer(options);
}

From source file:examples.NetExamples.java

License:Open Source License

public void example23(Vertx vertx) {
    NetServerOptions options = new NetServerOptions().setSsl(true).setClientAuth(ClientAuth.REQUIRED)
            .setTrustStoreOptions(new JksOptions().setPath("/path/to/your/truststore.jks")
                    .setPassword("password-of-your-truststore"));
    NetServer server = vertx.createNetServer(options);
}

From source file:examples.NetExamples.java

License:Open Source License

public void example24(Vertx vertx) {
    Buffer myTrustStoreAsABuffer = vertx.fileSystem().readFileBlocking("/path/to/your/truststore.jks");
    NetServerOptions options = new NetServerOptions().setSsl(true).setClientAuth(ClientAuth.REQUIRED)
            .setTrustStoreOptions(new JksOptions().setValue(myTrustStoreAsABuffer)
                    .setPassword("password-of-your-truststore"));
    NetServer server = vertx.createNetServer(options);
}

From source file:examples.NetExamples.java

License:Open Source License

public void example30(Vertx vertx) {
    NetClientOptions options = new NetClientOptions().setSsl(true).setTrustStoreOptions(new JksOptions()
            .setPath("/path/to/your/truststore.jks").setPassword("password-of-your-truststore"));
    NetClient client = vertx.createNetClient(options);
}