|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.nimbusds.jose.JOSEObject com.nimbusds.jose.JWSObject
@ThreadSafe public class JWSObject
JSON Web Signature (JWS) object. This class is thread-safe.
Nested Class Summary | |
---|---|
static class |
JWSObject.State
Enumeration of the states of a JSON Web Signature (JWS) object. |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
ReadOnlyJWSHeader |
getHeader()
Gets the header of this JOSE object. |
byte[] |
getSignableContent()
Gets the signable content of this JWS object. |
Base64URL |
getSignature()
Gets the signature of this JWS object. |
JWSObject.State |
getState()
Gets 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. |
Methods inherited from class com.nimbusds.jose.JOSEObject |
---|
getParsedParts, getParsedString, getPayload, setParsedParts, setPayload, split |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public 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.Method Detail |
---|
public ReadOnlyJWSHeader getHeader()
JOSEObject
getHeader
in class JOSEObject
public byte[] getSignableContent()
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 JOSEObject
IllegalStateException
- 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |