/** * The RAW String if available for the Access Token * @return String */ public String opaqueAccessToken() { String ret = delegate.opaqueAccessToken(); return ret; }
/** * The RAW String if available for the Access Token * @return String */ public String opaqueAccessToken() { String ret = delegate.opaqueAccessToken(); return ret; }
@Test public void shouldRefreshAToken(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(); final String origToken = token.opaqueAccessToken(); token.refresh(refresh -> { should.assertTrue(refresh.succeeded()); should.assertNotEquals(origToken, token.opaqueAccessToken()); test.complete(); }); }); }
@Test public void shouldLoginWithAccessToken(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(); keycloak.authenticate(new JsonObject().put("access_token", token.opaqueAccessToken()).put("token_type", "Bearer"), authn2 -> { should.assertTrue(authn2.succeeded()); should.assertNotNull(authn2.result()); test.complete(); }); }); }
session.put("token", accessToken.opaqueAccessToken()); session.put("id", id); session.put("email", email);
@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(); }); }); }); }