Class GeneralCMSUtils
java.lang.Object
se.swedenconnect.sigval.commons.utils.GeneralCMSUtils
Utility methods for processing CMS data
- Author:
- Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Data class for providing certificates supporting a CMS signature -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic GeneralCMSUtils.CMSSigCerts
extractCertificates
(org.bouncycastle.cms.CMSSignedDataParser cmsSignedDataParser) Extracts signing certificate and supporting certificate chainstatic X509Certificate
getCert
(org.bouncycastle.cert.X509CertificateHolder certHolder) converts an X509CertificateHolder object to an X509Certificate object.static org.bouncycastle.cms.CMSSignedDataParser
getCMSSignedDataParser
(byte[] cmsContentInfo, byte[] signedDocBytes) Obtains aCMSSignedDataParser
static org.bouncycastle.asn1.ASN1Sequence
getESSCertIDSequence
(org.bouncycastle.asn1.cms.Attribute essSigningCertAttr) This method extracts the ESSCertID sequence from a SigningCertificate signed CMS attribute.static PubKeyParams
getPkParams
(PublicKey pubKey) Retrieves Public key parameters from a public key
-
Constructor Details
-
GeneralCMSUtils
public GeneralCMSUtils()
-
-
Method Details
-
extractCertificates
public static GeneralCMSUtils.CMSSigCerts extractCertificates(org.bouncycastle.cms.CMSSignedDataParser cmsSignedDataParser) throws Exception Extracts signing certificate and supporting certificate chain- Parameters:
cmsSignedDataParser
-CMSSignedDataParser
object holding certificate data- Returns:
- signing certificate and supporting certificate chain
- Throws:
Exception
- is certificate extraction fails
-
getCMSSignedDataParser
public static org.bouncycastle.cms.CMSSignedDataParser getCMSSignedDataParser(byte[] cmsContentInfo, byte[] signedDocBytes) throws org.bouncycastle.cms.CMSException Obtains aCMSSignedDataParser
- Parameters:
cmsContentInfo
- The byes of the contents parameter in the signature dictionary containing the bytes of a CMS ContentInfosignedDocBytes
- The bytes of the PDF document signed by this signature. These are the bytes identified by the byteRange parameter in the signature dictionary.- Returns:
- CMSSignedDataParser
- Throws:
org.bouncycastle.cms.CMSException
- on error
-
getPkParams
Retrieves Public key parameters from a public key- Parameters:
pubKey
- The public key- Returns:
- public key parameters
- Throws:
IOException
- error obtaining public key parameters
-
getESSCertIDSequence
public static org.bouncycastle.asn1.ASN1Sequence getESSCertIDSequence(org.bouncycastle.asn1.cms.Attribute essSigningCertAttr) throws Exception This method extracts the ESSCertID sequence from a SigningCertificate signed CMS attribute. If the signed attribute is of type SigningCertificateV2 (RFC 5035) the returned sequence is ESSCertIDv2. If the signed attribute is of type SigningCertificate (RFC2634 using SHA1 as fixed hash algo) then the returned sequence is of type ESSCertID.- Parameters:
essSigningCertAttr
- The signed CMS attribute carried in SignerInfo- Returns:
- An ASN.1 Sequence holding the sequence of objects in ESSCertID or ESSCertIDv2
- Throws:
Exception
- Any exception caused by input not mathing the assumed processing rules
-
getCert
public static X509Certificate getCert(org.bouncycastle.cert.X509CertificateHolder certHolder) throws IOException, CertificateException converts an X509CertificateHolder object to an X509Certificate object.- Parameters:
certHolder
- the cert holder object- Returns:
- X509Certificate object
- Throws:
IOException
- error parsing input dataCertificateException
- certificate parsing error
-