com.nimbusds.jose
Class JWEObject

java.lang.Object
  extended by com.nimbusds.jose.JOSEObject
      extended by com.nimbusds.jose.JWEObject
Direct Known Subclasses:
EncryptedJWT

@ThreadSafe
public class JWEObject
extends JOSEObject

JSON Web Encryption (JWE) object. This class is thread-safe.

Version:
$version$ (2013-05-05)
Author:
Vladimir Dzhuvinov

Nested Class Summary
static class JWEObject.State
          Enumeration of the states of a JSON Web Encryption (JWE) object.
 
Field Summary
static javax.mail.internet.ContentType MIME_TYPE_COMPACT
          The MIME type of JWE objects serialised to a compact form: application/jwe; charset=UTF-8
static javax.mail.internet.ContentType MIME_TYPE_JS
          The MIME type of JWE objects serialised to a JSON object form: application/jwe-js; charset=UTF-8
 
Constructor Summary
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.
 
Method Summary
 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 getAuthenticationTag()
          Gets the authentication tag of this JWE object.
 Base64URL getCipherText()
          Gets the cipher text of this JWE object.
 Base64URL getEncryptedKey()
          Gets the encrypted key of this JWE object.
 ReadOnlyJWEHeader getHeader()
          Gets the header of this JOSE object.
 Base64URL getInitializationVector()
          Gets the initialisation vector (IV) of this JWE object.
 Base64URL getIntegrityValue()
          Deprecated. 
 JWEObject.State getState()
          Gets 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.
 
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
 

Field Detail

MIME_TYPE_COMPACT

public static final javax.mail.internet.ContentType MIME_TYPE_COMPACT
The MIME type of JWE objects serialised to a compact form: application/jwe; charset=UTF-8


MIME_TYPE_JS

public static final javax.mail.internet.ContentType MIME_TYPE_JS
The MIME type of JWE objects serialised to a JSON object form: application/jwe-js; charset=UTF-8

Constructor Detail

JWEObject

public JWEObject(JWEHeader header,
                 Payload payload)
Creates a new to-be-encrypted JSON Web Encryption (JWE) object with the specified header and payload. The initial state will be unencrypted.

Parameters:
header - The JWE header. Must not be null.
payload - The payload. Must not be null.

JWEObject

public JWEObject(Base64URL firstPart,
                 Base64URL secondPart,
                 Base64URL thirdPart,
                 Base64URL fourthPart,
                 Base64URL fifthPart)
          throws ParseException
Creates a new encrypted JSON Web Encryption (JWE) object with the specified serialised parts. The state will be encrypted.

Parameters:
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.
Throws:
ParseException - If parsing of the serialised parts failed.
Method Detail

getHeader

public ReadOnlyJWEHeader getHeader()
Description copied from class: JOSEObject
Gets the header of this JOSE object.

Specified by:
getHeader in class JOSEObject
Returns:
The header.

getEncryptedKey

public Base64URL getEncryptedKey()
Gets the encrypted key of this JWE object.

Returns:
The encrypted key, null not applicable or the JWE object has not been encrypted yet.

getInitializationVector

public Base64URL getInitializationVector()
Gets the initialisation vector (IV) of this JWE object.

Returns:
The initialisation vector (IV), null if not applicable or the JWE object has not been encrypted yet.

getCipherText

public Base64URL getCipherText()
Gets the cipher text of this JWE object.

Returns:
The cipher text, null if the JWE object has not been encrypted yet.

getAuthenticationTag

public Base64URL getAuthenticationTag()
Gets the authentication tag of this JWE object.

Returns:
The authentication tag, null if not applicable or the JWE object has not been encrypted yet.

getIntegrityValue

@Deprecated
public Base64URL getIntegrityValue()
Deprecated. 

Use getAuthenticationTag() instead.


getState

public JWEObject.State getState()
Gets the state of this JWE object.

Returns:
The state.

encrypt

public void encrypt(JWEEncrypter encrypter)
             throws JOSEException
Encrypts this JWE object with the specified encrypter. The JWE object must be in an unencrypted state.

Parameters:
encrypter - The JWE encrypter. Must not be null.
Throws:
IllegalStateException - If the JWE object is not in an unencrypted state.
JOSEException - If the JWE object couldn't be encrypted.

decrypt

public void decrypt(JWEDecrypter decrypter)
             throws JOSEException
Decrypts this JWE object with the specified decrypter. The JWE object must be in a encrypted state.

Parameters:
decrypter - The JWE decrypter. Must not be null.
Throws:
IllegalStateException - If the JWE object is not in an encrypted state.
JOSEException - If the JWE object couldn't be decrypted.

serialize

public String serialize()
Serialises this JWE object to its compact format consisting of Base64URL-encoded parts delimited by period ('.') characters. It must be in a encrypted or decrypted state.
 [header-base64url].[encryptedKey-base64url].[iv-base64url].[cipherText-base64url].[authTag-base64url]
 

Specified by:
serialize in class JOSEObject
Returns:
The serialised JWE object.
Throws:
IllegalStateException - If the JWE object is not in a encrypted or decrypted state.

parse

public static JWEObject parse(String s)
                       throws ParseException
Parses a JWE object from the specified string in compact form. The parsed JWE object will be given an JWEObject.State.ENCRYPTED state.

Parameters:
s - The string to parse. Must not be null.
Returns:
The JWE object.
Throws:
ParseException - If the string couldn't be parsed to a valid JWE object.


Copyright © 2013 NimbusDS. All Rights Reserved.