Search in sources :

Example 1 with XmlDigestMethodType

use of xades4j.xml.bind.xmldsig.XmlDigestMethodType in project xades4j by luisgoncalves.

the class ToXmlSignaturePolicyConverter method getSignaturePolicy.

private XmlSignaturePolicyIdType getSignaturePolicy(SignaturePolicyData sigPolicyData, Document doc) {
    XmlSignaturePolicyIdType xmlSigPolicyId = new XmlSignaturePolicyIdType();
    // Identifier
    xmlSigPolicyId.setSigPolicyId(ToXmlUtils.getXmlObjectId(sigPolicyData.getIdentifier()));
    // Hash
    XmlDigestMethodType xmlDigestMethod = new XmlDigestMethodType();
    xmlDigestMethod.setAlgorithm(sigPolicyData.getDigestAlgorithm());
    XmlDigestAlgAndValueType xmlDigest = new XmlDigestAlgAndValueType();
    xmlDigest.setDigestMethod(xmlDigestMethod);
    xmlDigest.setDigestValue(sigPolicyData.getDigestValue());
    xmlSigPolicyId.setSigPolicyHash(xmlDigest);
    // Qualifiers
    String url = sigPolicyData.getLocationUrl();
    if (url != null) {
        JAXBElement<String> xmlSPURI = new JAXBElement<String>(new QName(QualifyingProperty.XADES_XMLNS, "SPURI"), String.class, url);
        XmlAnyType xmlQualifier = new XmlAnyType();
        xmlQualifier.getContent().add(xmlSPURI);
        XmlSigPolicyQualifiersListType xmlQualifiers = new XmlSigPolicyQualifiersListType();
        xmlQualifiers.getSigPolicyQualifier().add(xmlQualifier);
        xmlSigPolicyId.setSigPolicyQualifiers(xmlQualifiers);
    }
    return xmlSigPolicyId;
}
Also used : XmlDigestAlgAndValueType(xades4j.xml.bind.xades.XmlDigestAlgAndValueType) XmlAnyType(xades4j.xml.bind.xades.XmlAnyType) QName(javax.xml.namespace.QName) XmlDigestMethodType(xades4j.xml.bind.xmldsig.XmlDigestMethodType) JAXBElement(javax.xml.bind.JAXBElement) XmlSignaturePolicyIdType(xades4j.xml.bind.xades.XmlSignaturePolicyIdType) XmlSigPolicyQualifiersListType(xades4j.xml.bind.xades.XmlSigPolicyQualifiersListType)

Example 2 with XmlDigestMethodType

use of xades4j.xml.bind.xmldsig.XmlDigestMethodType in project xades4j by luisgoncalves.

the class ToXmlUtils method getXmlCertRefList.

/**/
static XmlCertIDListType getXmlCertRefList(BaseCertRefsData certRefsData) {
    XmlCertIDListType xmlCertRefListProp = new XmlCertIDListType();
    List<XmlCertIDType> xmlCertRefList = xmlCertRefListProp.getCert();
    XmlDigestAlgAndValueType certDigest;
    XmlDigestMethodType certDigestMethod;
    XmlX509IssuerSerialType issuerSerial;
    XmlCertIDType certID;
    for (CertRef certRef : certRefsData.getCertRefs()) {
        certDigestMethod = new XmlDigestMethodType();
        certDigestMethod.setAlgorithm(certRef.digestAlgUri);
        certDigest = new XmlDigestAlgAndValueType();
        certDigest.setDigestMethod(certDigestMethod);
        certDigest.setDigestValue(certRef.digestValue);
        issuerSerial = new XmlX509IssuerSerialType();
        issuerSerial.setX509IssuerName(certRef.issuerDN);
        issuerSerial.setX509SerialNumber(certRef.serialNumber);
        certID = new XmlCertIDType();
        certID.setCertDigest(certDigest);
        certID.setIssuerSerial(issuerSerial);
        xmlCertRefList.add(certID);
    }
    return xmlCertRefListProp;
}
Also used : XmlDigestAlgAndValueType(xades4j.xml.bind.xades.XmlDigestAlgAndValueType) XmlCertIDType(xades4j.xml.bind.xades.XmlCertIDType) XmlX509IssuerSerialType(xades4j.xml.bind.xmldsig.XmlX509IssuerSerialType) XmlCertIDListType(xades4j.xml.bind.xades.XmlCertIDListType) CertRef(xades4j.properties.data.CertRef) XmlDigestMethodType(xades4j.xml.bind.xmldsig.XmlDigestMethodType)

Example 3 with XmlDigestMethodType

