public class JsonWebSignature extends JsonWebStructure
| Modifier and Type | Field and Description |
|---|---|
static short |
COMPACT_SERIALIZATION_PARTS |
base64url, doKeyValidation, headers, rawCompactSerialization| Constructor and Description |
|---|
JsonWebSignature() |
| Modifier and Type | Method and Description |
|---|---|
JsonWebSignatureAlgorithm |
getAlgorithm() |
JsonWebSignatureAlgorithm |
getAlgorithmNoConstraintCheck() |
String |
getCompactSerialization()
Sign and produce the JWS Compact Serialization.
|
String |
getDetachedContentCompactSerialization()
Produces the compact serialization with an empty/detached payload as described in
Appendix F, Detached Content, of the JWS spec
though providing library support rather than making the application do it all as
described therein.
|
String |
getEncodedPayload()
Gets the base64url encoded JWS Payload.
|
String |
getEncodedSignature() |
KeyPersuasion |
getKeyPersuasion() |
String |
getKeyType() |
String |
getPayload()
Gets the JWS payload as a string.
|
byte[] |
getPayloadBytes()
Get the JWS payload.
|
String |
getPayloadCharEncoding()
Gets the character encoding used for the string representation of the JWS payload.
|
protected byte[] |
getSignature() |
String |
getUnverifiedPayload()
Gets the JWS payload as a string.
|
byte[] |
getUnverifiedPayloadBytes()
Get the JWS payload.
|
protected boolean |
isRfc7797UnencodedPayload() |
protected boolean |
isSupportedCriticalHeader(String headerName) |
protected void |
onNewKey() |
protected void |
setCompactSerializationParts(String[] parts) |
void |
setEncodedPayload(String encodedPayload) |
void |
setPayload(String payload)
Sets the JWS payload as a string.
|
void |
setPayloadBytes(byte[] payloadBytes)
Sets the JWS payload.
|
void |
setPayloadCharEncoding(String payloadCharEncoding)
Sets the character encoding used for the string representation of the JWS payload (i.e.
|
protected void |
setSignature(byte[] signature) |
void |
sign()
Compute the JWS signature.
|
boolean |
verifySignature()
Verify the signature of the JWS.
|
checkCrit, checkNotEmptyPart, fromCompactSerialization, getAlgorithmConstraints, getAlgorithmHeaderValue, getCertificateChainHeaderValue, getContentTypeHeaderValue, getEncodedHeader, getHeader, getHeader, getHeaders, getIntegrity, getKey, getKeyIdHeaderValue, getLeafCertificateHeaderValue, getProviderCtx, getX509CertSha1ThumbprintHeaderValue, getX509CertSha256ThumbprintHeaderValue, isDoKeyValidation, setAlgorithmConstraints, setAlgorithmHeaderValue, setCertificateChainHeaderValue, setCompactSerialization, setContentTypeHeaderValue, setCriticalHeaderNames, setDoKeyValidation, setEncodedHeader, setHeader, setIntegrity, setKey, setKeyIdHeaderValue, setKnownCriticalHeaders, setProviderContext, setX509CertSha1ThumbprintHeaderValue, setX509CertSha1ThumbprintHeaderValue, setX509CertSha256ThumbprintHeaderValue, setX509CertSha256ThumbprintHeaderValue, toStringpublic static final short COMPACT_SERIALIZATION_PARTS
public void setPayload(String payload)
setPayloadCharEncoding(String) before calling this method, to use a character
encoding other than UTF-8.setPayload in class JsonWebStructurepayload - the payload, as a string, to be singed.public byte[] getPayloadBytes()
throws JoseException
JoseException - if the JWS signature is invalid or an error condition is encountered during the signature verification processpublic byte[] getUnverifiedPayloadBytes()
getPayloadBytes() the signature is not
verified when calling this method.public void setPayloadBytes(byte[] payloadBytes)
payloadBytes - the payload, as a byte array, to be singedprotected void setCompactSerializationParts(String[] parts) throws JoseException
setCompactSerializationParts in class JsonWebStructureJoseExceptionpublic String getCompactSerialization() throws JoseException
Sign and produce the JWS Compact Serialization.
The JWS Compact Serialization represents digitally signed or MACed content as a compact, URL-safe string. This string is:
BASE64URL(UTF8(JWS Protected Header)) || '.' || BASE64URL(JWS Payload) || '.' || BASE64URL(JWS Signature)
getCompactSerialization in class JsonWebStructureJoseExceptionpublic String getDetachedContentCompactSerialization() throws JoseException
JoseException - if an error condition is encountered during the signing processpublic void sign()
throws JoseException
JoseException - if an error condition is encountered during the signing processprotected void onNewKey()
onNewKey in class JsonWebStructurepublic boolean verifySignature()
throws JoseException
JoseException - if an error condition is encountered during the signature verification processprotected boolean isSupportedCriticalHeader(String headerName)
isSupportedCriticalHeader in class JsonWebStructurepublic JsonWebSignatureAlgorithm getAlgorithm() throws InvalidAlgorithmException
getAlgorithm in class JsonWebStructureInvalidAlgorithmExceptionpublic JsonWebSignatureAlgorithm getAlgorithmNoConstraintCheck() throws InvalidAlgorithmException
getAlgorithmNoConstraintCheck in class JsonWebStructureInvalidAlgorithmExceptionprotected boolean isRfc7797UnencodedPayload()
public String getPayload() throws JoseException
setPayloadCharEncoding(String) before calling this method, to use a character
encoding other than UTF-8.getPayload in class JsonWebStructureJoseException - if the JWS signature is invalid or an error condition is encountered during the signature verification processpublic String getUnverifiedPayload()
getPayload() the signature is not
verified when calling this method.
Use setPayloadCharEncoding(String) before calling this method, to use a character
encoding other than UTF-8.public String getPayloadCharEncoding()
public void setPayloadCharEncoding(String payloadCharEncoding)
getPayload(), getUnverifiedPayload(), or setPayload(String)).
The default encoding is UTF-8.payloadCharEncoding - the character encoding to use for the string representation of the JWS payloadpublic String getKeyType() throws InvalidAlgorithmException
InvalidAlgorithmExceptionpublic KeyPersuasion getKeyPersuasion() throws InvalidAlgorithmException
InvalidAlgorithmExceptionpublic void setEncodedPayload(String encodedPayload)
public String getEncodedPayload()
public String getEncodedSignature()
protected byte[] getSignature()
protected void setSignature(byte[] signature)
Copyright © 2018. All rights reserved.