Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
J

jjwt

> 安全
Open source

Java JWT: JSON Web Token for Java and Android

11.1K stars0 likes9 views
WebsiteGitHub

About

Java JWT: JSON Web Token for Java and Android

:doctype: book = Java JWT: JSON Web Token for Java and Android :project-version: 0.13.0 :toc: :toc-title: :toc-placement!: :toclevels: 4

ifdef::env-github[] :tip-caption: ✏️TIP :note-caption: ℹ️ NOTE :important-caption: ‼️IMPORTANT :caution-caption: ⛔️CAUTION :warning-caption: ⚠️WARNING endif::[]

// Macros :fn-require-java11-plus: Requires Java 11 or a compatible JCA Provider (like BouncyCastle) in the runtime classpath. :fn-require-java15-plus: Requires Java 15 or a compatible JCA Provider (like BouncyCastle) in the runtime classpath.

image:https://github.com/jwtk/jjwt/actions/workflows/ci.yml/badge.svg?branch=master[Build Status,link=https://github.com/jwtk/jjwt/actions/workflows/ci.yml?query=branch%3Amaster] image:https://coveralls.io/repos/github/jwtk/jjwt/badge.svg?branch=master[Coverage Status,link=https://coveralls.io/github/jwtk/jjwt?branch=master] image:https://snyk-widget.herokuapp.com/badge/mvn/io.jsonwebtoken/jjwt-root/badge.svg[Vuln score,link=https://snyk-widget.herokuapp.com/badge/mvn/io.jsonwebtoken/jjwt-root/badge.svg] image:https://snyk.io/test/github/jwtk/jjwt/badge.svg[Known Vulns,link=https://snyk.io/test/github/jwtk/jjwt/badge.svg] image:https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A[link="https://community.develocity.cloud/scans?search.rootProjectNames=JJWT",title="Revved up by Develocity"]

JJWT aims to be the easiest to use and understand library for creating and verifying JSON Web Tokens (JWTs) and JSON Web Keys (JWKs) on the JVM and Android.

JJWT is a pure Java implementation based exclusively on the https://datatracker.ietf.org/wg/jose/documents/[JOSE Working Group] RFC specifications:

  • https://tools.ietf.org/html/rfc7519[RFC 7519: JSON Web Token (JWT)]
  • https://tools.ietf.org/html/rfc7515[RFC 7515: JSON Web Signature (JWS)]
  • https://tools.ietf.org/html/rfc7516[RFC 7516: JSON Web Encryption (JWE)]
  • https://tools.ietf.org/html/rfc7517[RFC 7517: JSON Web Key (JWK)]
  • https://tools.ietf.org/html/rfc7518[RFC 7518: JSON Web Algorithms (JWA)]
  • https://www.rfc-editor.org/rfc/rfc7638.html[RFC 7638: JSON Web Key Thumbprint]
  • https://www.rfc-editor.org/rfc/rfc9278.html[RFC 9278: JSON Web Key Thumbprint URI]
  • https://www.rfc-editor.org/rfc/rfc7797.html[RFC 7797: JWS Unencoded Payload Option]
  • https://www.rfc-editor.org/rfc/rfc8037[RFC 8037: Edwards Curve algorithms and JWKs]

It was created by https://github.com/lhazlewood[Les Hazlewood] and is supported and maintained by a https://github.com/jwtk/jjwt/graphs/contributors[community] of contributors.

JJWT is open source under the terms of the http://www.apache.org/licenses/LICENSE-2.0[Apache 2.0 License].

==== [discrete] == Table of Contents

toc::[]

++++++++++++

== Features

  • Fully functional on all Java 8+ JDKs and Android
  • Automatic security best practices and assertions
  • Easy to learn and read API
  • Convenient and readable http://en.wikipedia.org/wiki/Fluent_interface[fluent] interfaces, great for IDE auto-completion to write code quickly
  • Fully RFC specification compliant on all implemented functionality, tested against RFC-specified test vectors
  • Stable implementation with almost 1,700 tests and enforced 100% test code coverage. Every single method, statement and conditional branch variant in the entire codebase is tested and required to pass on every build.
  • Creating, parsing and verifying digitally signed compact JWTs (aka JWSs) with all standard JWS algorithms:

|=== | Identifier | Signature Algorithm

| HS256 | HMAC using SHA-256

| HS384 | HMAC using SHA-384

| HS512 | HMAC using SHA-512

| ES256 | ECDSA using P-256 and SHA-256

| ES384 | ECDSA using P-384 and SHA-384

| ES512 | ECDSA using P-521 and SHA-512

| RS256 | RSASSA-PKCS-v1_5 using SHA-256

| RS384 | RSASSA-PKCS-v1_5 using SHA-384

| RS512 | RSASSA-PKCS-v1_5 using SHA-512

