Skip to content

Commit

Permalink
start improve vci
Browse files Browse the repository at this point in the history
  • Loading branch information
pvandenbroucke committed Apr 13, 2016
1 parent 8f6fe61 commit 329910a
Show file tree
Hide file tree
Showing 74 changed files with 471 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,10 @@ public SignaturePolicy getPolicyId() {

final ASN1OctetString digestValue = hashAlgAndValue.getHashValue();
final byte[] digestValueBytes = digestValue.getOctets();
final String policyDigestHexValue = DSSUtils.toHex(digestValueBytes);
signaturePolicy.setDigestValue(policyDigestHexValue);
signaturePolicy.setDigestValue(digestValueBytes);

final SigPolicyQualifiers sigPolicyQualifiers = sigPolicy.getSigPolicyQualifiers();
if (sigPolicyQualifiers == null) {

return signaturePolicy;
}
for (int ii = 0; ii < sigPolicyQualifiers.size(); ii++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public enum SubIndication {

NO_SIGNING_CERTIFICATE_FOUND,
FORMAT_FAILURE,
NO_POLICY,
POLICY_PROCESSING_ERROR,
SIGNATURE_POLICY_NOT_AVAILABLE,
OUT_OF_BOUNDS_NO_POE,
NO_CERTIFICATE_CHAIN_FOUND,
TRY_LATER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.04.11 at 08:34:13 PM CEST
// Generated on: 2016.04.13 at 03:49:01 PM CEST
//

@javax.xml.bind.annotation.XmlSchema(namespace = "http://dss.esig.europa.eu/validation/detailed-report", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
<xs:restriction base="xs:string">
<xs:enumeration value="NO_SIGNING_CERTIFICATE_FOUND" />
<xs:enumeration value="FORMAT_FAILURE" />
<xs:enumeration value="NO_POLICY" />
<xs:enumeration value="SIGNATURE_POLICY_NOT_AVAILABLE" />
<xs:enumeration value="POLICY_PROCESSING_ERROR" />
<xs:enumeration value="OUT_OF_BOUNDS_NO_POE" />
<xs:enumeration value="NO_CERTIFICATE_CHAIN_FOUND" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.net.URL;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -41,6 +42,7 @@
import javax.xml.bind.DatatypeConverter;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Sequence;
Expand Down Expand Up @@ -1206,13 +1208,13 @@ private void dealPolicy(final AdvancedSignature signature, final XmlSignature xm
final String notice = signaturePolicy.getNotice();
xmlPolicy.setNotice(notice);

final String policyDigestValueFromSignature = StringUtils.upperCase(signaturePolicy.getDigestValue());
final byte[] digestValue = signaturePolicy.getDigestValue();
final DigestAlgorithm signPolicyHashAlgFromSignature = signaturePolicy.getDigestAlgorithm();

if (StringUtils.isNotEmpty(policyDigestValueFromSignature)) {
if (ArrayUtils.isNotEmpty(digestValue)) {
XmlDigestAlgAndValueType xmlDigestAlgAndValue = new XmlDigestAlgAndValueType();
xmlDigestAlgAndValue.setDigestMethod(signPolicyHashAlgFromSignature == null ? "" : signPolicyHashAlgFromSignature.getName());
xmlDigestAlgAndValue.setDigestValue(policyDigestValueFromSignature);
xmlDigestAlgAndValue.setDigestValue(DatatypeConverter.printBase64Binary(digestValue));
xmlPolicy.setDigestAlgAndValue(xmlDigestAlgAndValue);
}

Expand Down Expand Up @@ -1303,46 +1305,40 @@ private void dealPolicy(final AdvancedSignature signature, final XmlSignature xm
}

byte[] recalculatedDigestValue = DSSASN1Utils.getAsn1SignaturePolicyDigest(signPolicyHashAlgFromPolicy, policyBytes);
String recalculatedDigestHexValue = DSSUtils.toHex(recalculatedDigestValue);

boolean equal = policyDigestValueFromSignature.equals(recalculatedDigestHexValue);
boolean equal = Arrays.equals(digestValue, recalculatedDigestValue);
xmlPolicy.setStatus(equal);
if (!equal) {
xmlPolicy.setProcessingError("The policy digest value (" + policyDigestValueFromSignature
+ ") does not match the re-calculated digest value (" + recalculatedDigestHexValue + ").");
xmlPolicy.setProcessingError("The policy digest value (" + DatatypeConverter.printBase64Binary(digestValue)
+ ") does not match the re-calculated digest value (" + DatatypeConverter.printBase64Binary(recalculatedDigestValue) + ").");
return;
}

final ASN1OctetString signPolicyHash = (ASN1OctetString) asn1Sequence.getObjectAt(2);
final byte[] policyDigestValueFromPolicy = signPolicyHash.getOctets();
String policyDigestHexValueFromPolicy = DSSUtils.toHex(policyDigestValueFromPolicy);
equal = policyDigestValueFromSignature.equals(policyDigestHexValueFromPolicy);
equal = Arrays.equals(digestValue, policyDigestValueFromPolicy);
xmlPolicy.setStatus(equal);
if (!equal) {
xmlPolicy.setProcessingError("The policy digest value (" + policyDigestValueFromSignature
+ ") does not match the digest value from the policy file (" + policyDigestHexValueFromPolicy + ").");
xmlPolicy.setProcessingError("The policy digest value (" + DatatypeConverter.printBase64Binary(digestValue)
+ ") does not match the digest value from the policy file (" + DatatypeConverter.printBase64Binary(policyDigestValueFromPolicy)
+ ").");
}
} else {

/**
* c) In all other cases, compute the digest using the digesting
* algorithm indicated in the children of the
* property/attribute.
*/

byte[] recalculatedDigestValue = DSSUtils.digest(signPolicyHashAlgFromSignature, policyBytes);
String recalculatedDigestHexValue = DSSUtils.toHex(recalculatedDigestValue);

boolean equal = policyDigestValueFromSignature.equals(recalculatedDigestHexValue);
boolean equal = Arrays.equals(digestValue, recalculatedDigestValue);
xmlPolicy.setStatus(equal);
if (!equal) {
xmlPolicy.setProcessingError("The policy digest value (" + policyDigestValueFromSignature
+ ") does not match the re-calculated digest value (" + recalculatedDigestHexValue + ").");
return;
xmlPolicy.setProcessingError("The policy digest value (" + DatatypeConverter.printBase64Binary(digestValue)
+ ") does not match the re-calculated digest value (" + DatatypeConverter.printBase64Binary(recalculatedDigestValue) + ").");
}
}

} catch (RuntimeException e) {
} catch (Exception e) {
// When any error (communication) we just set the status to false
xmlPolicy.setStatus(false);
xmlPolicy.setProcessingError(e.getMessage());
Expand Down

0 comments on commit 329910a

Please sign in to comment.