Nimbus is an open-source Java library for standards-based cryptographic and authentication protocols, including JOSE, JWS, and JWE. It supports Java services and Spring Security integrations for OIDC and OAuth2 logins. section 11.4.2 section 11.5.2
Use Nimbus to:
- Create and verify signed JWS objects with headers, payloads, and HS256 shared-secret signatures. section 11.4.2
- Encrypt and decrypt JWE payloads with AES-GCM while the library handles initialization vectors and serialization metadata. section 11.5.2
- Keep secrets out of source code and properties files; hardcoded keys simplify demonstrations but are unsafe in production. section 11.4.2
Signing and encrypting JSON
A Java service can construct a JWSObject with a JSON payload, sign it using MACSigner, and verify it with MACVerifier. For confidentiality, JWEObject with DirectEncrypter and DirectDecrypter provides a compact AES-GCM workflow. section 11.4.2 section 11.5.2
<dependency> <groupId>com.nimbusds</groupId> <artifactId>nimbus-jose-jwt</artifactId> <version>9.37.3</version> </dependency>
Use the Maven dependency declaration to add Nimbus JOSE JWT to a Java project. section 11.4.2
