updated Readme release notes

This commit is contained in:
Les Hazlewood 2014-09-26 17:52:40 -07:00
parent 99cdf07fab
commit fe666b938e
1 changed files with 24 additions and 4 deletions

View File

@ -33,9 +33,7 @@ Random random = new SecureRandom();
byte[] key = new byte[64];
random.nextBytes(key);
Claims claims = Jwts.claims().setIssuer("Me").setSubject("Joe");
String compactJwt = Jwts.builder().setClaims(claims).signWith(HS256, key).compact();
String compactJwt = Jwts.builder().setIssuer("Me").setSubject("Joe").signWith(HS256, key).compact();
```
How easy was that!?
@ -45,7 +43,7 @@ Now let's verify the JWT (you should always discard JWTs that don't match an exp
```java
Jwt jwt = Jwts.parser().setSigningKey(key).parse(compactJwt);
assert jwt.getClaims().getSubject().equals("Joe");
assert ((Claims)jwt.getBody()).getSubject().equals("Joe");
```
You have to love one-line code snippets in Java!
@ -88,6 +86,28 @@ try {
These feature sets will be implemented in a future release when possible. Community contributions are welcome!
## Release Notes
### 0.2
#### More convenient Claims building
This release adds convenience methods to the `JwtBuilder` interface so you can set claims directly on the builder without having to create a separate Claims instance/builder, reducing the amount of code you have to write. For example, this:
```java
Claims claims = Jwts.claims().setIssuer("Me").setSubject("Joe");
String compactJwt = Jwts.builder().setClaims(claims).signWith(HS256, key).compact();
```
can now be written as:
```java
String compactJwt = Jwts.builder().setIssuer("Me").setSubject("Joe").signWith(HS256, key).compact();
```
and the JWT payload will use a constructed Claims instance automatically.
<a name="olderJackson"></a>
#### Already using an older Jackson dependency?