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