Example usage for io.vertx.core Future succeededFuture

List of usage examples for io.vertx.core Future succeededFuture

Introduction

In this page you can find the example usage for io.vertx.core Future succeededFuture.

Prototype

static <T> Future<T> succeededFuture(T result) 

Source Link

Document

Created a succeeded future with the specified result.

Usage

From source file:org.sub.bug.BugCRUDServiceVertxEBProxy.java

License:Apache License

public void removeBug(String bugId, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from   ww  w  .  j  a  va 2s  .c  om*/
    }
    JsonObject _json = new JsonObject();
    _json.put("bugId", bugId);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "removeBug");
    _vertx.eventBus().<Void>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:org.workspace7.k8s.auth.proxy.K8sWebProxyVerticle.java

License:Apache License

protected void setup(Handler<AsyncResult<OAuth2Auth>> next, Future<Void> future) {

    final OAuth2ClientOptions options = new OAuth2ClientOptions();
    options.setSsl(true);//w w  w.j  a va2s.  co m
    options.setTrustStoreOptions(proxyTrustOptions());

    // keycloak conversion to oauth2 options
    if (config().containsKey("auth-server-url")) {
        options.setSite(config().getString("auth-server-url"));
    }

    if (config().containsKey("resource")) {
        options.setClientID(config().getString("resource"));
    }

    if (config().containsKey("credentials") && config().getJsonObject("credentials").containsKey("secret")) {
        options.setClientSecret(config().getJsonObject("credentials").getString("secret"));
    }

    if (config().containsKey("public-client") && config().getBoolean("public-client", false)) {
        options.setUseBasicAuthorizationHeader(true);
    }

    if (config().containsKey("realm")) {
        final String realm = config().getString("realm");

        options.setAuthorizationPath("/realms/" + realm + "/protocol/openid-connect/auth");
        options.setTokenPath("/realms/" + realm + "/protocol/openid-connect/token");
        options.setRevocationPath(null);
        options.setLogoutPath("/realms/" + realm + "/protocol/openid-connect/logout");
        options.setUserInfoPath("/realms/" + realm + "/protocol/openid-connect/userinfo");
    }

    if (config().containsKey("realm-public-key")) {
        options.setPublicKey(config().getString("realm-public-key"));
        options.setJwtToken(true);
    }

    OAuth2Auth keycloakOAuth2 = OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, options);

    next.handle(Future.succeededFuture(keycloakOAuth2));

}

From source file:se.liquidbytes.jel.database.DatabaseConnectionVertxEBProxy.java

License:Apache License

public DatabaseConnection getSite(String id, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from  w w  w . ja  va2s  .c  o  m
    JsonObject _json = new JsonObject();
    _json.put("id", id);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getSite");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:se.liquidbytes.jel.database.DatabaseConnectionVertxEBProxy.java

License:Apache License

public DatabaseConnection getSites(Handler<AsyncResult<JsonArray>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*w  w  w  . j  a va 2s  . c  o m*/
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getSites");
    _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:se.liquidbytes.jel.database.DatabaseConnectionVertxEBProxy.java

License:Apache License

public DatabaseConnection addSite(JsonObject document, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from  ww  w  . j  a  va  2s  .c om*/
    JsonObject _json = new JsonObject();
    _json.put("document", document);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "addSite");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:se.liquidbytes.jel.database.DatabaseConnectionVertxEBProxy.java

License:Apache License

public DatabaseConnection updateSite(JsonObject document, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from   www . j  a v a2 s . com*/
    JsonObject _json = new JsonObject();
    _json.put("document", document);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "updateSite");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:se.liquidbytes.jel.database.DatabaseConnectionVertxEBProxy.java

License:Apache License

public DatabaseConnection removeSite(String id, Handler<AsyncResult<Void>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/* ww w .j  av  a2s. c o  m*/
    JsonObject _json = new JsonObject();
    _json.put("id", id);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "removeSite");
    _vertx.eventBus().<Void>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:se.liquidbytes.jel.database.DatabaseConnectionVertxEBProxy.java

License:Apache License

public DatabaseConnection getUser(String id, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/* www  . ja  v  a  2 s  .  c o  m*/
    JsonObject _json = new JsonObject();
    _json.put("id", id);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getUser");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:se.liquidbytes.jel.database.DatabaseConnectionVertxEBProxy.java

License:Apache License

public DatabaseConnection getUserByUsername(String username, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from  ww  w  . ja  v  a 2s  .c o  m*/
    JsonObject _json = new JsonObject();
    _json.put("username", username);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getUserByUsername");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}

From source file:se.liquidbytes.jel.database.DatabaseConnectionVertxEBProxy.java

License:Apache License

public DatabaseConnection getUsers(Handler<AsyncResult<JsonArray>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from w  w w.j  a  va2s  .c o m
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getUsers");
    _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
    return this;
}