/** * Create a OAuth2Auth provider for Google Service Account (Server to Server) * * @param serviceAccountJson the configuration json file from your Google API page */ static OAuth2Auth create(Vertx vertx, JsonObject serviceAccountJson) { return create(vertx, serviceAccountJson, new HttpClientOptions()); }
/** * 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.GoogleAuth.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 Google * * @param clientId the client id given to you by Google * @param clientSecret the client secret given to you by Google */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret) { return create(vertx, clientId, clientSecret, new HttpClientOptions()); }
/** * 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.GoogleAuth.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 CookiePostHandler(final Vertx vertx, final JsonObject config) { final JsonObject auth = config.getJsonObject("auth"); this.oauth2 = GoogleAuth.create(vertx, auth.getString("client-id"), auth.getString("client-secret")); }
public static void discover(io.vertx.ext.auth.oauth2.providers.GoogleAuth 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.GoogleAuth.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); } public static io.vertx.ext.auth.oauth2.OAuth2Auth create(io.vertx.ext.auth.oauth2.providers.GoogleAuth j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> serviceAccountJson) {
public static io.vertx.ext.auth.oauth2.OAuth2Auth create(io.vertx.ext.auth.oauth2.providers.GoogleAuth j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> serviceAccountJson) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.auth.oauth2.providers.GoogleAuth.create(vertx, serviceAccountJson != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(serviceAccountJson) : null)); } public static io.vertx.ext.auth.oauth2.OAuth2Auth create(io.vertx.ext.auth.oauth2.providers.GoogleAuth j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> serviceAccountJson, java.util.Map<String, Object> httpClientOptions) {
@Test public void testGoogle() { GoogleAuth.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(); }
/** * Create a OAuth2Auth provider for Google Service Account (Server to Server) * @param vertx * @param serviceAccountJson the configuration json file from your Google API page * @param httpClientOptions custom http client options * @return */ public static io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth create(io.vertx.rxjava.core.Vertx vertx, JsonObject serviceAccountJson, HttpClientOptions httpClientOptions) { io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth ret = io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth.newInstance(io.vertx.ext.auth.oauth2.providers.GoogleAuth.create(vertx.getDelegate(), serviceAccountJson, httpClientOptions)); return ret; }
/** * Create a OAuth2Auth provider for Google Service Account (Server to Server) * @param vertx * @param serviceAccountJson the configuration json file from your Google API page * @param httpClientOptions custom http client options * @return */ public static io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth create(io.vertx.rxjava.core.Vertx vertx, JsonObject serviceAccountJson, HttpClientOptions httpClientOptions) { io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth ret = io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth.newInstance(io.vertx.ext.auth.oauth2.providers.GoogleAuth.create(vertx.getDelegate(), serviceAccountJson, httpClientOptions)); return ret; }
/** * Create a OAuth2Auth provider for Google * @param vertx * @param clientId the client id given to you by Google * @param clientSecret the client secret given to you by Google * @return */ public static io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth create(io.vertx.rxjava.core.Vertx vertx, String clientId, String clientSecret) { io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth ret = io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth.newInstance(io.vertx.ext.auth.oauth2.providers.GoogleAuth.create(vertx.getDelegate(), clientId, clientSecret)); return ret; }
/** * Create a OAuth2Auth provider for Google Service Account (Server to Server) * @param vertx * @param serviceAccountJson the configuration json file from your Google API page * @return */ public static io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth create(io.vertx.rxjava.core.Vertx vertx, JsonObject serviceAccountJson) { io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth ret = io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth.newInstance(io.vertx.ext.auth.oauth2.providers.GoogleAuth.create(vertx.getDelegate(), serviceAccountJson)); return ret; }
/** * Create a OAuth2Auth provider for Google * @param vertx * @param clientId the client id given to you by Google * @param clientSecret the client secret given to you by Google * @param httpClientOptions custom http client options * @return */ public static io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth create(io.vertx.rxjava.core.Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth ret = io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth.newInstance(io.vertx.ext.auth.oauth2.providers.GoogleAuth.create(vertx.getDelegate(), clientId, clientSecret, httpClientOptions)); return ret; }
/** * Create a OAuth2Auth provider for Google Service Account (Server to Server) * @param vertx * @param serviceAccountJson the configuration json file from your Google API page * @return */ public static io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth create(io.vertx.rxjava.core.Vertx vertx, JsonObject serviceAccountJson) { io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth ret = io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth.newInstance(io.vertx.ext.auth.oauth2.providers.GoogleAuth.create(vertx.getDelegate(), serviceAccountJson)); return ret; }
/** * Create a OAuth2Auth provider for Google * @param vertx * @param clientId the client id given to you by Google * @param clientSecret the client secret given to you by Google * @return */ public static io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth create(io.vertx.rxjava.core.Vertx vertx, String clientId, String clientSecret) { io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth ret = io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth.newInstance(io.vertx.ext.auth.oauth2.providers.GoogleAuth.create(vertx.getDelegate(), clientId, clientSecret)); return ret; }
/** * Create a OAuth2Auth provider for Google * @param vertx * @param clientId the client id given to you by Google * @param clientSecret the client secret given to you by Google * @param httpClientOptions custom http client options * @return */ public static io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth create(io.vertx.rxjava.core.Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth ret = io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth.newInstance(io.vertx.ext.auth.oauth2.providers.GoogleAuth.create(vertx.getDelegate(), clientId, clientSecret, httpClientOptions)); return ret; }
public static io.vertx.ext.auth.oauth2.OAuth2Auth create(io.vertx.ext.auth.oauth2.providers.GoogleAuth j_receiver, io.vertx.core.Vertx vertx, java.lang.String clientId, java.lang.String clientSecret, java.util.Map<String, Object> httpClientOptions) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.auth.oauth2.providers.GoogleAuth.create(vertx, clientId, clientSecret, httpClientOptions != null ? new io.vertx.core.http.HttpClientOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(httpClientOptions)) : null)); } public static void discover(io.vertx.ext.auth.oauth2.providers.GoogleAuth 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) {
public static io.vertx.ext.auth.oauth2.OAuth2Auth create(io.vertx.ext.auth.oauth2.providers.GoogleAuth j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> serviceAccountJson, java.util.Map<String, Object> httpClientOptions) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.auth.oauth2.providers.GoogleAuth.create(vertx, serviceAccountJson != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(serviceAccountJson) : null, httpClientOptions != null ? new io.vertx.core.http.HttpClientOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(httpClientOptions)) : null)); } }
@Test public void testLoadJWK() { OAuth2Auth oauth2 = GoogleAuth.create(vertx, "", ""); oauth2.loadJWK(load -> { assertFalse(load.failed()); testComplete(); }); await(); } }
@Override public void setUp() throws Exception { super.setUp(); oauth2 = GoogleAuth.create(vertx, new JsonObject() .put("type", "service_account") .put("project_id", "jetdrone")