use of io.vertx.ext.auth.jwt.JWTAuthOptions in project vertx-auth by vert-x3.
the class JWTAuthProviderTest method testValidateTokenWithValidMacSecret.
@Test
public void testValidateTokenWithValidMacSecret() {
String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1MDE3ODUyMDZ9.08K_rROcCmKTF1cKfPCli2GQFYIOP8dePxeS1SE4dc8";
authProvider = JWTAuth.create(vertx, new JWTAuthOptions().addSecret(new SecretOptions().setType("HS256").setSecret("notasecret")));
JsonObject authInfo = new JsonObject().put("jwt", token);
authProvider.authenticate(authInfo, onSuccess(res -> {
assertNotNull(res);
testComplete();
}));
await();
}
use of io.vertx.ext.auth.jwt.JWTAuthOptions in project vertx-auth by vert-x3.
the class AuthJWTExamples method example17.
public void example17(Vertx vertx) {
JWTAuth provider = JWTAuth.create(vertx, new JWTAuthOptions().addPubSecKey(new PubSecKeyOptions().setAlgorithm("ES256").setSecretKey("MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgeRyEfU1NSHPTCuC9\n" + "rwLZMukaWCH2Fk6q5w+XBYrKtLihRANCAAStpUnwKmSvBM9EI+W5QN3ALpvz6bh0\n" + "SPCXyz5KfQZQuSj4f3l+xNERDUDaygIUdLjBXf/bc15ur2iZjcq4r0Mr")));
String token = provider.generateToken(new JsonObject(), new io.vertx.ext.jwt.JWTOptions().setAlgorithm("ES256"));
}
use of io.vertx.ext.auth.jwt.JWTAuthOptions in project vertx-auth by vert-x3.
the class AuthJWTExamples method example18.
public void example18(Vertx vertx) {
JWTAuth provider = JWTAuth.create(vertx, new JWTAuthOptions().addPubSecKey(new PubSecKeyOptions().setAlgorithm("ES256").setPublicKey("MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEraVJ8CpkrwTPRCPluUDdwC6b8+m4\n" + "dEjwl8s+Sn0GULko+H95fsTREQ1A2soCFHS4wV3/23Nebq9omY3KuK9DKw==\n").setSecretKey("MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgeRyEfU1NSHPTCuC9\n" + "rwLZMukaWCH2Fk6q5w+XBYrKtLihRANCAAStpUnwKmSvBM9EI+W5QN3ALpvz6bh0\n" + "SPCXyz5KfQZQuSj4f3l+xNERDUDaygIUdLjBXf/bc15ur2iZjcq4r0Mr")));
String token = provider.generateToken(new JsonObject(), new io.vertx.ext.jwt.JWTOptions().setAlgorithm("ES256"));
}
use of io.vertx.ext.auth.jwt.JWTAuthOptions in project vertx-auth by vert-x3.
the class AuthJWTExamples method example16.
public void example16(Vertx vertx) {
JWTAuth provider = JWTAuth.create(vertx, new JWTAuthOptions().addPubSecKey(new PubSecKeyOptions().setAlgorithm("HS256").setPublicKey("keyboard cat").setSymmetric(true)));
String token = provider.generateToken(new JsonObject());
}
Aggregations