Package com.nimbusds.jose
Class JWSObjectJSON
java.lang.Object
com.nimbusds.jose.JOSEObjectJSON
com.nimbusds.jose.JWSObjectJSON
- All Implemented Interfaces:
Serializable
JSON Web Signature (JWS) secured object with
JSON
serialisation.
This class is thread-safe.
- Version:
- 2024-04-20
- Author:
- Alexander Martynov, Vladimir Dzhuvinov
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Individual signature in a JWS secured object serialisable to JSON.static enum
Enumeration of the states of a JSON Web Signature (JWS) secured object serialisable to JSON. -
Field Summary
Fields inherited from class com.nimbusds.jose.JOSEObjectJSON
MIME_TYPE_JOSE_JSON
-
Constructor Summary
ConstructorsConstructorDescriptionJWSObjectJSON
(Payload payload) Creates a new to-be-signed JSON Web Signature (JWS) secured object with the specified payload. -
Method Summary
Modifier and TypeMethodDescriptionReturns the individual signatures.getState()
Returns the current signatures state.static JWSObjectJSON
Parses a JWS secured object from the specified JSON object string.static JWSObjectJSON
Parses a JWS secured object from the specified JSON object representation.Serialises this JOSE object to a flattened JSON object string.Serialises this JOSE object to a general JOSE object string.void
Signs this JWS secured object with the specified JWS signer and adds the resulting signature to it.void
sign
(JWSHeader jwsHeader, UnprotectedHeader unprotectedHeader, JWSSigner signer) Signs this JWS secured object with the specified JWS signer and adds the resulting signature to it.Returns a flattened JSON object representation of this JOSE secured object.Returns a general JSON object representation of this JOSE secured object.Methods inherited from class com.nimbusds.jose.JOSEObjectJSON
getPayload, setPayload
-
Constructor Details
-
JWSObjectJSON
Creates a new to-be-signed JSON Web Signature (JWS) secured object with the specified payload.- Parameters:
payload
- The payload. Must not benull
.
-
-
Method Details
-
getSignatures
Returns the individual signatures.- Returns:
- The individual signatures, as an unmodified list, empty list if none have been added.
-
sign
Signs this JWS secured object with the specified JWS signer and adds the resulting signature to it. To add multiplesignatures
call this method successively.- Parameters:
jwsHeader
- The JWS protected header. The algorithm specified by the header must be supported by the JWS signer. Must not benull
.signer
- The JWS signer. Must not benull
.- Throws:
JOSEException
- If the JWS object couldn't be signed.
-
sign
public void sign(JWSHeader jwsHeader, UnprotectedHeader unprotectedHeader, JWSSigner signer) throws JOSEException Signs this JWS secured object with the specified JWS signer and adds the resulting signature to it. To add multiplesignatures
call this method successively.- Parameters:
jwsHeader
- The JWS protected header. The algorithm specified by the header must be supported by the JWS signer. Must not benull
.unprotectedHeader
- The unprotected header to include,null
if none.signer
- The JWS signer. Must not benull
.- Throws:
JOSEException
- If the JWS object couldn't be signed.
-
getState
Returns the current signatures state.- Returns:
- The state.
-
toGeneralJSONObject
Description copied from class:JOSEObjectJSON
Returns a general JSON object representation of this JOSE secured object.- Specified by:
toGeneralJSONObject
in classJOSEObjectJSON
- Returns:
- The JSON object.
-
toFlattenedJSONObject
Description copied from class:JOSEObjectJSON
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.
- Specified by:
toFlattenedJSONObject
in classJOSEObjectJSON
- Returns:
- The JSON object.
-
serializeGeneral
Description copied from class:JOSEObjectJSON
Serialises this JOSE object to a general JOSE object string.- Specified by:
serializeGeneral
in classJOSEObjectJSON
- Returns:
- The JSON object string.
-
serializeFlattened
Description copied from class:JOSEObjectJSON
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.
- Specified by:
serializeFlattened
in classJOSEObjectJSON
- Returns:
- The JSON object string.
-
parse
Parses a JWS secured object from the specified JSON object representation.- Parameters:
jsonObject
- The JSON object to parse. Must not benull
.- Returns:
- The JWS secured object.
- Throws:
ParseException
- If the JSON object couldn't be parsed to a JWS secured object.
-
parse
Parses a JWS secured object from the specified JSON object string.- Parameters:
json
- The JSON object string to parse. Must not benull
.- Returns:
- The JWS secured object.
- Throws:
ParseException
- If the string couldn't be parsed to a JWS secured object.
-