use of xades4j.xml.bind.xmldsig.XmlDigestMethodType 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;
}
use of xades4j.xml.bind.xmldsig.XmlDigestMethodType in project xades4j by luisgoncalves.
the class ToXmlUtils method getXmlCertRefList.
/**/
static XmlCertIDListType getXmlCertRefList(BaseCertRefsData certRefsData) {
XmlCertIDListType xmlCertRefListProp = new XmlCertIDListType();
List<XmlCertIDType> xmlCertRefList = xmlCertRefListProp.getCert();
XmlDigestAlgAndValueType certDigest;
XmlDigestMethodType certDigestMethod;
XmlX509IssuerSerialType issuerSerial;
XmlCertIDType certID;
for (CertRef certRef : certRefsData.getCertRefs()) {
certDigestMethod = new XmlDigestMethodType();
certDigestMethod.setAlgorithm(certRef.digestAlgUri);
certDigest = new XmlDigestAlgAndValueType();
certDigest.setDigestMethod(certDigestMethod);
certDigest.setDigestValue(certRef.digestValue);
issuerSerial = new XmlX509IssuerSerialType();
issuerSerial.setX509IssuerName(certRef.issuerDN);
issuerSerial.setX509SerialNumber(certRef.serialNumber);
certID = new XmlCertIDType();
certID.setCertDigest(certDigest);
certID.setIssuerSerial(issuerSerial);
xmlCertRefList.add(certID);
}
return xmlCertRefListProp;
}
use of xades4j.xml.bind.xmldsig.XmlDigestMethodType in project xades4j by luisgoncalves.
the class ToXmlCompleteRevocRefsConverter method convertIntoObjectTree.
@Override
public void convertIntoObjectTree(PropertyDataObject propData, XmlUnsignedPropertiesType xmlProps, Document doc) {
CompleteRevocationRefsData complRevocRefsData = (CompleteRevocationRefsData) propData;
// Only CRL refs are supported.
XmlCRLRefsType xmlCRLRefs = new XmlCRLRefsType();
List<XmlCRLRefType> xmlCRLRefsList = xmlCRLRefs.getCRLRef();
try {
for (CRLRef crlRef : complRevocRefsData.getCrlRefs()) {
XmlCRLIdentifierType xmlCrlId = new XmlCRLIdentifierType();
xmlCrlId.setIssueTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(crlRef.issueTime));
xmlCrlId.setIssuer(crlRef.issuerDN);
// May be null.
xmlCrlId.setNumber(crlRef.serialNumber);
XmlDigestAlgAndValueType xmlDigest = new XmlDigestAlgAndValueType();
XmlDigestMethodType xmlDigestMethod = new XmlDigestMethodType();
xmlDigestMethod.setAlgorithm(crlRef.digestAlgUri);
xmlDigest.setDigestValue(crlRef.digestValue);
xmlDigest.setDigestMethod(xmlDigestMethod);
XmlCRLRefType xmlCrlRef = new XmlCRLRefType();
xmlCrlRef.setCRLIdentifier(xmlCrlId);
xmlCrlRef.setDigestAlgAndValue(xmlDigest);
xmlCRLRefsList.add(xmlCrlRef);
}
} catch (DatatypeConfigurationException ex) {
throw new UnsupportedOperationException(ex.getMessage(), ex);
}
XmlCompleteRevocationRefsType xmlComplRevocRefs = new XmlCompleteRevocationRefsType();
// Only CRL refs are supported.
xmlComplRevocRefs.setCRLRefs(xmlCRLRefs);
xmlProps.getUnsignedSignatureProperties().setCompleteRevocationRefs(xmlComplRevocRefs);
}
Aggregations