/** * Create a OAuth2Auth provider for OpenID Connect Discovery. The discovery will use the default site in the * configuration options and attempt to load the well known descriptor. If a site is provided (for example when * running on a custom instance) that site will be used to do the lookup. * <p> * If the discovered config includes a json web key url, it will be also fetched and the JWKs will be loaded * into the OAuth provider so tokens can be decoded. * @param vertx the vertx instance * @param config the initial config * @param handler the instantiated Oauth2 provider instance handler */ public static void discover(io.vertx.rxjava.core.Vertx vertx, OAuth2ClientOptions config, Handler<AsyncResult<io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth>> handler) { io.vertx.ext.auth.oauth2.providers.SalesforceAuth.discover(vertx.getDelegate(), config, new Handler<AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth>>() { public void handle(AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
/** * Create a OAuth2Auth provider for OpenID Connect Discovery. The discovery will use the default site in the * configuration options and attempt to load the well known descriptor. If a site is provided (for example when * running on a custom instance) that site will be used to do the lookup. * <p> * If the discovered config includes a json web key url, it will be also fetched and the JWKs will be loaded * into the OAuth provider so tokens can be decoded. * @param vertx the vertx instance * @param config the initial config * @param handler the instantiated Oauth2 provider instance handler */ public static void discover(io.vertx.rxjava.core.Vertx vertx, OAuth2ClientOptions config, Handler<AsyncResult<io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth>> handler) { io.vertx.ext.auth.oauth2.providers.SalesforceAuth.discover(vertx.getDelegate(), config, new Handler<AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth>>() { public void handle(AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
public static void discover(io.vertx.ext.auth.oauth2.providers.SalesforceAuth j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> config, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth>> handler) { io.vertx.ext.auth.oauth2.providers.SalesforceAuth.discover(vertx, config != null ? new io.vertx.ext.auth.oauth2.OAuth2ClientOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(config)) : null, handler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth> ar) { handler.handle(ar.map(event -> io.vertx.core.impl.ConversionHelper.fromObject(event))); } } : null); } }
@Test public void testSalesforce() { SalesforceAuth.discover(vertx, new OAuth2ClientOptions(), load -> { // will fail as there is no application config, but the parsing should have happened assertTrue(load.failed()); assertEquals("Configuration missing. You need to specify [clientId]", load.cause().getMessage()); testComplete(); }); await(); } }