use of org.apache.geronimo.microprofile.impl.jwtauth.jwt.KidMapper in project meecrowave by apache.
the class OAuth2Test method validateJwt.
private void validateJwt(final ClientAccessToken token) {
final JwtParser parser = new JwtParser();
final KidMapper kidMapper = new KidMapper();
final DateValidator dateValidator = new DateValidator();
final SignatureValidator signatureValidator = new SignatureValidator();
final GeronimoJwtAuthConfig config = (value, def) -> {
switch(value) {
case "issuer.default":
return "myissuer";
case "jwt.header.kid.default":
return "defaultkid";
case "public-key.default":
return Base64.getEncoder().encodeToString(PUBLIC_KEY.getEncoded());
default:
return def;
}
};
setField(kidMapper, "config", config);
setField(dateValidator, "config", config);
setField(parser, "config", config);
setField(signatureValidator, "config", config);
setField(parser, "kidMapper", kidMapper);
setField(parser, "dateValidator", dateValidator);
setField(parser, "signatureValidator", signatureValidator);
Stream.of(dateValidator, signatureValidator, kidMapper, parser).forEach(this::init);
final JsonWebToken jsonWebToken = parser.parse(token.getTokenKey());
assertNotNull(jsonWebToken);
assertEquals("myissuer", jsonWebToken.getIssuer());
assertEquals("test", JsonString.class.cast(jsonWebToken.getClaim("username")).getString());
}
Aggregations