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);
}
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);
}
Aggregations