org.pfsw.security
Class SignatureAlgorithm

java.lang.Object
  extended by org.pfsw.security.SignatureAlgorithm

public class SignatureAlgorithm
extends Object

Each instance of this class represents a signature algorithm.

Version:
1.0
Author:
Manfred Duchrow

Field Summary
static SignatureAlgorithm MD5_WITH_RSA
           
static SignatureAlgorithm SHA1_WITH_DSA
           
static SignatureAlgorithm SHA1_WITH_ECDSA
           
static SignatureAlgorithm SHA1_WITH_RSA
           
static SignatureAlgorithm SHA256_WITH_ECDSA
           
static SignatureAlgorithm SHA256_WITH_RSA
           
static SignatureAlgorithm SHA384_WITH_ECDSA
           
static SignatureAlgorithm SHA384_WITH_RSA
           
static SignatureAlgorithm SHA512_WITH_ECDSA
           
static SignatureAlgorithm SHA512_WITH_RSA
           
 
Constructor Summary
SignatureAlgorithm(String algorithmName)
          Creates the SignatureAlgorithm object for the given name.
SignatureAlgorithm(String algorithmName, String jwaName)
          Creates the SignatureAlgorithm object for the given names.
 
Method Summary
 Signature asSignature()
          Returns the signature object or throws an NoSuchAlgorithmException if this signature algorithm is not supported.
 boolean equals(Object obj)
           
static SignatureAlgorithm findByJWAName(String jwaName)
           
static SignatureAlgorithm findByName(String algorithmName)
           
 String getJWAName()
          Returns the JSON Web Algorithm (JWA) name.
 String getName()
          Returns the signature algorithm name.
 int hashCode()
           
static boolean register(SignatureAlgorithm algorithm)
          Registers a SignatureAlgorithm for re-use.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MD5_WITH_RSA

public static final SignatureAlgorithm MD5_WITH_RSA

SHA1_WITH_DSA

public static final SignatureAlgorithm SHA1_WITH_DSA

SHA1_WITH_RSA

public static final SignatureAlgorithm SHA1_WITH_RSA

SHA256_WITH_RSA

public static final SignatureAlgorithm SHA256_WITH_RSA

SHA384_WITH_RSA

public static final SignatureAlgorithm SHA384_WITH_RSA

SHA512_WITH_RSA

public static final SignatureAlgorithm SHA512_WITH_RSA

SHA1_WITH_ECDSA

public static final SignatureAlgorithm SHA1_WITH_ECDSA

SHA256_WITH_ECDSA

public static final SignatureAlgorithm SHA256_WITH_ECDSA

SHA384_WITH_ECDSA

public static final SignatureAlgorithm SHA384_WITH_ECDSA

SHA512_WITH_ECDSA

public static final SignatureAlgorithm SHA512_WITH_ECDSA
Constructor Detail

SignatureAlgorithm

public SignatureAlgorithm(String algorithmName)
Creates the SignatureAlgorithm object for the given name.

Parameters:
algorithmName - The name of the signature algorithm (must not be null).
Throws:
SignatureAlgorithm - If algorithmName is null or blank.

SignatureAlgorithm

public SignatureAlgorithm(String algorithmName,
                          String jwaName)
Creates the SignatureAlgorithm object for the given names.

Parameters:
algorithmName - The name of the signature algorithm (must not be null).
jwaName - An optional name from the JWA specification (may be null).
Throws:
SignatureAlgorithm - If algorithmName is null or blank.
Method Detail

findByName

public static SignatureAlgorithm findByName(String algorithmName)

findByJWAName

public static SignatureAlgorithm findByJWAName(String jwaName)

register

public static boolean register(SignatureAlgorithm algorithm)
Registers a SignatureAlgorithm for re-use.

Returns:
true if the algorithm has been added to the registry, false if it has not been added (e.g. because it was a duplicate).

getName

public String getName()
Returns the signature algorithm name.


getJWAName

public String getJWAName()
Returns the JSON Web Algorithm (JWA) name.

Returns:
The name form the JWA specification or null if this algorithm has no JWA name.

asSignature

public Signature asSignature()
                      throws NoSuchAlgorithmException
Returns the signature object or throws an NoSuchAlgorithmException if this signature algorithm is not supported.

Throws:
NoSuchAlgorithmException

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2015 Manfred Duchrow Consulting & Software. All rights reserved.