Class JjwtClientAssertionProvider
java.lang.Object
org.cibseven.bpm.client.interceptor.auth.JjwtClientAssertionProvider
- All Implemented Interfaces:
ClientAssertionProvider
Creates signed client assertion JWTs using the JJWT library.
The generated assertion conforms to RFC 7523 and can be used with
OAuth2ClientCredentialsProvider for private_key_jwt client
authentication.
Each call to getAssertion() produces a fresh JWT (new jti,
iat, and exp). The actual access token is cached by
OAuth2ClientCredentialsProvider; the assertion itself is intentionally
short-lived (5 minutes) and regenerated only when a new token is needed.
Supported algorithms (auto-detected from key type):
RS256– RSA with SHA-256 (RSAPrivateKey, most widely supported)ES256– ECDSA with P-256 and SHA-256 (ECPrivateKey on P-256 curve)
Requires io.jsonwebtoken:jjwt-api at compile time and
io.jsonwebtoken:jjwt-impl at runtime.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final longJWT lifetime in milliseconds (5 minutes).protected final Stringprotected final Stringprotected final PrivateKey -
Constructor Summary
ConstructorsConstructorDescriptionJjwtClientAssertionProvider(String clientId, String audience, PrivateKey privateKey) Creates a provider that signs assertions with any supported private key. -
Method Summary
Modifier and TypeMethodDescriptionGenerates and returns a freshly signed client assertion JWT.
-
Field Details
-
ASSERTION_LIFETIME_MS
protected static final long ASSERTION_LIFETIME_MSJWT lifetime in milliseconds (5 minutes).- See Also:
-
clientId
-
audience
-
privateKey
-
-
Constructor Details
-
JjwtClientAssertionProvider
Creates a provider that signs assertions with any supported private key. JJWT auto-detects the algorithm based on key type (RS256 for RSA, ES256 for EC P-256).- Parameters:
clientId- the OAuth2client_id— used as bothissandsubclaimsaudience- the token endpoint URI — used as theaudclaimprivateKey- the private key used for signing
-
-
Method Details
-
getAssertion
Generates and returns a freshly signed client assertion JWT. JJWT automatically selects RS256 for RSAPrivateKey and ES256 for ECPrivateKey (P-256).- Specified by:
getAssertionin interfaceClientAssertionProvider- Returns:
- serialized signed JWT string
- Throws:
ExternalTaskClientException- if signing fails
-