You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+47-13Lines changed: 47 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,22 @@ An implementation of [JSON Web Tokens](http://self-issued.info/docs/draft-ietf-o
16
16
compile 'com.auth0:java-jwt:3.0.+'
17
17
```
18
18
19
+
## Available Algorithms
20
+
21
+
The library implements JWT Verification and Signing using the following algorithms:
22
+
23
+
| JWS | Algorithm | Description |
24
+
| :-------------: | :-------------: | :----- |
25
+
| HS256 | HMAC256 | HMAC with SHA-256 |
26
+
| HS384 | HMAC384 | HMAC with SHA-384 |
27
+
| HS512 | HMAC512 | HMAC with SHA-512 |
28
+
| RS256 | RSA256 | RSASSA-PKCS1-v1_5 with SHA-256 |
29
+
| RS384 | RSA384 | RSASSA-PKCS1-v1_5 with SHA-384 |
30
+
| RS512 | RSA512 | RSASSA-PKCS1-v1_5 with SHA-512 |
31
+
| ES256 | ECDSA256 | ECDSA with curve P-256 and SHA-256 |
32
+
| ES384 | ECDSA384 | ECDSA with curve P-384 and SHA-384 |
33
+
| ES512 | ECDSA512 | ECDSA with curve P-521 and SHA-512 |
34
+
19
35
## Usage
20
36
21
37
### Decode a Token
@@ -31,22 +47,40 @@ try {
31
47
32
48
If the token has an invalid syntax or the header or payload are not JSONs, a `JWTDecodeException` will raise.
33
49
34
-
### Verify a Token
35
50
51
+
### Create and Sign a Token
36
52
37
-
The library implements JWT Verification using the following algorithms:
53
+
You'll first need to create a `JWTCreator` instance by calling `JWT.create()` and passing the Algorithm instance. Use the builder to define the custom Claims your token needs to have. Finally to get the String token call `sign()`.
38
54
39
-
| JWS | Algorithm | Description |
40
-
| :-------------: | :-------------: | :----- |
41
-
| HS256 | HMAC256 | HMAC with SHA-256 |
42
-
| HS384 | HMAC384 | HMAC with SHA-384 |
43
-
| HS512 | HMAC512 | HMAC with SHA-512 |
44
-
| RS256 | RSA256 | RSASSA-PKCS1-v1_5 with SHA-256 |
45
-
| RS384 | RSA384 | RSASSA-PKCS1-v1_5 with SHA-384 |
46
-
| RS512 | RSA512 | RSASSA-PKCS1-v1_5 with SHA-512 |
47
-
| ES256 | ECDSA256 | ECDSA with curve P-256 and SHA-256 |
48
-
| ES384 | ECDSA384 | ECDSA with curve P-384 and SHA-384 |
49
-
| ES512 | ECDSA512 | ECDSA with curve P-521 and SHA-512 |
If a Claim couldn't be converted to JSON or the Key used in the signing process was invalid a `JWTCreationException` will raise.
81
+
82
+
83
+
### Verify a Token
50
84
51
85
You'll first need to create a `JWTVerifier` instance by calling `JWT.require()` and passing the Algorithm instance. If you require the token to have specific Claim values, use the builder to define them. The instance returned by the method `build()` is reusable, so you can define it once and use it to verify different tokens. Finally call `verifier.verify()` passing the token.
0 commit comments