use of xades4j.xml.bind.xades.XmlEncapsulatedPKIDataType in project xades4j by luisgoncalves.
the class FromXmlBaseTimeStampConverter method convertTimeStamps.
protected void convertTimeStamps(List<XmlXAdESTimeStampType> xmlTimeStamps, QualifyingPropertiesDataCollector propertyDataCollector) throws PropertyUnmarshalException {
if (null == xmlTimeStamps || xmlTimeStamps.isEmpty())
return;
for (XmlXAdESTimeStampType xmlTS : xmlTimeStamps) {
if (!xmlTS.getReferenceInfo().isEmpty())
throw new PropertyUnmarshalException("ReferenceInfo is not supported in XAdESTimeStamp", propName);
Algorithm c14n;
XmlCanonicalizationMethodType xmlCanonMethod = xmlTS.getCanonicalizationMethod();
if (null == xmlCanonMethod) {
c14n = new GenericAlgorithm(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
} else {
List params = CollectionUtils.filterByType(xmlCanonMethod.getContent(), Element.class);
c14n = new GenericAlgorithm(xmlCanonMethod.getAlgorithm(), params);
}
TPropData tsData = createTSData(c14n);
List<Object> tsTokens = xmlTS.getEncapsulatedTimeStampOrXMLTimeStamp();
if (tsTokens.isEmpty())
throw new PropertyUnmarshalException("No time-stamp tokens", propName);
for (Object tkn : tsTokens) {
if (!(tkn instanceof XmlEncapsulatedPKIDataType))
throw new PropertyUnmarshalException("XML time-stamps are not supported", propName);
tsData.addTimeStampToken(((XmlEncapsulatedPKIDataType) tkn).getValue());
}
doSpecificConvert(xmlTS, tsData);
setTSData(tsData, propertyDataCollector);
}
}
use of xades4j.xml.bind.xades.XmlEncapsulatedPKIDataType in project xades4j by luisgoncalves.
the class ToXmlBaseTimeStampConverter method convertIntoObjectTree.
@Override
public final void convertIntoObjectTree(PropertyDataObject propData, TXml xmlProps, Document doc) {
TData tsData = (TData) propData;
XmlXAdESTimeStampType xmlTimeStamp = new XmlXAdESTimeStampType();
// Canonicalization method
XmlCanonicalizationMethodType xmlCanon = new XmlCanonicalizationMethodType();
xmlTimeStamp.setCanonicalizationMethod(xmlCanon);
Algorithm c14n = tsData.getCanonicalizationAlgorithm();
xmlCanon.setAlgorithm(c14n.getUri());
try {
List<Node> c14nParams = this.algorithmsParametersMarshallingProvider.marshalParameters(c14n, doc);
if (c14nParams != null) {
xmlCanon.getContent().addAll(c14nParams);
}
} catch (UnsupportedAlgorithmException ex) {
// Do not throw any specific exception for now.
throw new IllegalArgumentException("Cannot marshall algorithm parameters", ex);
}
// Time-stamp tokens
List<byte[]> tsTokens = tsData.getTimeStampTokens();
List<Object> xmlTSTokens = xmlTimeStamp.getEncapsulatedTimeStampOrXMLTimeStamp();
for (byte[] tsToken : tsTokens) {
XmlEncapsulatedPKIDataType xmlTSTkn = new XmlEncapsulatedPKIDataType();
xmlTSTkn.setValue(tsToken);
xmlTSTokens.add(xmlTSTkn);
}
insertIntoObjectTree(xmlTimeStamp, xmlProps, tsData);
}
use of xades4j.xml.bind.xades.XmlEncapsulatedPKIDataType in project xades4j by luisgoncalves.
the class ToXmlRevocationValuesConverter method convertIntoObjectTree.
@Override
public void convertIntoObjectTree(PropertyDataObject propData, XmlUnsignedPropertiesType xmlProps, Document doc) {
Collection<byte[]> crlValues = ((RevocationValuesData) propData).getData();
XmlRevocationValuesType xmlRevocValues = new XmlRevocationValuesType();
XmlCRLValuesType xmlCRLValues = new XmlCRLValuesType();
xmlRevocValues.setCRLValues(xmlCRLValues);
List xmlCRLs = xmlCRLValues.getEncapsulatedCRLValue();
for (byte[] encodCrl : crlValues) {
XmlEncapsulatedPKIDataType xmlEncodCert = new XmlEncapsulatedPKIDataType();
xmlEncodCert.setValue(encodCrl);
xmlCRLs.add(xmlEncodCert);
}
xmlProps.getUnsignedSignatureProperties().setRevocationValues(xmlRevocValues);
}
use of xades4j.xml.bind.xades.XmlEncapsulatedPKIDataType in project xades4j by luisgoncalves.
the class ToXmlCertificateValuesConverter method convertIntoObjectTree.
@Override
public void convertIntoObjectTree(PropertyDataObject propData, XmlUnsignedPropertiesType xmlProps, Document doc) {
Collection<byte[]> certValues = ((CertificateValuesData) propData).getData();
XmlCertificateValuesType xmlCertValues = new XmlCertificateValuesType();
List xmlCerts = xmlCertValues.getEncapsulatedX509CertificateOrOtherCertificate();
for (byte[] encodCer : certValues) {
XmlEncapsulatedPKIDataType xmlEncodCert = new XmlEncapsulatedPKIDataType();
xmlEncodCert.setValue(encodCer);
xmlCerts.add(xmlEncodCert);
}
xmlProps.getUnsignedSignatureProperties().setCertificateValues(xmlCertValues);
}
Aggregations