Class AnkaJoseUtil
This class exists because ANKASecure exposes only General JSON Serialization on its REST API. Clients that receive a Compact JOSE payload from a third-party producer (Nimbus JOSE+JWT, jose4j, python-jose, an OAuth issuer, etc.) MUST convert it to General JSON before invoking ANKA's decrypt/verify/reencrypt endpoints. Conversely, clients that wish to feed an ANKA-produced JOSE artefact to a Compact-only consumer (typical JWT-side tooling) MUST convert the other direction.
Stateless, thread-safe: the ObjectMapper is
private static final and no other state is held. No I/O. No HTTP.
No dependency on the ANKA server. Safe to call from any thread without
synchronization.
Multi-recipient / multi-signature rejection: General JSON
supports multi-recipient JWE and multi-signature JWS; Compact does not
(RFC 7516 §7.1 / RFC 7515 §7.1 are single-recipient/single-signature only).
Attempting to convert a multi-recipient/multi-signature General JSON to
Compact throws IllegalArgumentException with a descriptive message
— the helper NEVER silently drops recipients or signatures.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcompactJweToGeneral(String compactJwe) Converts a Compact JWE (5 dot-separated base64url segments) into the General JSON Serialization form as a JSON string.static StringcompactJwsToGeneral(String compactJws) Converts a Compact JWS (3 dot-separated base64url segments) into the General JSON Serialization form as a JSON string.static StringgeneralJweToCompact(String generalJsonJwe) Converts a General JSON Serialization JWE (as a JSON string) into the Compact Serialization (5 dot-separated segments).static StringgeneralJwsToCompact(String generalJsonJws) Converts a General JSON Serialization JWS (as a JSON string) into the Compact Serialization (3 dot-separated segments).
-
Method Details
-
compactJweToGeneral
Converts a Compact JWE (5 dot-separated base64url segments) into the General JSON Serialization form as a JSON string.- Throws:
IllegalArgumentException- if the input has the wrong segment count
-
generalJweToCompact
Converts a General JSON Serialization JWE (as a JSON string) into the Compact Serialization (5 dot-separated segments).- Throws:
IllegalArgumentException- if the General JSON has more than one recipient (multi-recipient cannot be represented in Compact form — RFC 7516 §7.1 is single-recipient only)
-
compactJwsToGeneral
Converts a Compact JWS (3 dot-separated base64url segments) into the General JSON Serialization form as a JSON string. -
generalJwsToCompact
Converts a General JSON Serialization JWS (as a JSON string) into the Compact Serialization (3 dot-separated segments).- Throws:
IllegalArgumentException- if the General JSON has more than one signature
-