Example usage for io.vertx.core.json JsonObject JsonObject

List of usage examples for io.vertx.core.json JsonObject JsonObject

Introduction

In this page you can find the example usage for io.vertx.core.json JsonObject JsonObject.

Prototype

public JsonObject() 

Source Link

Document

Create a new, empty instance

Usage

From source file:examples.ConfigKubernetesExamples.java

License:Apache License

public void example1(Vertx vertx) {
    ConfigStoreOptions store = new ConfigStoreOptions().setType("configmap")
            .setConfig(new JsonObject().put("namespace", "my-project-namespace").put("name", "configmap-name"));

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

From source file:examples.ConfigKubernetesExamples.java

License:Apache License

public void example2(Vertx vertx) {
    ConfigStoreOptions store = new ConfigStoreOptions().setType("configmap").setConfig(new JsonObject()
            .put("namespace", "my-project-namespace").put("name", "my-secret").put("secret", true));

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

From source file:examples.ConfigRedisExamples.java

License:Apache License

public void example1(Vertx vertx) {
    ConfigStoreOptions store = new ConfigStoreOptions().setType("redis").setConfig(
            new JsonObject().put("host", "localhost").put("port", 6379).put("key", "my-configuration"));

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

From source file:examples.ConfigSpringExamples.java

License:Apache License

public void example1(Vertx vertx) {
    ConfigStoreOptions store = new ConfigStoreOptions().setType("spring-config-server")
            .setConfig(new JsonObject().put("url", "http://localhost:8888/foo/development"));

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

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 exampleWithToken(Vertx vertx, String token) {
    JsonObject vault_config = new JsonObject();

    // ...// ww  w .  jav a 2 s  .co  m

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

    // The token
    vault_config.put("token", token);

    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 exampleWithTokenCreation(Vertx vertx, String token) {
    JsonObject vault_config = new JsonObject();

    // ...//from w w w .ja  va  2  s  . com

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

    // Configure the token generation

    // Configure the token request (https://www.vaultproject.io/docs/auth/token.html)
    JsonObject tokenRequest = new JsonObject().put("ttl", "1h").put("noDefault", true)

            // The token to use to request the generation (parts of the tokenRequest object)
            .put("token", token);

    vault_config.put("auth-backend", "token") // Indicate the auth backend to use
            .put("renew-window", 5000L) // Renew error margin in ms
            .put("token-request", tokenRequest); // Pass the token generation configuration

    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  w w w  . ja  v  a  2s  .co  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.ConfigVaultExamples.java

License:Apache License

public void exampleWithAppRole(Vertx vertx, String appRoleId, String secretId) {
    JsonObject vault_config = new JsonObject();

    // .../* w  w w.jav  a 2 s . c o m*/

    vault_config.put("auth-backend", "approle") // Set the auth-backend to approle
            .put("approle", new JsonObject() // Configure the role id and secret it
                    .put("role-id", appRoleId).put("secret-id", secretId));

    // 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 exampleWithUserPass(Vertx vertx, String username, String password) {
    JsonObject vault_config = new JsonObject();

    // .../* w  w  w.j  a v  a2s  .c o  m*/

    vault_config.put("auth-backend", "userpass") // Set the auth-backend to userpass
            .put("user-credentials", new JsonObject().put("username", username).put("password", password));

    // 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));
}