• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Java JWT signature example
2
3This is an example showing how to sign and verify JSON Web Tokens (JWT) with
4Tink.
5
6It demonstrates the basic steps of using Tink, namely loading key material,
7obtaining a primitive, and using the primitive to do crypto.
8
9The key material was generated with:
10
11```shell
12$ tinkey create-keyset --key-template JWT_ES256 --out-format JSON \
13    --out jwt_signature_test_private_keyset.json
14```
15
16## Build and Run
17
18### Bazel
19
20```shell
21$ git clone https://github.com/tink-crypto/tink-java
22$ cd examples
23$ bazel build ...
24$ touch token.txt
25
26$ ./bazel-bin/jwt/jwt_sign \
27    ./jwt/jwt_signature_test_private_keyset.json example_audience token.txt
28
29$ ./bazel-bin/jwt/jwt_generate_public_jwk_set \
30    ./jwt/jwt_signature_test_private_keyset.json public_jwk_set.json
31
32$ ./bazel-bin/jwt/jwt_verify \
33    public_jwk_set.json example_audience token.txt
34```
35