@ThreadSafe public class JWEObject extends JOSEObject
Modifier and Type | Class and Description |
---|---|
static class |
JWEObject.State
Enumeration of the states of a JSON Web Encryption (JWE) object.
|
MIME_TYPE_COMPACT, MIME_TYPE_JS
Constructor and Description |
---|
JWEObject(Base64URL firstPart,
Base64URL secondPart,
Base64URL thirdPart,
Base64URL fourthPart,
Base64URL fifthPart)
Creates a new encrypted JSON Web Encryption (JWE) object with the
specified serialised parts.
|
JWEObject(JWEHeader header,
Payload payload)
Creates a new to-be-encrypted JSON Web Encryption (JWE) object with
the specified header and payload.
|
Modifier and Type | Method and Description |
---|---|
void |
decrypt(JWEDecrypter decrypter)
Decrypts this JWE object with the specified decrypter.
|
void |
encrypt(JWEEncrypter encrypter)
Encrypts this JWE object with the specified encrypter.
|
Base64URL |
getAuthTag()
Returns the authentication tag of this JWE object.
|
Base64URL |
getCipherText()
Returns the cipher text of this JWE object.
|
Base64URL |
getEncryptedKey()
Returns the encrypted key of this JWE object.
|
JWEHeader |
getHeader()
Returns the header of this JOSE object.
|
Base64URL |
getIV()
Returns the initialisation vector (IV) of this JWE object.
|
JWEObject.State |
getState()
Returns the state of this JWE object.
|
static JWEObject |
parse(String s)
Parses a JWE object from the specified string in compact form.
|
String |
serialize()
Serialises this JWE object to its compact format consisting of
Base64URL-encoded parts delimited by period ('.') characters.
|
getParsedParts, getParsedString, getPayload, setParsedParts, setPayload, split
public JWEObject(JWEHeader header, Payload payload)
unencrypted
.header
- The JWE header. Must not be null
.payload
- The payload. Must not be null
.public JWEObject(Base64URL firstPart, Base64URL secondPart, Base64URL thirdPart, Base64URL fourthPart, Base64URL fifthPart) throws ParseException
encrypted
.firstPart
- The first part, corresponding to the JWE header.
Must not be null
.secondPart
- The second part, corresponding to the encrypted
key. Empty or null
if none.thirdPart
- The third part, corresponding to the
initialisation vector. Empty or null
if
none.fourthPart
- The fourth part, corresponding to the cipher text.
Must not be null
.fifthPart
- The fifth part, corresponding to the
authentication tag. Empty of null
if none.ParseException
- If parsing of the serialised parts failed.public JWEHeader getHeader()
JOSEObject
getHeader
in class JOSEObject
public Base64URL getEncryptedKey()
null
not applicable or the JWE
object has not been encrypted yet.public Base64URL getIV()
null
if not
applicable or the JWE object has not been encrypted yet.public Base64URL getCipherText()
null
if the JWE object has not been
encrypted yet.public Base64URL getAuthTag()
null
if not applicable or
the JWE object has not been encrypted yet.public JWEObject.State getState()
public void encrypt(JWEEncrypter encrypter) throws JOSEException
unencrypted
state.encrypter
- The JWE encrypter. Must not be null
.IllegalStateException
- If the JWE object is not in an
unencrypted
state
.JOSEException
- If the JWE object couldn't be
encrypted.public void decrypt(JWEDecrypter decrypter) throws JOSEException
encrypted
state.decrypter
- The JWE decrypter. Must not be null
.IllegalStateException
- If the JWE object is not in an
encrypted
state
.JOSEException
- If the JWE object couldn't be
decrypted.public String serialize()
encrypted
or
decrypted
state.
[header-base64url].[encryptedKey-base64url].[iv-base64url].[cipherText-base64url].[authTag-base64url]
serialize
in class JOSEObject
IllegalStateException
- If the JWE object is not in a
encrypted
or
decrypted
state
.public static JWEObject parse(String s) throws ParseException
JWEObject.State.ENCRYPTED
state.s
- The string to parse. Must not be null
.ParseException
- If the string couldn't be parsed to a valid
JWE object.Copyright © 2017 Connect2id Ltd.. All rights reserved.