com.nimbusds.jose
Class Payload

java.lang.Object
  extended by com.nimbusds.jose.Payload

@Immutable
public class Payload
extends java.lang.Object

Payload with JSON object, string, byte array and Base64URL views. Represents the original object that was signed with JWS or encrypted with JWE. This class is immutable.

Non-initial views are created on demand to conserve resources.

UTF-8 is the character set for all string from / to byte array conversions.

Conversion relations:

 JSONObject <=> String <=> Base64URL
                       <=> byte[]
 

Version:
$version$ (2012-10-23)
Author:
Vladimir Dzhuvinov

Nested Class Summary
static class Payload.Origin
          Enumeration of the original data types used to create a Payload.
 
Constructor Summary
Payload(Base64URL base64URL)
          Creates a new payload from the specified Base64URL-encoded object.
Payload(byte[] bytes)
          Creates a new payload from the specified byte array.
Payload(net.minidev.json.JSONObject json)
          Creates a new payload from the specified JSON object.
Payload(java.lang.String string)
          Creates a new payload from the specified string.
 
Method Summary
 Payload.Origin getOrigin()
          Gets the original data type used to create this payload.
 Base64URL toBase64URL()
          Returns a Base64URL view of this payload.
 byte[] toBytes()
          Returns a byte array view of this payload.
 net.minidev.json.JSONObject toJSONObject()
          Returns a JSON object view of this payload.
 java.lang.String toString()
          Returns a string view of this payload.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Payload

public Payload(net.minidev.json.JSONObject json)
Creates a new payload from the specified JSON object.

Parameters:
json - The JSON object representing the payload. Must not be null.

Payload

public Payload(java.lang.String string)
Creates a new payload from the specified string.

Parameters:
string - The string representing the payload. Must not be null.

Payload

public Payload(byte[] bytes)
Creates a new payload from the specified byte array.

Parameters:
bytes - The byte array representing the payload. Must not be null.

Payload

public Payload(Base64URL base64URL)
Creates a new payload from the specified Base64URL-encoded object.

Parameters:
base64URL - The Base64URL-encoded object representing the payload. Must not be null.
Method Detail

getOrigin

public Payload.Origin getOrigin()
Gets the original data type used to create this payload.

Returns:
The payload origin.

toJSONObject

public net.minidev.json.JSONObject toJSONObject()
Returns a JSON object view of this payload.

Returns:
The JSON object view, null if the payload couldn't be converted to a JSON object.

toString

public java.lang.String toString()
Returns a string view of this payload.

Overrides:
toString in class java.lang.Object
Returns:
The string view.

toBytes

public byte[] toBytes()
Returns a byte array view of this payload.

Returns:
The byte array view.

toBase64URL

public Base64URL toBase64URL()
Returns a Base64URL view of this payload.

Returns:
The Base64URL view.


Copyright © 2013 NimbusDS. All Rights Reserved.