| PS256 | RSASSA-PSS using SHA-256 and MGF1 with SHA-256^1^

| PS384 | RSASSA-PSS using SHA-384 and MGF1 with SHA-384^1^

| PS512 | RSASSA-PSS using SHA-512 and MGF1 with SHA-512^1^

| EdDSA | Edwards-curve Digital Signature Algorithm^2^ |=== + ^1.{sp}{fn-require-java11-plus}^ + ^2.{sp}{fn-require-java15-plus}^

  • Creating, parsing and decrypting encrypted compact JWTs (aka JWEs) with all standard JWE encryption algorithms:

|=== | Identifier | Encryption Algorithm

| A128CBC‑HS256 | https://www.rfc-editor.org/rfc/rfc7518.html#section-5.2.3[AES_128_CBC_HMAC_SHA_256] authenticated encryption algorithm

| A192CBC-HS384 | https://www.rfc-editor.org/rfc/rfc7518.html#section-5.2.4[AES_192_CBC_HMAC_SHA_384] authenticated encryption algorithm

| A256CBC-HS512 | https://www.rfc-editor.org/rfc/rfc7518.html#section-5.2.5[AES_256_CBC_HMAC_SHA_512] authenticated encryption algorithm

| A128GCM | AES GCM using 128-bit key

| A192GCM | AES GCM using 192-bit key

| A256GCM | AES GCM using 256-bit key |=== +

  • All Key Management Algorithms for obtaining JWE encryption and decryption keys:

|=== | Identifier | Key Management Algorithm

| RSA1_5 | RSAES-PKCS1-v1_5

| RSA-OAEP | RSAES OAEP using default parameters

| RSA-OAEP-256 | RSAES OAEP using SHA-256 and MGF1 with SHA-256

| A128KW | AES Key Wrap with default initial value using 128-bit key

| A192KW | AES Key Wrap with default initial value using 192-bit key

| A256KW | AES Key Wrap with default initial value using 256-bit key

| dir | Direct use of a shared symmetric key as the CEK

| ECDH-ES | Elliptic Curve Diffie-Hellman Ephemeral Static key agreement using Concat KDF

| ECDH-ES+A128KW | ECDH-ES using Concat KDF and CEK wrapped with "A128KW"

| ECDH-ES+A192KW | ECDH-ES using Concat KDF and CEK wrapped with "A192KW"

| ECDH-ES+A256KW | ECDH-ES using Concat KDF and CEK wrapped with "A256KW"

| A128GCMKW | Key wrapping with AES GCM using 128-bit key

| A192GCMKW | Key wrapping with AES GCM using 192-bit key

| A256GCMKW | Key wrapping with AES GCM using 256-bit key

| PBES2-HS256+A128KW | PBES2 with HMAC SHA-256 and "A128KW" wrapping

| PBES2-HS384+A192KW | PBES2 with HMAC SHA-384 and "A192KW" wrapping

| PBES2‑HS512+A256KW | PBES2 with HMAC SHA-512 and "A256KW" wrapping |=== +

  • Creating, parsing and verifying JSON Web Keys (JWKs) in all standard JWA key formats using native Java Key types:

|=== | JWK Key Format | Java Key Type | JJWT Jwk Type

| Symmetric Key | SecretKey | SecretJwk

| Elliptic Curve Public Key | ECPublicKey | EcPublicJwk

| Elliptic Curve Private Key | ECPrivateKey | EcPrivateJwk

| RSA Public Key | RSAPublicKey | RsaPublicJwk

| RSA Private Key | RSAPrivateKey | RsaPrivateJwk

| XDH Public Key | XECPublicKey^1^ | OctetPublicJwk

| XDH Private Key | XECPrivateKey^1^ | OctetPrivateJwk

| EdDSA Public Key | EdECPublicKey^2^ | OctetPublicJwk

| EdDSA Private Key | EdECPrivateKey^2^ | OctetPrivateJwk |=== + ^1.{sp}{fn-require-java15-plus}^ + ^2.{sp}{fn-require-java15-plus}^

  • Convenience enhancements beyond the specification such as ** Payload compression for any large JWT, not just JWEs ** Claims assertions (requiring specific values) ** Claim POJO marshaling and unmarshalling when using a compatible JSON parser (e.g. Jackson) ** Secure Key generation based on desired JWA algorithms ** and more...

++++++++++++

=== Currently Unsupported Features

  • https://tools.ietf.org/html/rfc7515#section-7.2[Non-compact] serialization and parsing.

This feature may be implemented in a future release. Community contributions are welcome!

++++++++++++

== Community

++++++++++++

=== Getting Help

If you have trouble using JJWT, please first read the documentation on this page before asking questions. We try very hard to ensure JJWT's documentation is robust, categorized with a table of contents, and up to date for each release.

