use of xades4j.xml.bind.xades.XmlXAdESTimeStampType 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.XmlXAdESTimeStampType in project xades4j by luisgoncalves.
the class ToXmlArchiveTimeStampConverter method insertIntoObjectTree.
@Override
protected void insertIntoObjectTree(XmlXAdESTimeStampType xmlTimeStamp, XmlUnsignedPropertiesType xmlProps, ArchiveTimeStampData propData) {
JAXBElement<XmlXAdESTimeStampType> xmlArchTS = new ObjectFactory().createArchiveTimeStampV2(xmlTimeStamp);
xmlProps.getUnsignedSignatureProperties().getAny().add(xmlArchTS);
}
use of xades4j.xml.bind.xades.XmlXAdESTimeStampType 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);
}
Aggregations