Package ch.admin.bj.swiyu.sdjwtvalidator
Class SdJwtParser
java.lang.Object
ch.admin.bj.swiyu.sdjwtvalidator.SdJwtParser
Parses the compact serialization format of an SD-JWT.
An SD-JWT has the following structure (RFC 9901 ยง4):
<Issuer-signed JWT>~<Disclosure 1>~...~<Disclosure N>~The trailing
~ after the last Disclosure is mandatory.-
Method Summary
Modifier and TypeMethodDescriptionstatic StringdecodeDisclosure(String disclosure) Decodes a single base64url-encoded Disclosure into its raw JSON string.extractDisclosures(String sdJwt) Extracts all Disclosure strings from the SD-JWT.static StringextractIssuerSignedJwt(String sdJwt) Extracts the Issuer-Signed JWT (the first segment before the first~).
-
Method Details
-
extractIssuerSignedJwt
Extracts the Issuer-Signed JWT (the first segment before the first~).- Parameters:
sdJwt- the full SD-JWT string; must not benullor blank- Returns:
- the compact serialized Issuer-Signed JWT
- Throws:
JwtValidatorException- if the input is null, blank, or does not contain~
-
extractDisclosures
Extracts all Disclosure strings from the SD-JWT.Disclosures are the
~-separated segments between the Issuer-Signed JWT. Empty segments are excluded.- Parameters:
sdJwt- the full SD-JWT string; must not benullor blank- Returns:
- an immutable list of base64url-encoded Disclosure strings (may be empty)
-
decodeDisclosure
Decodes a single base64url-encoded Disclosure into its raw JSON string.- Parameters:
disclosure- the base64url-encoded Disclosure segment- Returns:
- the decoded JSON string (e.g.
["salt","given_name","Max"]) - Throws:
JwtValidatorException- if decoding fails
-