Class SVTAlgoRegistry

java.lang.Object
se.swedenconnect.sigval.svt.algorithms.SVTAlgoRegistry

public class SVTAlgoRegistry extends Object
Registry for SVT supported algorithms. This class adds support for the minimum supported set of algorithms and allows new algorithms to be added. By default only RSA and ECDSA with SHA 245, 384 and 512 are supported.
Author:
Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
  • Field Details

  • Method Details

    • isAlgoSupported

      public static boolean isAlgoSupported(com.nimbusds.jose.JWSAlgorithm algorithm)
      Test if a particular JWSAlgorithm is supported
      Parameters:
      algorithm - algorithm to test
      Returns:
      true if supported
    • getAlgoParams

      public static SVTAlgoRegistry.AlgoProperties getAlgoParams(com.nimbusds.jose.JWSAlgorithm supportedJWSAlgo) throws IllegalArgumentException
      Returns the algorithm parameters for a supported algorithm
      Parameters:
      supportedJWSAlgo - algorithm
      Returns:
      algorithm parameters
      Throws:
      IllegalArgumentException - if the algorithm is not supported
    • getMessageDigestInstance

      public static MessageDigest getMessageDigestInstance(com.nimbusds.jose.JWSAlgorithm supportedJWSAlgo) throws NoSuchAlgorithmException
      Get an instance of the message digest algorithm associated with the specified JWS algorithm
      Parameters:
      supportedJWSAlgo - JWS algorithm
      Returns:
      MessageDigest instance
      Throws:
      NoSuchAlgorithmException - if specified JWS algorithm is not supported
    • getMessageDigestInstance

      public static MessageDigest getMessageDigestInstance(String digestAlgoId) throws NoSuchAlgorithmException
      Get an instance of the supported message digest algorithm associated with the specified algorithm identifier
      Parameters:
      digestAlgoId - Digest algorithm URI identifier
      Returns:
      MessageDigest instance
      Throws:
      NoSuchAlgorithmException - if specified JWS algorithm is not supported
    • registerSupportedJWSAlgorithmType

      public static boolean registerSupportedJWSAlgorithmType(com.nimbusds.jose.JWSAlgorithm.Family family)
      Register a new supported JWS algorithm family
      Parameters:
      family - Famliy to register
      Returns:
      true if the new algorithm was registered
    • registerSupportedJWSAlgorithm

      public static boolean registerSupportedJWSAlgorithm(com.nimbusds.jose.JWSAlgorithm algorithm, String sigAlgoId, String digestAlgoId, String digestInstanceName) throws IllegalArgumentException
      Register a new supported JWS algorithm for signing the SVT
      Parameters:
      algorithm - The JWSAlgorithm object for this algorithm
      sigAlgoId - XML URI identifier for this algorithm
      digestAlgoId - the XML URI identifier for this algorithm
      digestInstanceName - the name of the digest algorithm passed to the supported crypto provider when creating an instance of this hash algorithm
      Returns:
      true if the algorithm registration was successful
      Throws:
      IllegalArgumentException
    • getAlgoFamilyFromAlgo

      public static com.nimbusds.jose.JWSAlgorithm.Family getAlgoFamilyFromAlgo(com.nimbusds.jose.JWSAlgorithm algo) throws IllegalArgumentException
      Retrieve the algorithm family for a specific JWS algorithm
      Parameters:
      algo - the JWS algorithm
      Returns:
      JWSAlgorithm.Family
      Throws:
      IllegalArgumentException - if the requested algorithm is not supported
    • getSigner

      public static com.nimbusds.jose.JWSSigner getSigner(com.nimbusds.jose.JWSAlgorithm jwsAlgorithm, Object privateKey, PublicKey publicKey) throws IllegalArgumentException, com.nimbusds.jose.JOSEException
      Creates a signer for a specific algorithm and private key object
      Parameters:
      jwsAlgorithm - the JWS algorithm
      privateKey - the suitable private key object for this algorithm type
      publicKey - the public key associated with the private signing key
      Returns:
      JWSSigner
      Throws:
      IllegalArgumentException - if the provided parameters are not supported
      com.nimbusds.jose.JOSEException - on error