use of xades4j.xml.bind.xmldsig.XmlDigestMethodType in project xades4j by luisgoncalves.

the class ToXmlCompleteRevocRefsConverter method convertIntoObjectTree.

@Override
public void convertIntoObjectTree(PropertyDataObject propData, XmlUnsignedPropertiesType xmlProps, Document doc) {
    CompleteRevocationRefsData complRevocRefsData = (CompleteRevocationRefsData) propData;
    // Only CRL refs are supported.
    XmlCRLRefsType xmlCRLRefs = new XmlCRLRefsType();
    List<XmlCRLRefType> xmlCRLRefsList = xmlCRLRefs.getCRLRef();
    try {
        for (CRLRef crlRef : complRevocRefsData.getCrlRefs()) {
            XmlCRLIdentifierType xmlCrlId = new XmlCRLIdentifierType();
            xmlCrlId.setIssueTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(crlRef.issueTime));
            xmlCrlId.setIssuer(crlRef.issuerDN);
            // May be null.
            xmlCrlId.setNumber(crlRef.serialNumber);
            XmlDigestAlgAndValueType xmlDigest = new XmlDigestAlgAndValueType();
            XmlDigestMethodType xmlDigestMethod = new XmlDigestMethodType();
            xmlDigestMethod.setAlgorithm(crlRef.digestAlgUri);
            xmlDigest.setDigestValue(crlRef.digestValue);
            xmlDigest.setDigestMethod(xmlDigestMethod);
            XmlCRLRefType xmlCrlRef = new XmlCRLRefType();
            xmlCrlRef.setCRLIdentifier(xmlCrlId);
            xmlCrlRef.setDigestAlgAndValue(xmlDigest);
            xmlCRLRefsList.add(xmlCrlRef);
        }
    } catch (DatatypeConfigurationException ex) {
        throw new UnsupportedOperationException(ex.getMessage(), ex);
    }
    XmlCompleteRevocationRefsType xmlComplRevocRefs = new XmlCompleteRevocationRefsType();
    // Only CRL refs are supported.
    xmlComplRevocRefs.setCRLRefs(xmlCRLRefs);
    xmlProps.getUnsignedSignatureProperties().setCompleteRevocationRefs(xmlComplRevocRefs);
}
Also used : XmlCRLIdentifierType(xades4j.xml.bind.xades.XmlCRLIdentifierType) XmlDigestAlgAndValueType(xades4j.xml.bind.xades.XmlDigestAlgAndValueType) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) XmlCRLRefType(xades4j.xml.bind.xades.XmlCRLRefType) XmlCompleteRevocationRefsType(xades4j.xml.bind.xades.XmlCompleteRevocationRefsType) CRLRef(xades4j.properties.data.CRLRef) XmlDigestMethodType(xades4j.xml.bind.xmldsig.XmlDigestMethodType) XmlCRLRefsType(xades4j.xml.bind.xades.XmlCRLRefsType) CompleteRevocationRefsData(xades4j.properties.data.CompleteRevocationRefsData)

Aggregations

XmlDigestAlgAndValueType (xades4j.xml.bind.xades.XmlDigestAlgAndValueType)3 XmlDigestMethodType (xades4j.xml.bind.xmldsig.XmlDigestMethodType)3 JAXBElement (javax.xml.bind.JAXBElement)1 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)1 QName (javax.xml.namespace.QName)1 CRLRef (xades4j.properties.data.CRLRef)1 CertRef (xades4j.properties.data.CertRef)1 CompleteRevocationRefsData (xades4j.properties.data.CompleteRevocationRefsData)1 XmlAnyType (xades4j.xml.bind.xades.XmlAnyType)1 XmlCRLIdentifierType (xades4j.xml.bind.xades.XmlCRLIdentifierType)1 XmlCRLRefType (xades4j.xml.bind.xades.XmlCRLRefType)1 XmlCRLRefsType (xades4j.xml.bind.xades.XmlCRLRefsType)1 XmlCertIDListType (xades4j.xml.bind.xades.XmlCertIDListType)1 XmlCertIDType (xades4j.xml.bind.xades.XmlCertIDType)1 XmlCompleteRevocationRefsType (xades4j.xml.bind.xades.XmlCompleteRevocationRefsType)1 XmlSigPolicyQualifiersListType (xades4j.xml.bind.xades.XmlSigPolicyQualifiersListType)1 XmlSignaturePolicyIdType (xades4j.xml.bind.xades.XmlSignaturePolicyIdType)1 XmlX509IssuerSerialType (xades4j.xml.bind.xmldsig.XmlX509IssuerSerialType)1