@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(JWSHeader 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 |
|---|---|
JWSHeader |
getHeader()
Returns the header of this JOSE object.
|
Base64URL |
getSignature()
Returns the signature of this JWS object.
|
byte[] |
getSigningInput()
Returns the signing input for this JWS object.
|
JWSObject.State |
getState()
Returns the state of this JWS object.
|
static JWSObject |
parse(String s)
Parses a JWS object from the specified string in compact format.
|
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(JWSHeader 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 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.ParseException - If parsing of the serialised parts failed.public JWSHeader getHeader()
JOSEObjectgetHeader in class JOSEObjectpublic byte[] getSigningInput()
Format:
[header-base64url].[payload-base64url]
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.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.IllegalStateException - If the JWS object is not in a
signed or
verified state.JOSEException - If the JWS object couldn't be
verified.public String serialize()
signed or
verified state.
[header-base64url].[payload-base64url].[signature-base64url]
serialize in class JOSEObjectIllegalStateException - If the JWS object is not in a
signed or
verified state.public static JWSObject parse(String s) throws ParseException
JWSObject.State.SIGNED state.s - The string to parse. Must not be null.ParseException - If the string couldn't be parsed to a valid
JWS object.Copyright © 2015 Connect2id Ltd.. All Rights Reserved.