-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Milestone
Description
@bobmcwhirter @adietish @gunnarmorling @Sanne @stalep
Issue while creating JWT token with quarkus-smallrye-jwt dependency
While creating token
JwtClaimsBuilder claims = Jwt.claims(jsonResName); throws NPE.
Initially thought file is not loading may be the path of the file is wrong, but when I
tried to read the content of the file with below code, I am getting the content. So it means file path is correct.
InputStream inputStream = JwtUtil.class.getResourceAsStream("/privateKey.pem")
Below is my piece of code to create token.
public static String generateTokenString(PrivateKey privateKey, String kid,
String jsonResName, Map<String, Long> timeClaims) throws Exception {
JwtClaimsBuilder claims = Jwt.claims(jsonResName);
long currentTimeInSecs = currentTimeInSecs();
long exp = timeClaims != null && timeClaims.containsKey(Claims.exp.name())
? timeClaims.get(Claims.exp.name()) : currentTimeInSecs + 300;
claims.issuedAt(currentTimeInSecs);
claims.claim(Claims.auth_time.name(), currentTimeInSecs);
claims.expiresAt(exp);
return claims.jws().signatureKeyId(kid).sign(privateKey);
}
Metadata
Metadata
Assignees
Labels
No labels