Package com.nimbusds.jwt
Class EncryptedJWT
java.lang.Object
com.nimbusds.jose.JOSEObject
com.nimbusds.jose.JWEObject
com.nimbusds.jwt.EncryptedJWT
- All Implemented Interfaces:
JWT
,Serializable
Encrypted JSON Web Token (JWT). This class is thread-safe.
- Version:
- 2021-02-22
- Author:
- Vladimir Dzhuvinov
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.nimbusds.jose.JWEObject
JWEObject.State
-
Field Summary
Fields inherited from class com.nimbusds.jose.JWEObject
MAX_COMPRESSED_CIPHER_TEXT_LENGTH
Fields inherited from class com.nimbusds.jose.JOSEObject
MIME_TYPE_COMPACT, MIME_TYPE_JS
-
Constructor Summary
ConstructorDescriptionEncryptedJWT
(JWEHeader header, JWTClaimsSet claimsSet) Creates a new to-be-encrypted JSON Web Token (JWT) with the specified header and claims set.EncryptedJWT
(Base64URL firstPart, Base64URL secondPart, Base64URL thirdPart, Base64URL fourthPart, Base64URL fifthPart) Creates a new encrypted JSON Web Token (JWT) with the specified serialised parts. -
Method Summary
Modifier and TypeMethodDescriptionGets the claims set of the JSON Web Token (JWT).static EncryptedJWT
Parses an encrypted JSON Web Token (JWT) from the specified string in compact format.protected void
setPayload
(Payload payload) Sets the payload of this JOSE object.Methods inherited from class com.nimbusds.jose.JWEObject
decrypt, encrypt, getAuthTag, getCipherText, getEncryptedKey, getHeader, getIV, getState, serialize
Methods inherited from class com.nimbusds.jose.JOSEObject
getParsedParts, getParsedString, getPayload, setParsedParts, split
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.nimbusds.jwt.JWT
getHeader, getParsedParts, getParsedString, serialize
-
Constructor Details
-
EncryptedJWT
Creates a new to-be-encrypted JSON Web Token (JWT) with the specified header and claims set. The initial state will beunencrypted
.- Parameters:
header
- The JWE header. Must not benull
.claimsSet
- The JWT claims set. Must not benull
.
-
EncryptedJWT
public EncryptedJWT(Base64URL firstPart, Base64URL secondPart, Base64URL thirdPart, Base64URL fourthPart, Base64URL fifthPart) throws ParseException Creates a new encrypted JSON Web Token (JWT) with the specified serialised parts. The state will beencrypted
.- Parameters:
firstPart
- The first part, corresponding to the JWE header. Must not benull
.secondPart
- The second part, corresponding to the encrypted key. Empty ornull
if none.thirdPart
- The third part, corresponding to the initialisation vectory. Empty ornull
if none.fourthPart
- The fourth part, corresponding to the cipher text. Must not benull
.fifthPart
- The fifth part, corresponding to the integrity value. Empty ofnull
if none.- Throws:
ParseException
- If parsing of the serialised parts failed.
-
-
Method Details
-
getJWTClaimsSet
Description copied from interface:JWT
Gets the claims set of the JSON Web Token (JWT).- Specified by:
getJWTClaimsSet
in interfaceJWT
- Returns:
- The claims set,
null
if not available (for an encrypted JWT that isn't decrypted). - Throws:
ParseException
- If the payload of the JWT doesn't represent a valid JSON object and a JWT claims set.
-
setPayload
Description copied from class:JOSEObject
Sets the payload of this JOSE object.- Overrides:
setPayload
in classJOSEObject
- Parameters:
payload
- The payload,null
if not available (e.g. for an encrypted JWE object).
-
parse
Parses an encrypted JSON Web Token (JWT) from the specified string in compact format.- Parameters:
s
- The string to parse. Must not benull
.- Returns:
- The encrypted JWT.
- Throws:
ParseException
- If the string couldn't be parsed to a valid encrypted JWT.
-