Assuming I have multiple clients, I'm expecting from my "clientA" to provide a JWT token created with it's privateKeyClientA, like
String jwtToken = Jwts.builder()
.claims()
.issuer("ClientA")
.expiration(expirationDate)
.and()
.signWith(privateKeyClientA)
.compact() ;
to decode the claims, I can use
claims = Jwts.parser()
.verifyWith(publicKeyClientA)
.build()
.parseClaimsJws(jwtToken)
.getBody();
But, how do you identify "clientA", so, publicKeyClientA before validating the JWT's signature in an "elegant way"?
p.s. I must use "JJWT :: API" (io.jsonwebtoken)
Two approaches:
If there is no io.jsonwebtoken
support for parsing before validating, try another library.
Doing this yourself can be like so:
b
from "Bearer a.b.c"For header just parse a
instead.