Search in sources :

Example 1 with XmlCRLRefsType

use of xades4j.xml.bind.xades.XmlCRLRefsType in project xades4j by luisgoncalves.

the class FromXmlCompleteRevocRefsConverter method convertFromObjectTree.

@Override
public void convertFromObjectTree(XmlUnsignedSignaturePropertiesType xmlProps, QualifyingPropertiesDataCollector propertyDataCollector) throws PropertyUnmarshalException {
    XmlCompleteRevocationRefsType xmlCompleteRevocRefs = xmlProps.getCompleteRevocationRefs();
    if (null == xmlCompleteRevocRefs)
        return;
    if (xmlCompleteRevocRefs.getOCSPRefs() != null || xmlCompleteRevocRefs.getOtherRefs() != null)
        throw new PropertyUnmarshalException("Only CRL references are supported", CompleteRevocationRefsProperty.PROP_NAME);
    XmlCRLRefsType xmlCRLRefs = xmlCompleteRevocRefs.getCRLRefs();
    if (null == xmlCRLRefs)
        throw new PropertyUnmarshalException("CRL references not present", CompleteRevocationRefsProperty.PROP_NAME);
    CompleteRevocationRefsData complRevocRefsData = new CompleteRevocationRefsData();
    for (XmlCRLRefType xmlCRLRef : xmlCRLRefs.getCRLRef()) {
        XmlCRLIdentifierType xmlCrlId = xmlCRLRef.getCRLIdentifier();
        complRevocRefsData.addCRLRef(new CRLRef(xmlCrlId.getIssuer(), xmlCrlId.getNumber(), xmlCRLRef.getDigestAlgAndValue().getDigestMethod().getAlgorithm(), xmlCRLRef.getDigestAlgAndValue().getDigestValue(), xmlCrlId.getIssueTime().toGregorianCalendar()));
    }
    propertyDataCollector.setCompleteRevocRefs(complRevocRefsData);
}
Also used : XmlCRLIdentifierType(xades4j.xml.bind.xades.XmlCRLIdentifierType) XmlCRLRefType(xades4j.xml.bind.xades.XmlCRLRefType) XmlCompleteRevocationRefsType(xades4j.xml.bind.xades.XmlCompleteRevocationRefsType) CRLRef(xades4j.properties.data.CRLRef) XmlCRLRefsType(xades4j.xml.bind.xades.XmlCRLRefsType) CompleteRevocationRefsData(xades4j.properties.data.CompleteRevocationRefsData)

Example 2 with XmlCRLRefsType

use of xades4j.xml.bind.xades.XmlCRLRefsType 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

CRLRef (xades4j.properties.data.CRLRef)2 CompleteRevocationRefsData (xades4j.properties.data.CompleteRevocationRefsData)2 XmlCRLIdentifierType (xades4j.xml.bind.xades.XmlCRLIdentifierType)2 XmlCRLRefType (xades4j.xml.bind.xades.XmlCRLRefType)2 XmlCRLRefsType (xades4j.xml.bind.xades.XmlCRLRefsType)2 XmlCompleteRevocationRefsType (xades4j.xml.bind.xades.XmlCompleteRevocationRefsType)2 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)1 XmlDigestAlgAndValueType (xades4j.xml.bind.xades.XmlDigestAlgAndValueType)1 XmlDigestMethodType (xades4j.xml.bind.xmldsig.XmlDigestMethodType)1