Class SVTAlgoRegistry
java.lang.Object
se.swedenconnect.sigval.svt.algorithms.SVTAlgoRegistry
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)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Data object for signature algorithm properties -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.nimbusds.jose.JWSAlgorithm.Family
getAlgoFamilyFromAlgo
(com.nimbusds.jose.JWSAlgorithm algo) Retrieve the algorithm family for a specific JWS algorithmgetAlgoParams
(com.nimbusds.jose.JWSAlgorithm supportedJWSAlgo) Returns the algorithm parameters for a supported algorithmstatic MessageDigest
getMessageDigestInstance
(com.nimbusds.jose.JWSAlgorithm supportedJWSAlgo) Get an instance of the message digest algorithm associated with the specified JWS algorithmstatic MessageDigest
getMessageDigestInstance
(String digestAlgoId) Get an instance of the supported message digest algorithm associated with the specified algorithm identifierstatic com.nimbusds.jose.JWSSigner
Creates a signer for a specific algorithm and private key objectstatic boolean
isAlgoSupported
(com.nimbusds.jose.JWSAlgorithm algorithm) Test if a particular JWSAlgorithm is supportedstatic boolean
registerSupportedJWSAlgorithm
(com.nimbusds.jose.JWSAlgorithm algorithm, String sigAlgoId, String digestAlgoId, String digestInstanceName) Register a new supported JWS algorithm for signing the SVTstatic boolean
registerSupportedJWSAlgorithmType
(com.nimbusds.jose.JWSAlgorithm.Family family) Register a new supported JWS algorithm family
-
Field Details
-
DIGEST_ALGO_NAME_SHA256
- See Also:
-
DIGEST_ALGO_NAME_SHA384
- See Also:
-
DIGEST_ALGO_NAME_SHA512
- See Also:
-
ALGO_ID_SIGNATURE_ECDSA_SHA256
- See Also:
-
ALGO_ID_SIGNATURE_ECDSA_SHA384
- See Also:
-
ALGO_ID_SIGNATURE_ECDSA_SHA512
- See Also:
-
ALGO_ID_SIGNATURE_RSA_SHA256
- See Also:
-
ALGO_ID_SIGNATURE_RSA_SHA384
- See Also:
-
ALGO_ID_SIGNATURE_RSA_SHA512
- See Also:
-
ALGO_ID_SIGNATURE_RSA_SHA256_MGF1
- See Also:
-
ALGO_ID_SIGNATURE_RSA_SHA384_MGF1
- See Also:
-
ALGO_ID_SIGNATURE_RSA_SHA512_MGF1
- See Also:
-
ALGO_ID_SIGNATURE_RSA_SHA3_256_MGF1
- See Also:
-
ALGO_ID_SIGNATURE_RSA_SHA3_384_MGF1
- See Also:
-
ALGO_ID_SIGNATURE_RSA_SHA3_512_MGF1
- See Also:
-
ALGO_ID_DIGEST_SHA256
- See Also:
-
ALGO_ID_DIGEST_SHA384
- See Also:
-
ALGO_ID_DIGEST_SHA512
- See Also:
-
ALGO_ID_DIGEST_SHA3_256
- See Also:
-
ALGO_ID_DIGEST_SHA3_384
- See Also:
-
ALGO_ID_DIGEST_SHA3_512
- See Also:
-
-
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 algorithmsigAlgoId
- XML URI identifier for this algorithmdigestAlgoId
- the XML URI identifier for this algorithmdigestInstanceName
- 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 algorithmprivateKey
- the suitable private key object for this algorithm typepublicKey
- the public key associated with the private signing key- Returns:
JWSSigner
- Throws:
IllegalArgumentException
- if the provided parameters are not supportedcom.nimbusds.jose.JOSEException
- on error
-