Package com.nimbusds.jose
Class JOSEObjectJSON
java.lang.Object
com.nimbusds.jose.JOSEObjectJSON
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
JWEObjectJSON
,JWSObjectJSON
The base abstract class for JSON Web Signature (JWS) secured and JSON Web
Encryption (JWE) secured objects serialisable to JSON.
- Version:
- 2021-10-05
- Author:
- Vladimir Dzhuvinov
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The MIME type of JOSE objects serialised to JSON:application/jose+json; charset=UTF-8
-
Constructor Summary
ModifierConstructorDescriptionprotected
JOSEObjectJSON
(Payload payload) Creates a new JOSE object with the specified payload. -
Method Summary
Modifier and TypeMethodDescriptionReturns the payload of this JOSE object.static JOSEObjectJSON
Parses a JOSE secured object from the specified JSON string.static JOSEObjectJSON
Parses a JOSE secured object from the specified JSON object representation.abstract String
Serialises this JOSE object to a flattened JSON object string.abstract String
Serialises this JOSE object to a general JOSE object string.protected void
setPayload
(Payload payload) Sets the payload of this JOSE object.Returns a flattened JSON object representation of this JOSE secured object.Returns a general JSON object representation of this JOSE secured object.
-
Field Details
-
MIME_TYPE_JOSE_JSON
The MIME type of JOSE objects serialised to JSON:application/jose+json; charset=UTF-8
- See Also:
-
-
Constructor Details
-
JOSEObjectJSON
Creates a new JOSE object with the specified payload.- Parameters:
payload
- The payload,null
if not available (e.g. for an encrypted JWE object).
-
-
Method Details
-
setPayload
Sets the payload of this JOSE object.- Parameters:
payload
- The payload,null
if not available (e.g. for an encrypted JWE object).
-
getPayload
Returns the payload of this JOSE object.- Returns:
- The payload,
null
if not available (for an encrypted JWE object that hasn't been decrypted).
-
toGeneralJSONObject
Returns a general JSON object representation of this JOSE secured object.- Returns:
- The JSON object.
- Throws:
IllegalStateException
- If the JOSE object is not in a state that permits serialisation.
-
toFlattenedJSONObject
Returns a flattened JSON object representation of this JOSE secured object. There must be exactly one JWS signature or JWE recipient for a flattened JSON serialisation.See JWS flattened serialisation or JWE flattened serialisation.
- Returns:
- The JSON object.
- Throws:
IllegalStateException
- If the JOSE object is not in a state that permits serialisation or there is more than one JWS signature or JWE recipient.
-
serializeGeneral
Serialises this JOSE object to a general JOSE object string.- Returns:
- The JSON object string.
- Throws:
IllegalStateException
- If the JOSE object is not in a state that permits serialisation.
-
serializeFlattened
Serialises this JOSE object to a flattened JSON object string. There must be exactly one JWS signature or JWE recipient for a flattened JSON serialisation.See JWS flattened serialisation or JWE flattened serialisation.
- Returns:
- The JSON object string.
- Throws:
IllegalStateException
- If the JOSE object is not in a state that permits serialisation or there is more than one JWS signature or JWE recipient.
-
parse
Parses a JOSE secured object from the specified JSON object representation.- Parameters:
jsonObject
- The JSON object to parse. Must not benull
.- Returns:
- The corresponding
JWSObjectJSON
. - Throws:
ParseException
- If the JSON object couldn't be parsed to a valid JWS or JWE secured object.
-
parse
Parses a JOSE secured object from the specified JSON string.- Parameters:
json
- The JSON string to parse. Must not benull
.- Returns:
- The corresponding
JWSObjectJSON
. - Throws:
ParseException
- If the string couldn't be parsed to a valid JWS or JWE secured object.
-