@ThreadSafe public class JWSObject extends JOSEObject
| Modifier and Type | Class and Description |
|---|---|
static class |
JWSObject.State
Enumeration of the states of a JSON Web Signature (JWS) object.
|
MIME_TYPE_COMPACT, MIME_TYPE_JS| Constructor and Description |
|---|
JWSObject(Base64URL firstPart,
Base64URL secondPart,
Base64URL thirdPart)
Creates a new signed JSON Web Signature (JWS) object with the
specified serialised parts.
|
JWSObject(ReadOnlyJWSHeader header,
Payload payload)
Creates a new to-be-signed JSON Web Signature (JWS) object with the
specified header and payload.
|
| Modifier and Type | Method and Description |
|---|---|
ReadOnlyJWSHeader |
getHeader()
Gets the header of this JOSE object.
|
byte[] |
getSignableContent()
Deprecated.
Use
getSigningInput() instead. |
Base64URL |
getSignature()
Gets the signature of this JWS object.
|
byte[] |
getSigningInput()
Gets the signing input for this JWS object.
|
JWSObject.State |
getState()
Gets the state of this JWS object.
|
static JWSObject |
parse(java.lang.String s)
Parses a JWS object from the specified string in compact format.
|
java.lang.String |
serialize()
Serialises this JWS object to its compact format consisting of
Base64URL-encoded parts delimited by period ('.') characters.
|
void |
sign(JWSSigner signer)
Signs this JWS object with the specified signer.
|
boolean |
verify(JWSVerifier verifier)
Checks the signature of this JWS object with the specified verifier.
|
getParsedParts, getParsedString, getPayload, setParsedParts, setPayload, splitpublic JWSObject(ReadOnlyJWSHeader header, Payload payload)
unsigned.header - The JWS header. Must not be null.payload - The payload. Must not be null.public JWSObject(Base64URL firstPart, Base64URL secondPart, Base64URL thirdPart) throws java.text.ParseException
signed.firstPart - The first part, corresponding to the JWS header.
Must not be null.secondPart - The second part, corresponding to the payload. Must
not be null.thirdPart - The third part, corresponding to the signature.
Must not be null.java.text.ParseException - If parsing of the serialised parts failed.public ReadOnlyJWSHeader getHeader()
JOSEObjectgetHeader in class JOSEObjectpublic byte[] getSigningInput()
Format:
[header-base64url].[payload-base64url]
@Deprecated public byte[] getSignableContent()
getSigningInput() instead.public Base64URL getSignature()
null if the JWS object is not signed
yet.public JWSObject.State getState()
public void sign(JWSSigner signer) throws JOSEException
unsigned state.signer - The JWS signer. Must not be null.java.lang.IllegalStateException - If the JWS object is not in an
unsigned state.JOSEException - If the JWS object couldn't be signed.public boolean verify(JWSVerifier verifier) throws JOSEException
signed state.verifier - The JWS verifier. Must not be null.true if the signature was successfully verified,
else false.java.lang.IllegalStateException - If the JWS object is not in a
signed or
verified state.JOSEException - If the JWS object couldn't be verified.public java.lang.String serialize()
signed or
verified state.
[header-base64url].[payload-base64url].[signature-base64url]
serialize in class JOSEObjectjava.lang.IllegalStateException - If the JWS object is not in a
signed or
verified state.public static JWSObject parse(java.lang.String s) throws java.text.ParseException
JWSObject.State.SIGNED state.s - The string to parse. Must not be null.java.text.ParseException - If the string couldn't be parsed to a valid
JWS object.Copyright © 2014 Connect2id Ltd.. All Rights Reserved.