Class PDFAlgorithmRegistry
java.lang.Object
se.idsec.signservice.security.sign.pdf.configuration.PDFAlgorithmRegistry
Registry for 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)
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getAlgoFamilyFromAlgo
(String algorithm) Retrieve the algorithm family for a specific algorithm.static se.swedenconnect.security.algorithms.SignatureAlgorithm
getAlgorithmProperties
(String algorithm) Returns the algorithm parameters for a supported signature algorithm.static String
getAlgorithmURI
(org.bouncycastle.asn1.ASN1ObjectIdentifier sigAlgoOid, org.bouncycastle.asn1.ASN1ObjectIdentifier digestAlgoOid) Get the URI identifier for a registered signature algorithm based on signature algorithm identifier and hash algorithm identifier.static String
getAlgorithmURI
(org.bouncycastle.asn1.x509.AlgorithmIdentifier algorithmIdentifier) Get the URI identifier for a registered signature algorithm specified by an ASN.1 algorithm identifier.static String
getDigestName
(String algorithm) Get the algorithm name for the digest algorithm of the signature algorithm.static MessageDigest
getMessageDigestInstance
(String algorithm) Get an instance of the message digest associated with the specified signature algorithm.static String
getSigAlgoName
(String algorithm) Get the algorithm name for the signature algorithm.static boolean
isAlgoSupported
(String algorithm) Test if a particular algorithm is supported.static void
registerSupportedAlgorithm
(se.swedenconnect.security.algorithms.SignatureAlgorithm signatureAlgorithm) Register a new supported signature algorithm.
-
Method Details
-
isAlgoSupported
Test if a particular algorithm is supported.- Parameters:
algorithm
- algorithm to test- Returns:
- true if supported, and false otherwise
-
getAlgorithmURI
public static String getAlgorithmURI(org.bouncycastle.asn1.x509.AlgorithmIdentifier algorithmIdentifier) throws NoSuchAlgorithmException Get the URI identifier for a registered signature algorithm specified by an ASN.1 algorithm identifier.- Parameters:
algorithmIdentifier
- the ASN.1 algorithm identifier- Returns:
- URI identifier for the specified signature algorithm
- Throws:
NoSuchAlgorithmException
- if the specified algorithm is not supported or has illegal parameters
-
getAlgorithmURI
public static String getAlgorithmURI(org.bouncycastle.asn1.ASN1ObjectIdentifier sigAlgoOid, org.bouncycastle.asn1.ASN1ObjectIdentifier digestAlgoOid) throws NoSuchAlgorithmException Get the URI identifier for a registered signature algorithm based on signature algorithm identifier and hash algorithm identifier.- Parameters:
sigAlgoOid
- signature algorithm object identifierdigestAlgoOid
- hash algorithm object identifier- Returns:
- URI identifier for the combined signature algorithm
- Throws:
NoSuchAlgorithmException
- if the OID combinations are not supported
-
getAlgorithmProperties
public static se.swedenconnect.security.algorithms.SignatureAlgorithm getAlgorithmProperties(String algorithm) throws NoSuchAlgorithmException Returns the algorithm parameters for a supported signature algorithm.- Parameters:
algorithm
- signature algorithm- Returns:
- algorithm properties
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported
-
getMessageDigestInstance
public static MessageDigest getMessageDigestInstance(String algorithm) throws NoSuchAlgorithmException Get an instance of the message digest associated with the specified signature algorithm.- Parameters:
algorithm
- algorithm URI identifier for signature algorithm- Returns:
- s MessageDigest instance
- Throws:
NoSuchAlgorithmException
- if specified signature algorithm is not supported
-
getDigestName
Get the algorithm name for the digest algorithm of the signature algorithm.- Parameters:
algorithm
- algorithm URI identifier- Returns:
- the name of the digest algorithm used to create instances of the digest algorithm
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported
-
getSigAlgoName
Get the algorithm name for the signature algorithm.- Parameters:
algorithm
- algorithm URI identifier- Returns:
- the name of the signature algorithm used to initiate the use of this algorithm in CMS signing
- Throws:
NoSuchAlgorithmException
- if the algorithm is not supported
-
registerSupportedAlgorithm
public static void registerSupportedAlgorithm(se.swedenconnect.security.algorithms.SignatureAlgorithm signatureAlgorithm) Register a new supported signature algorithm.- Parameters:
signatureAlgorithm
- the signature algorithm to register
-
getAlgoFamilyFromAlgo
Retrieve the algorithm family for a specific algorithm.- Parameters:
algorithm
- the algorithm- Returns:
- the algorithm type
- Throws:
IllegalArgumentException
- if the requested algorithm is not supported
-