Search in sources :

Example 1 with XmlSignaturePolicyIdType

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

the class FromXmlSignaturePolicyConverter method convertFromObjectTree.

@Override
public void convertFromObjectTree(XmlSignedSignaturePropertiesType xmlProps, QualifyingPropertiesDataCollector propertyDataCollector) throws PropertyUnmarshalException {
    XmlSignaturePolicyIdentifierType xmlSigPolicy = xmlProps.getSignaturePolicyIdentifier();
    if (null == xmlSigPolicy)
        return;
    if (xmlSigPolicy.getSignaturePolicyImplied() != null) {
        propertyDataCollector.setSignaturePolicy(new SignaturePolicyData());
        return;
    }
    XmlSignaturePolicyIdType xmlPolicyId = xmlSigPolicy.getSignaturePolicyId();
    if (xmlPolicyId.getTransforms() != null)
        throw new PropertyUnmarshalException("Signature policy transforms are not supported", SignaturePolicyBase.PROP_NAME);
    propertyDataCollector.setSignaturePolicy(new SignaturePolicyData(FromXmlUtils.getObjectIdentifier(xmlPolicyId.getSigPolicyId()), xmlPolicyId.getSigPolicyHash().getDigestMethod().getAlgorithm(), xmlPolicyId.getSigPolicyHash().getDigestValue(), getLocationUrl(xmlPolicyId)));
}
Also used : SignaturePolicyData(xades4j.properties.data.SignaturePolicyData) XmlSignaturePolicyIdType(xades4j.xml.bind.xades.XmlSignaturePolicyIdType) XmlSignaturePolicyIdentifierType(xades4j.xml.bind.xades.XmlSignaturePolicyIdentifierType)

Example 2 with XmlSignaturePolicyIdType

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

the class ToXmlSignaturePolicyConverter method getSignaturePolicy.

private XmlSignaturePolicyIdType getSignaturePolicy(SignaturePolicyData sigPolicyData, Document doc) {
    XmlSignaturePolicyIdType xmlSigPolicyId = new XmlSignaturePolicyIdType();
    // Identifier
    xmlSigPolicyId.setSigPolicyId(ToXmlUtils.getXmlObjectId(sigPolicyData.getIdentifier()));
    // Hash
    XmlDigestMethodType xmlDigestMethod = new XmlDigestMethodType();
    xmlDigestMethod.setAlgorithm(sigPolicyData.getDigestAlgorithm());
    XmlDigestAlgAndValueType xmlDigest = new XmlDigestAlgAndValueType();
    xmlDigest.setDigestMethod(xmlDigestMethod);
    xmlDigest.setDigestValue(sigPolicyData.getDigestValue());
    xmlSigPolicyId.setSigPolicyHash(xmlDigest);
    // Qualifiers
    String url = sigPolicyData.getLocationUrl();
    if (url != null) {
        JAXBElement<String> xmlSPURI = new JAXBElement<String>(new QName(QualifyingProperty.XADES_XMLNS, "SPURI"), String.class, url);
        XmlAnyType xmlQualifier = new XmlAnyType();
        xmlQualifier.getContent().add(xmlSPURI);
        XmlSigPolicyQualifiersListType xmlQualifiers = new XmlSigPolicyQualifiersListType();
        xmlQualifiers.getSigPolicyQualifier().add(xmlQualifier);
        xmlSigPolicyId.setSigPolicyQualifiers(xmlQualifiers);
    }
    return xmlSigPolicyId;
}
Also used : XmlDigestAlgAndValueType(xades4j.xml.bind.xades.XmlDigestAlgAndValueType) XmlAnyType(xades4j.xml.bind.xades.XmlAnyType) QName(javax.xml.namespace.QName) XmlDigestMethodType(xades4j.xml.bind.xmldsig.XmlDigestMethodType) JAXBElement(javax.xml.bind.JAXBElement) XmlSignaturePolicyIdType(xades4j.xml.bind.xades.XmlSignaturePolicyIdType) XmlSigPolicyQualifiersListType(xades4j.xml.bind.xades.XmlSigPolicyQualifiersListType)

Aggregations

XmlSignaturePolicyIdType (xades4j.xml.bind.xades.XmlSignaturePolicyIdType)2 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1 SignaturePolicyData (xades4j.properties.data.SignaturePolicyData)1 XmlAnyType (xades4j.xml.bind.xades.XmlAnyType)1 XmlDigestAlgAndValueType (xades4j.xml.bind.xades.XmlDigestAlgAndValueType)1 XmlSigPolicyQualifiersListType (xades4j.xml.bind.xades.XmlSigPolicyQualifiersListType)1 XmlSignaturePolicyIdentifierType (xades4j.xml.bind.xades.XmlSignaturePolicyIdentifierType)1 XmlDigestMethodType (xades4j.xml.bind.xmldsig.XmlDigestMethodType)1