private Claims extractAllClaims(String token){
return Jwts
.parser()
.verifyWith(getSignInKey())
.build()
.parseSignedClaims(token)
.getPayload();
}
private Foo extractFoo(String token){
Claims claims = extractAllClaims(token);
return claims.getFoo();
}
private Bar extractBar(String token){
Claims claims = extractAllClaims(token);
return claims.getBar();
}
Is the code above or below good practice to extract data and why? Thanks for your contribute!
private Date extractFoo(String token){
Claims claims = Jwts
.parser()
.verifyWith(getSignInKey())
.build()
.parseSignedClaims(token)
.getPayload();
return claims.getFoo();
}
private Date extractBar(String token){
Claims claims = Jwts
.parser()
.verifyWith(getSignInKey())
.build()
.parseSignedClaims(token)
.getPayload();
return claims.getBar();
}
On top we will be bearing with jwts’ chain once, but on bottom each time we extract something.
3