Search in sources :

Example 1 with X509IssuerSerialType

use of org.w3.x2000.x09.xmldsig.X509IssuerSerialType in project poi by apache.

the class XAdESSignatureFacet method setCertID.

/**
     * Gives back the JAXB CertID data structure.
     */
protected static void setCertID(CertIDType certId, SignatureConfig signatureConfig, boolean issuerNameNoReverseOrder, X509Certificate certificate) {
    X509IssuerSerialType issuerSerial = certId.addNewIssuerSerial();
    String issuerName;
    if (issuerNameNoReverseOrder) {
        /*
             * Make sure the DN is encoded using the same order as present
             * within the certificate. This is an Office2010 work-around.
             * Should be reverted back.
             * 
             * XXX: not correct according to RFC 4514.
             */
        // TODO: check if issuerName is different on getTBSCertificate
        // issuerName = PrincipalUtil.getIssuerX509Principal(certificate).getName().replace(",", ", ");
        issuerName = certificate.getIssuerDN().getName().replace(",", ", ");
    } else {
        issuerName = certificate.getIssuerX500Principal().toString();
    }
    issuerSerial.setX509IssuerName(issuerName);
    issuerSerial.setX509SerialNumber(certificate.getSerialNumber());
    byte[] encodedCertificate;
    try {
        encodedCertificate = certificate.getEncoded();
    } catch (CertificateEncodingException e) {
        throw new RuntimeException("certificate encoding error: " + e.getMessage(), e);
    }
    DigestAlgAndValueType certDigest = certId.addNewCertDigest();
    setDigestAlgAndValue(certDigest, encodedCertificate, signatureConfig.getXadesDigestAlgo());
}
Also used : CertificateEncodingException(java.security.cert.CertificateEncodingException) XmlString(org.apache.xmlbeans.XmlString) DigestAlgAndValueType(org.etsi.uri.x01903.v13.DigestAlgAndValueType) X509IssuerSerialType(org.w3.x2000.x09.xmldsig.X509IssuerSerialType)

Aggregations

CertificateEncodingException (java.security.cert.CertificateEncodingException)1 XmlString (org.apache.xmlbeans.XmlString)1 DigestAlgAndValueType (org.etsi.uri.x01903.v13.DigestAlgAndValueType)1 X509IssuerSerialType (org.w3.x2000.x09.xmldsig.X509IssuerSerialType)1