com.nimbusds.jose.jwk
Class OctetSequenceKey

java.lang.Object
  extended by com.nimbusds.jose.jwk.JWK
      extended by com.nimbusds.jose.jwk.OctetSequenceKey
All Implemented Interfaces:
net.minidev.json.JSONAware

@Immutable
public class OctetSequenceKey
extends JWK

Octet sequence JSON Web Key (JWK), used to represent symmetric keys. This class is immutable.

Example JSON object representation of an octet sequence JWK:

 {
   "kty" : "oct",
   "alg" : "A128KW",
   "k"   : "GawgguFyGrWKav7AX4VKUg"
 }
 

Version:
$version$ (2013-03-26)
Author:
Justin Richer, Vladimir Dzhuvinov

Constructor Summary
OctetSequenceKey(Base64URL k, Use use, Algorithm alg, String kid)
          Creates a new octet sequence JSON Web Key (JWK) with the specified parameters.
OctetSequenceKey(byte[] k, Use use, Algorithm alg, String kid)
          Creates a new octet sequence JSON Web Key (JWK) with the specified parameters.
 
Method Summary
 Base64URL getKeyValue()
          Returns the value of this octet sequence key.
 boolean isPrivate()
          Octet sequence (symmetric) keys are never considered public, this method always returns true.
static OctetSequenceKey parse(net.minidev.json.JSONObject jsonObject)
          Parses an octet sequence JWK from the specified JSON object representation.
static OctetSequenceKey parse(String s)
          Parses an octet sequence JWK from the specified JSON object string representation.
 byte[] toByteArray()
          Returns a copy of this octet sequence key value as a byte array.
 net.minidev.json.JSONObject toJSONObject()
          Returns a JSON object representation of this JWK.
 OctetSequenceKey toPublicJWK()
          Octet sequence (symmetric) keys are never considered public, this method always returns null.
 
Methods inherited from class com.nimbusds.jose.jwk.JWK
getAlgorithm, getKeyID, getKeyType, getKeyUse, parseAlgorithm, parseKeyID, parseKeyUse, toJSONString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OctetSequenceKey

public OctetSequenceKey(Base64URL k,
                        Use use,
                        Algorithm alg,
                        String kid)
Creates a new octet sequence JSON Web Key (JWK) with the specified parameters.

Parameters:
k - The key value. It is represented as the Base64URL encoding of value's big endian representation. Must not be null.
use - The key use. null if not specified.
alg - The intended JOSE algorithm for the key, null if not specified.
kid - The key ID. null if not specified.

OctetSequenceKey

public OctetSequenceKey(byte[] k,
                        Use use,
                        Algorithm alg,
                        String kid)
Creates a new octet sequence JSON Web Key (JWK) with the specified parameters.

Parameters:
k - The key value. It is represented as the value's big endian representation. Must not be null.
use - The key use. null if not specified.
alg - The intended JOSE algorithm for the key, null if not specified.
kid - The key ID. null if not specified.
Method Detail

getKeyValue

public Base64URL getKeyValue()
Returns the value of this octet sequence key. It is represented as the Base64URL encoding of the coordinate's big endian representation.

Returns:
The key value.

toByteArray

public byte[] toByteArray()
Returns a copy of this octet sequence key value as a byte array.

Returns:
The key value as a byte array.

isPrivate

public boolean isPrivate()
Octet sequence (symmetric) keys are never considered public, this method always returns true.

Specified by:
isPrivate in class JWK
Returns:
true

toPublicJWK

public OctetSequenceKey toPublicJWK()
Octet sequence (symmetric) keys are never considered public, this method always returns null.

Specified by:
toPublicJWK in class JWK
Returns:
null

toJSONObject

public net.minidev.json.JSONObject toJSONObject()
Description copied from class: JWK
Returns a JSON object representation of this JWK. This method is intended to be called from extending classes.

Example:

 {
   "kty" : "RSA",
   "use" : "sig",
   "kid" : "fd28e025-8d24-48bc-a51a-e2ffc8bc274b"
 }
 

Overrides:
toJSONObject in class JWK
Returns:
The JSON object representation.

parse

public static OctetSequenceKey parse(String s)
                              throws ParseException
Parses an octet sequence JWK from the specified JSON object string representation.

Parameters:
s - The JSON object string to parse. Must not be null.
Returns:
The octet sequence JWK.
Throws:
ParseException - If the string couldn't be parsed to an octet sequence JWK.

parse

public static OctetSequenceKey parse(net.minidev.json.JSONObject jsonObject)
                              throws ParseException
Parses an octet sequence JWK from the specified JSON object representation.

Parameters:
jsonObject - The JSON object to parse. Must not be
Returns:
The octet sequence JWK.
Throws:
ParseException - If the JSON object couldn't be parsed to an octet sequence JWK.


Copyright © 2013 NimbusDS. All Rights Reserved.