com.nimbusds.jose
Class PlainHeader

java.lang.Object
  extended by com.nimbusds.jose.Header
      extended by com.nimbusds.jose.PlainHeader
All Implemented Interfaces:
ReadOnlyHeader, ReadOnlyPlainHeader

public class PlainHeader
extends Header
implements ReadOnlyPlainHeader

Plaintext JOSE header.

Supports all reserved header parameters of the plain specification:

The header may also carry custom parameters; these will be serialised and parsed along the reserved ones.

Example:

 {
   "alg" : "none"
 }
 

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

Field Summary
 
Fields inherited from class com.nimbusds.jose.Header
alg
 
Constructor Summary
PlainHeader()
          Creates a new plain header with algorithm none.
 
Method Summary
 Algorithm getAlgorithm()
          Gets the algorithm (alg) parameter.
 Set<String> getIncludedParameters()
          Gets the names of all included parameters (reserved and custom) in the header instance.
static Set<String> getReservedParameterNames()
          Gets the reserved parameter names for plain headers.
static PlainHeader parse(Base64URL base64URL)
          Parses a plain header from the specified Base64URL.
static PlainHeader parse(net.minidev.json.JSONObject json)
          Parses a plain header from the specified JSON object.
static PlainHeader parse(String s)
          Parses a plain header from the specified JSON string.
 void setCustomParameter(String name, Object value)
          Sets a custom (non-reserved) parameter.
 
Methods inherited from class com.nimbusds.jose.Header
getContentType, getCriticalHeaders, getCustomParameter, getCustomParameters, getType, parseAlgorithm, setContentType, setCriticalHeaders, setCustomParameters, setParsedBase64URL, setType, toBase64URL, toJSONObject, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.nimbusds.jose.ReadOnlyHeader
getContentType, getCriticalHeaders, getCustomParameter, getCustomParameters, getType, toBase64URL, toJSONObject, toString
 

Constructor Detail

PlainHeader

public PlainHeader()
Creates a new plain header with algorithm none.

Method Detail

getReservedParameterNames

public static Set<String> getReservedParameterNames()
Gets the reserved parameter names for plain headers.

Returns:
The reserved parameter names, as an unmodifiable set.

getAlgorithm

public Algorithm getAlgorithm()
Description copied from interface: ReadOnlyPlainHeader
Gets the algorithm (alg) parameter.

Specified by:
getAlgorithm in interface ReadOnlyHeader
Specified by:
getAlgorithm in interface ReadOnlyPlainHeader
Returns:
Algorithm.NONE.

setCustomParameter

public void setCustomParameter(String name,
                               Object value)
Description copied from class: Header
Sets a custom (non-reserved) parameter. Callers and extending classes should ensure the parameter name doesn't match a reserved parameter name.

Overrides:
setCustomParameter in class Header
Parameters:
name - The name of the custom parameter. Must not match a reserved parameter name and must not be null.
value - The value of the custom parameter, should map to a valid JSON entity, null if not specified.
Throws:
IllegalArgumentException - If the specified parameter name matches a reserved parameter name.

getIncludedParameters

public Set<String> getIncludedParameters()
Description copied from interface: ReadOnlyHeader
Gets the names of all included parameters (reserved and custom) in the header instance.

Specified by:
getIncludedParameters in interface ReadOnlyHeader
Returns:
The included parameters.

parse

public static PlainHeader parse(net.minidev.json.JSONObject json)
                         throws ParseException
Parses a plain header from the specified JSON object.

Parameters:
json - The JSON object to parse. Must not be null.
Returns:
The plain header.
Throws:
ParseException - If the specified JSON object doesn't represent a valid plain header.

parse

public static PlainHeader parse(String s)
                         throws ParseException
Parses a plain header from the specified JSON string.

Parameters:
s - The JSON string to parse. Must not be null.
Returns:
The plain header.
Throws:
ParseException - If the specified JSON string doesn't represent a valid plain header.

parse

public static PlainHeader parse(Base64URL base64URL)
                         throws ParseException
Parses a plain header from the specified Base64URL.

Parameters:
base64URL - The Base64URL to parse. Must not be null.
Returns:
The plain header.
Throws:
ParseException - If the specified Base64URL doesn't represent a valid plain header.


Copyright © 2013 NimbusDS. All Rights Reserved.