use of io.vertx.ext.auth.oauth2.impl.OAuth2TokenImpl in project vertx-auth by vert-x3.
the class PasswordImpl method getToken.
/**
* Returns the Access Token object.
*
* @param params - username: A string that represents the registered username.
* password: A string that represents the registered password.
* scope: A String that represents the application privileges.
* @param handler - The handler function returning the results.
*/
@Override
public void getToken(JsonObject params, Handler<AsyncResult<AccessToken>> handler) {
getToken("password", params, res -> {
if (res.failed()) {
handler.handle(Future.failedFuture(res.cause()));
return;
}
AccessToken token;
try {
token = new OAuth2TokenImpl(provider, res.result());
} catch (RuntimeException e) {
handler.handle(Future.failedFuture(e));
return;
}
handler.handle(Future.succeededFuture(token));
});
}
use of io.vertx.ext.auth.oauth2.impl.OAuth2TokenImpl in project vertx-auth by vert-x3.
the class Oauth2TokenTest method testNullScope.
@Test
public void testNullScope() throws Exception {
super.setUp();
oauth2 = KeycloakAuth.create(vertx, OAuth2FlowType.AUTH_CODE, keycloakConfig);
JsonObject json = new JsonObject("{\n" + " \"access_token\":\"xyz\",\n" + " \"expires_in\":60,\n" + " \"token_type\":\"bearer\",\n" + " \"not-before-policy\":0,\n" + " \"scope\":null\n" + "}");
try {
OAuth2TokenImpl token = new OAuth2TokenImpl((OAuth2AuthProviderImpl) oauth2, json);
} catch (RuntimeException e) {
fail();
}
}
use of io.vertx.ext.auth.oauth2.impl.OAuth2TokenImpl in project vertx-auth by vert-x3.
the class Oauth2TokenTest method keycloakTest.
@Test
public void keycloakTest() throws Exception {
super.setUp();
oauth2 = KeycloakAuth.create(vertx, OAuth2FlowType.AUTH_CODE, keycloakConfig);
OAuth2TokenImpl token = new OAuth2TokenImpl((OAuth2AuthProviderImpl) oauth2, keycloakToken);
assertNotNull(token.opaqueAccessToken());
assertNotNull(token.opaqueRefreshToken());
assertNull(token.accessToken());
// trust it
token.setTrustJWT(true);
assertNotNull(token.accessToken());
}
Aggregations