From 13650e3f01adbae75572eb676b819ffa086978b7 Mon Sep 17 00:00:00 2001 From: Les Hazlewood Date: Fri, 26 Sep 2014 20:12:07 -0700 Subject: [PATCH] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3a13ca1d..d191181d 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Random random = new SecureRandom(); byte[] key = new byte[64]; random.nextBytes(key); -String compactJwt = Jwts.builder().setSubject("Joe").signWith(HS256, key).compact(); +String compact = Jwts.builder().setSubject("Joe").signWith(HS256, key).compact(); ``` How easy was that!? @@ -41,9 +41,9 @@ How easy was that!? Now let's verify the JWT (you should always discard JWTs that don't match an expected signature): ```java -Jwt jwt = Jwts.parser().setSigningKey(key).parse(compactJwt); +Claims claims = Jwts.parser().setSigningKey(key).parseClaimsJws(compact).getBody(); -assert ((Claims)jwt.getBody()).getSubject().equals("Joe"); +assert claims.getSubject().equals("Joe"); ``` You have to love one-line code snippets in Java!