Search in sources :

Example 1 with XmlEncapsulatedPKIDataType

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);
    }
}
Also used : XmlEncapsulatedPKIDataType(xades4j.xml.bind.xades.XmlEncapsulatedPKIDataType) XmlXAdESTimeStampType(xades4j.xml.bind.xades.XmlXAdESTimeStampType) List(java.util.List) Algorithm(xades4j.algorithms.Algorithm) GenericAlgorithm(xades4j.algorithms.GenericAlgorithm) GenericAlgorithm(xades4j.algorithms.GenericAlgorithm) XmlCanonicalizationMethodType(xades4j.xml.bind.xmldsig.XmlCanonicalizationMethodType)

Example 2 with XmlEncapsulatedPKIDataType

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);
}
Also used : Node(org.w3c.dom.Node) Algorithm(xades4j.algorithms.Algorithm) UnsupportedAlgorithmException(xades4j.UnsupportedAlgorithmException) XmlEncapsulatedPKIDataType(xades4j.xml.bind.xades.XmlEncapsulatedPKIDataType) XmlXAdESTimeStampType(xades4j.xml.bind.xades.XmlXAdESTimeStampType) PropertyDataObject(xades4j.properties.data.PropertyDataObject) XmlCanonicalizationMethodType(xades4j.xml.bind.xmldsig.XmlCanonicalizationMethodType)

Example 3 with XmlEncapsulatedPKIDataType

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);
}
Also used : XmlCRLValuesType(xades4j.xml.bind.xades.XmlCRLValuesType) RevocationValuesData(xades4j.properties.data.RevocationValuesData) XmlRevocationValuesType(xades4j.xml.bind.xades.XmlRevocationValuesType) XmlEncapsulatedPKIDataType(xades4j.xml.bind.xades.XmlEncapsulatedPKIDataType) List(java.util.List)

Example 4 with XmlEncapsulatedPKIDataType

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);
}
Also used : XmlEncapsulatedPKIDataType(xades4j.xml.bind.xades.XmlEncapsulatedPKIDataType) CertificateValuesData(xades4j.properties.data.CertificateValuesData) List(java.util.List) XmlCertificateValuesType(xades4j.xml.bind.xades.XmlCertificateValuesType)

Aggregations

XmlEncapsulatedPKIDataType (xades4j.xml.bind.xades.XmlEncapsulatedPKIDataType)4 List (java.util.List)3 Algorithm (xades4j.algorithms.Algorithm)2 XmlXAdESTimeStampType (xades4j.xml.bind.xades.XmlXAdESTimeStampType)2 XmlCanonicalizationMethodType (xades4j.xml.bind.xmldsig.XmlCanonicalizationMethodType)2 Node (org.w3c.dom.Node)1 UnsupportedAlgorithmException (xades4j.UnsupportedAlgorithmException)1 GenericAlgorithm (xades4j.algorithms.GenericAlgorithm)1 CertificateValuesData (xades4j.properties.data.CertificateValuesData)1 PropertyDataObject (xades4j.properties.data.PropertyDataObject)1 RevocationValuesData (xades4j.properties.data.RevocationValuesData)1 XmlCRLValuesType (xades4j.xml.bind.xades.XmlCRLValuesType)1 XmlCertificateValuesType (xades4j.xml.bind.xades.XmlCertificateValuesType)1 XmlRevocationValuesType (xades4j.xml.bind.xades.XmlRevocationValuesType)1