++++++++++++

==== Questions

If the documentation or the API JavaDoc isn't sufficient, and you either have usability questions or are confused about something, please https://github.com/jwtk/jjwt/discussions/new?category=q-a[ask your question here]. However:

Please do not create a GitHub issue to ask a question.

We use GitHub Issues to track actionable work that requires changes to JJWT's design and/or codebase. If you have a usability question, instead please https://github.com/jwtk/jjwt/discussions/new?category=q-a[ask your question here], and we can convert that to an issue if necessary.

If a GitHub Issue is created that does not represent actionable work for JJWT's codebase, it will be promptly closed.

++++++++++++

==== Bugs, Feature Requests, Ideas and General Discussions

If you do not have a usability question and believe you have a legitimate bug or feature request, please https://github.com/jwtk/jjwt/discussions[discuss it here] FIRST. Please do a quick search first to see if an existing discussion related to yours exist already and join that existing discussion if necesary.

If you feel like you'd like to help fix a bug or implement the new feature yourself, please read the Contributing section next before starting any work.

++++++++++++

=== Contributing

++++++++++++

==== Pull Requests

Simple Pull Requests that fix anything other than JJWT core code (documentation, JavaDoc, typos, test cases, etc) are always appreciated and have a high likelihood of being merged quickly. Please send them!

However, if you want or feel the need to change JJWT's functionality or core code, please do not issue a pull request without https://github.com/jwtk/jjwt/discussions[starting a new JJWT discussion] and discussing your desired changes first, before you start working on it.

It would be a shame to reject your earnest and genuinely-appreciated pull request if it might not align with the project's goals, design expectations or planned functionality. We've sadly had to reject large PRs in the past because they were out of sync with project or design expectations - all because the PR author didn't first check in with the team first before working on a solution.

So, please https://github.com/jwtk/jjwt/discussions[create a new JJWT discussion] first to discuss, and then we can see easily convert the discussion to an issue and then see if (or how) a PR is warranted. Thank you!

++++++++++++

==== Help Wanted

If you would like to help, but don't know where to start, please visit the https://github.com/jwtk/jjwt/labels/help%20wanted[Help Wanted Issues] page and pick any of the ones there, and we'll be happy to discuss and answer questions in the issue comments.

If any of those don't appeal to you, no worries! Any help you would like to offer would be appreciated based on the above caveats concerning <<contributing-pull-requests,contributing pull requests>>. Feel free to https://github.com/jwtk/jjwt/discussions[discuss or ask questions first] if you're not sure. :)

When you're ready to build and test the project locally, see link:CONTRIBUTING.md[CONTRIBUTING.md].

++++++++++++

== What is a JSON Web Token?

JSON Web Token (JWT) is a general-purpose text-based messaging format for transmitting information in a compact and secure way. Contrary to popular belief, JWT is not just useful for sending and receiving identity tokens on the web - even if that is the most common use case. JWTs can be used as messages for any type of data.

A JWT in its simplest form contains two parts:

. The primary data within the JWT, called the payload, and . A JSON Object with name/value pairs that represent metadata about the payload and the message itself, called the header.

A JWT payload can be absolutely anything at all - anything that can be represented as a byte array, such

Issues· 46 open

View all issuesOpen on GitHub
  • #1029

    Adapter for Jackson 3.0

    Updated Sep 10, 2026
  • #1035

    JWE with no "cty" where content accidentally looks like JSON cannot be decrypted with parseEncryptedContent

    Updated Aug 24, 2026
  • #1049

    AndroidKeyStore RSA keys not able to be used for signing

    Updated Aug 24, 2026
  • #1065

    `JacksonSerializer` does not respect `JsonTypeInfo`

    Updated Aug 24, 2026
  • #1042

    RFC 9964: ML-DSA post-quantum signature algorithm

    Updated Aug 24, 2026
  • #1070

    [Javadoc] The javadoc for JwtParser.parse does not specifically guarantee validation of iat and nbf

    Updated Jul 23, 2026
  • #582

    isSigned returns true if normal JSON provided or singed with different key

    Updated Jun 6, 2026
  • #1026

    Support non-blocking keylocators

    enhancementhelp-wantedjdk8Updated Oct 27, 2025
  • #354

    Functional interface cleanup

    jdk8Updated Oct 25, 2025
  • #519

    Enable JDK9+ module-info

    enhancementUpdated Sep 18, 2025

> Tags

Javahacktoberfestjacksonjavajava-jwt

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 28, 2026
Category安全
PricingOpen source

> Related tools

O
OWASP ZAP
开源 Web 应用安全扫描器
O
owasp-wstg-tracker
Simple web app to track OWASP WSTG security testing progress
H
homebridge-mi-gateway-security
XiaoMi Gateway Security plugin for HomeBridge.