/** * Query an OAuth 2.0 authorization server to determine the active state of an OAuth 2.0 token and to determine * meta-information about this token. * @param token the access token (base64 string) * @param handler A handler to receive the event * @return self */ public io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth introspectToken(String token, Handler<AsyncResult<io.vertx.rxjava.ext.auth.oauth2.AccessToken>> handler) { delegate.introspectToken(token, new Handler<AsyncResult<io.vertx.ext.auth.oauth2.AccessToken>>() { public void handle(AsyncResult<io.vertx.ext.auth.oauth2.AccessToken> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.auth.oauth2.AccessToken.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Query an OAuth 2.0 authorization server to determine the active state of an OAuth 2.0 token and to determine * meta-information about this token. * @param token the access token (base64 string) * @param handler A handler to receive the event * @return self */ public io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth introspectToken(String token, Handler<AsyncResult<io.vertx.rxjava.ext.auth.oauth2.AccessToken>> handler) { delegate.introspectToken(token, new Handler<AsyncResult<io.vertx.ext.auth.oauth2.AccessToken>>() { public void handle(AsyncResult<io.vertx.ext.auth.oauth2.AccessToken> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.auth.oauth2.AccessToken.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Query an OAuth 2.0 authorization server to determine the active state of an OAuth 2.0 token and to determine * meta-information about this token. * @param token the access token (base64 string) * @param tokenType hint to the token type e.g.: `access_token` * @param handler A handler to receive the event * @return self */ public io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth introspectToken(String token, String tokenType, Handler<AsyncResult<io.vertx.rxjava.ext.auth.oauth2.AccessToken>> handler) { delegate.introspectToken(token, tokenType, new Handler<AsyncResult<io.vertx.ext.auth.oauth2.AccessToken>>() { public void handle(AsyncResult<io.vertx.ext.auth.oauth2.AccessToken> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.auth.oauth2.AccessToken.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Query an OAuth 2.0 authorization server to determine the active state of an OAuth 2.0 token and to determine * meta-information about this token. * @param token the access token (base64 string) * @param tokenType hint to the token type e.g.: `access_token` * @param handler A handler to receive the event * @return self */ public io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth introspectToken(String token, String tokenType, Handler<AsyncResult<io.vertx.rxjava.ext.auth.oauth2.AccessToken>> handler) { delegate.introspectToken(token, tokenType, new Handler<AsyncResult<io.vertx.ext.auth.oauth2.AccessToken>>() { public void handle(AsyncResult<io.vertx.ext.auth.oauth2.AccessToken> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.auth.oauth2.AccessToken.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Query an OAuth 2.0 authorization server to determine the active state of an OAuth 2.0 token and to determine * meta-information about this token. * * @param token the access token (base64 string) * @param handler A handler to receive the event * @return self */ @Fluent default OAuth2Auth introspectToken(String token, Handler<AsyncResult<AccessToken>> handler) { return introspectToken(token, "access_token", handler); }
@Test public void introspectAccessTokenKeyCloakWay() { config = oauthIntrospect; fixture = fixtureKeycloak; oauth2.introspectToken(token, res -> { if (res.failed()) { fail(res.cause()); } else { AccessToken token = res.result(); assertNotNull(token); assertNotNull(token.principal()); testComplete(); } }); await(); } }
@Test public void shouldIntrospectAccessToken(TestContext should) { final Async test = should.async(); keycloak.authenticate(new JsonObject().put("username", "test-user").put("password", "tiger"), authn -> { should.assertTrue(authn.succeeded()); should.assertNotNull(authn.result()); // generate a access token from the user AccessToken token = (AccessToken) authn.result(); OAuth2ClientOptions options = new OAuth2ClientOptions() .setFlow(OAuth2FlowType.PASSWORD) .setSite(site + "/auth/realms/vertx-test") .setClientID("confidential-client") .setClientSecret("62b8de48-672e-4287-bb1e-6af39aec045e"); options.setTrustAll(true); // get a auth handler for the confidential client KeycloakAuth.discover( rule.vertx(), options, discover -> { should.assertTrue(discover.succeeded()); OAuth2Auth confidential = discover.result(); confidential.introspectToken(token.opaqueAccessToken(), introspect -> { should.assertTrue(introspect.succeeded()); test.complete(); }); }); }); }
config = oauthIntrospect; fixture = fixtureGoogle; oauth2.introspectToken(token, res -> { if (res.failed()) { fail(res.cause().getMessage());
config = oauthIntrospect; fixture = fixtureIntrospect; oauth2.introspectToken(token, res -> { if (res.failed()) { fail(res.cause().getMessage());