com.nimbusds.jose.crypto
Class ECDSASigner

java.lang.Object
  extended by com.nimbusds.jose.crypto.ECDSASigner
All Implemented Interfaces:
JWSAlgorithmProvider, JWSSigner

@ThreadSafe
public class ECDSASigner
extends Object
implements JWSSigner

Elliptic Curve Digital Signature Algorithm (ECDSA) signer of JWS objects. This class is thread-safe.

Supports the following JSON Web Algorithms (JWAs):

Version:
$version$ (2013-05-04)
Author:
Axel Nennker, Vladimir Dzhuvinov

Field Summary
static Set<JWSAlgorithm> SUPPORTED_ALGORITHMS
          The supported JWS algorithms.
 
Constructor Summary
ECDSASigner(BigInteger privateKey)
          Creates a new Elliptic Curve Digital Signature Algorithm (ECDSA) signer.
 
Method Summary
protected static com.nimbusds.jose.crypto.ECDSAParameters getECDSAParameters(JWSAlgorithm alg)
          Gets the initial parameters for the specified ECDSA-based JSON Web Algorithm (JWA).
 BigInteger getPrivateKey()
          Gets the private key ('d' parameter).
protected static int getSignatureByteArrayLength(JWSAlgorithm alg)
          Gets the expected signature byte array length (R + S parts) for the specified ECDSA algorithm.
 Base64URL sign(ReadOnlyJWSHeader header, byte[] signingInput)
          Signs the specified input of a JWS object.
 Set<JWSAlgorithm> supportedAlgorithms()
          Returns the names of the supported JWS algorithms.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.nimbusds.jose.JWSAlgorithmProvider
supportedAlgorithms
 

Field Detail

SUPPORTED_ALGORITHMS

public static final Set<JWSAlgorithm> SUPPORTED_ALGORITHMS
The supported JWS algorithms.

Constructor Detail

ECDSASigner

public ECDSASigner(BigInteger privateKey)
Creates a new Elliptic Curve Digital Signature Algorithm (ECDSA) signer.

Parameters:
privateKey - The private key ('d' parameter). Must not be null.
Method Detail

getPrivateKey

public BigInteger getPrivateKey()
Gets the private key ('d' parameter).

Returns:
The private key.

sign

public Base64URL sign(ReadOnlyJWSHeader header,
                      byte[] signingInput)
               throws JOSEException
Description copied from interface: JWSSigner
Signs the specified input of a JWS object.

Specified by:
sign in interface JWSSigner
Parameters:
header - The JSON Web Signature (JWS) header. Must specify a supported JWS algorithm and must not be null.
signingInput - The input to sign. Must not be null.
Returns:
The resulting signature part (third part) of the JWS object.
Throws:
JOSEException - If the JWS algorithm is not supported or if signing failed for some other reason.

getSignatureByteArrayLength

protected static int getSignatureByteArrayLength(JWSAlgorithm alg)
                                          throws JOSEException
Gets the expected signature byte array length (R + S parts) for the specified ECDSA algorithm.

Parameters:
alg - The JSON Web Algorithm (JWA). Must be supported and not null.
Returns:
The expected byte array length for the signature.
Throws:
JOSEException - If the algorithm is not supported.

getECDSAParameters

protected static com.nimbusds.jose.crypto.ECDSAParameters getECDSAParameters(JWSAlgorithm alg)
                                                                      throws JOSEException
Gets the initial parameters for the specified ECDSA-based JSON Web Algorithm (JWA).

Parameters:
alg - The JSON Web Algorithm (JWA). Must be supported and not null.
Returns:
The initial ECDSA parameters.
Throws:
JOSEException - If the algorithm is not supported.

supportedAlgorithms

public Set<JWSAlgorithm> supportedAlgorithms()
Description copied from interface: JWSAlgorithmProvider
Returns the names of the supported JWS algorithms. These correspond to the alg JWS header parameter.

Specified by:
supportedAlgorithms in interface JWSAlgorithmProvider
Returns:
The supported JWS algorithms, empty set if none.


Copyright © 2013 NimbusDS. All Rights Reserved.