mirror of https://github.com/jwtk/jjwt.git
updated Readme release notes
This commit is contained in:
parent
99cdf07fab
commit
fe666b938e
28
README.md
28
README.md
|
@ -33,9 +33,7 @@ Random random = new SecureRandom();
|
||||||
byte[] key = new byte[64];
|
byte[] key = new byte[64];
|
||||||
random.nextBytes(key);
|
random.nextBytes(key);
|
||||||
|
|
||||||
Claims claims = Jwts.claims().setIssuer("Me").setSubject("Joe");
|
String compactJwt = Jwts.builder().setIssuer("Me").setSubject("Joe").signWith(HS256, key).compact();
|
||||||
|
|
||||||
String compactJwt = Jwts.builder().setClaims(claims).signWith(HS256, key).compact();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
How easy was that!?
|
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
|
```java
|
||||||
Jwt jwt = Jwts.parser().setSigningKey(key).parse(compactJwt);
|
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!
|
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!
|
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>
|
<a name="olderJackson"></a>
|
||||||
#### Already using an older Jackson dependency?
|
#### Already using an older Jackson dependency?
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue