aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-asic
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2018-02-13 11:27:02 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2018-02-13 11:27:02 +0100
commit00e4e0cbaf7fe6b2ecb08011995f00e503981911 (patch)
treea460d18b334c9cc57b31396f9380809c760db3b0 /moaSig/moa-asic
parentc6083bb7ebd59cb5316ee531d30d1c2da583e594 (diff)
downloadmoa-sig-00e4e0cbaf7fe6b2ecb08011995f00e503981911.tar.gz
moa-sig-00e4e0cbaf7fe6b2ecb08011995f00e503981911.tar.bz2
moa-sig-00e4e0cbaf7fe6b2ecb08011995f00e503981911.zip
add infos about signature and hash algorithms into responses
Diffstat (limited to 'moaSig/moa-asic')
-rw-r--r--moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerificationResult.java9
-rw-r--r--moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/AsicSignedFilesContainer.java39
-rw-r--r--moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/ExtendedCAdESVerifier.java8
-rw-r--r--moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/ExtendedXAdESVerifier.java7
-rw-r--r--moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/SimpleCAdESVerifier.java7
-rw-r--r--moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/SimpleXAdESVerifier.java7
-rw-r--r--moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureResponseBuilder.java16
-rw-r--r--moaSig/moa-asic/src/test/java/at/gv/egiz/asic/dev/Main.java5
8 files changed, 77 insertions, 21 deletions
diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerificationResult.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerificationResult.java
index a350f18..ce8f374 100644
--- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerificationResult.java
+++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerificationResult.java
@@ -1,5 +1,6 @@
package at.gv.egiz.asic.api;
+import at.gv.egiz.asic.impl.AsicSignedFilesContainer;
import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponse;
import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse;
@@ -11,22 +12,22 @@ import java.util.List;
*/
public class ASiCVerificationResult {
- private List<String> signedFiles = new ArrayList<String>();
+ private List<AsicSignedFilesContainer> signedFiles = new ArrayList<AsicSignedFilesContainer>();
private VerifyCMSSignatureResponse cmsResult = null;
private VerifyXMLSignatureResponse xmlResult = null;
- public ASiCVerificationResult(List<String> references, VerifyCMSSignatureResponse cmsResult) {
+ public ASiCVerificationResult(List<AsicSignedFilesContainer> references, VerifyCMSSignatureResponse cmsResult) {
this.signedFiles = references;
this.cmsResult = cmsResult;
}
- public ASiCVerificationResult(List<String> references, VerifyXMLSignatureResponse xmlResult) {
+ public ASiCVerificationResult(List<AsicSignedFilesContainer> references, VerifyXMLSignatureResponse xmlResult) {
this.signedFiles = references;
this.xmlResult = xmlResult;
}
- public List<String> getSignedFiles() {
+ public List<AsicSignedFilesContainer> getSignedFiles() {
return signedFiles;
}
diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/AsicSignedFilesContainer.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/AsicSignedFilesContainer.java
new file mode 100644
index 0000000..c21960d
--- /dev/null
+++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/AsicSignedFilesContainer.java
@@ -0,0 +1,39 @@
+package at.gv.egiz.asic.impl;
+
+public class AsicSignedFilesContainer {
+
+ private String uri = null;
+ private String hashAlg = null;
+
+
+ /**
+ * Container element with ASIC signed files information
+ *
+ * @param uri Identifier of the file
+ * @param hashAlg Hash algorithm that is used to hash the file
+ */
+ public AsicSignedFilesContainer(String uri, String hashAlg) {
+ this.uri = uri;
+ this.hashAlg = hashAlg;
+
+ }
+
+ /**
+ * Get file identifier
+ *
+ * @return
+ */
+ public String getUri() {
+ return uri;
+ }
+
+ /**
+ * Get hash algorithm that is used to hash the file
+ *
+ * @return
+ */
+ public String getHashAlg() {
+ return hashAlg;
+ }
+
+}
diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/ExtendedCAdESVerifier.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/ExtendedCAdESVerifier.java
index 9f16035..c227a9d 100644
--- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/ExtendedCAdESVerifier.java
+++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/ExtendedCAdESVerifier.java
@@ -6,6 +6,7 @@ import at.gv.egiz.asic.api.ASiC;
import at.gv.egiz.asic.api.ASiCEntry;
import at.gv.egiz.asic.api.ASiCFormat;
import at.gv.egiz.asic.api.ASiCVerificationResult;
+import at.gv.egiz.asic.impl.AsicSignedFilesContainer;
import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.MOAException;
import at.gv.egovernment.moa.spss.MOASystemException;
@@ -73,14 +74,14 @@ public class ExtendedCAdESVerifier extends CAdESVerifier {
// verify all references
boolean allReferencesValid = true;
- List<String> signedFiles = new ArrayList<String>();
+ List<AsicSignedFilesContainer> signedFiles = new ArrayList<AsicSignedFilesContainer>();
Iterator<DataObjectReferenceType> dataObjectReferenceTypeIterator = asiCManifestType.getDataObjectReference().iterator();
while (dataObjectReferenceTypeIterator.hasNext()) {
DataObjectReferenceType dataObjectReferenceType = dataObjectReferenceTypeIterator.next();
String mdURI = dataObjectReferenceType.getDigestMethod().getAlgorithm();
String uri = dataObjectReferenceType.getURI();
- signedFiles.add(uri);
+ signedFiles.add(new AsicSignedFilesContainer(uri, mdURI));
Iterator<ASiCEntry> dataEntryIterator = asic.getDataEntries().iterator();
@@ -149,7 +150,8 @@ public class ExtendedCAdESVerifier extends CAdESVerifier {
signatureCheck,
orig.getCertificateCheck(),
orig.getAdESFormResults(),
- orig.getExtendedCertificateCheck());
+ orig.getExtendedCertificateCheck(),
+ orig.getSignatureAlgorithm());
responseElements.add(responseElement);
}
VerifyCMSSignatureResponse verifyCMSSignatureResponse = SPSSFactory.getInstance().
diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/ExtendedXAdESVerifier.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/ExtendedXAdESVerifier.java
index c07efd9..86918bf 100644
--- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/ExtendedXAdESVerifier.java
+++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/ExtendedXAdESVerifier.java
@@ -7,6 +7,7 @@ import at.gv.egiz.asic.api.ASiC;
import at.gv.egiz.asic.api.ASiCEntry;
import at.gv.egiz.asic.api.ASiCFormat;
import at.gv.egiz.asic.api.ASiCVerificationResult;
+import at.gv.egiz.asic.impl.AsicSignedFilesContainer;
import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.MOAException;
import at.gv.egovernment.moa.spss.MOARuntimeException;
@@ -132,14 +133,14 @@ public class ExtendedXAdESVerifier extends XAdESVerifier {
//JAXBContext jc = JAXBContext.newInstance( "at.gv.egiz.asic" );
//JAXBElement<SignatureType> xmlSignatureJaxb = jc.createUnmarshaller().unmarshal(node, SignatureType.class);
//SignatureType xmlSignature = xmlSignatureJaxb.getValue();
- List<String> signedFiles = new ArrayList<String>();
+ List<AsicSignedFilesContainer> signedFiles = new ArrayList<AsicSignedFilesContainer>();
//Iterator<ReferenceType> it = xmlSignature.getSignedInfo().getReference().iterator();
Iterator<ReferenceType> it = xmlSignatures.get(i).getSignedInfo().getReference().iterator();
while (it.hasNext()) {
ReferenceType refType = it.next();
- if (!refType.getURI().startsWith("#")) {
- signedFiles.add(refType.getURI());
+ if (!refType.getURI().startsWith("#")) {
+ signedFiles.add(new AsicSignedFilesContainer(refType.getURI(), refType.getDigestMethod().getAlgorithm()));
}
}
diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/SimpleCAdESVerifier.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/SimpleCAdESVerifier.java
index f10fe2f..f1756fa 100644
--- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/SimpleCAdESVerifier.java
+++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/SimpleCAdESVerifier.java
@@ -4,6 +4,7 @@ import at.gv.egiz.asic.api.ASiC;
import at.gv.egiz.asic.api.ASiCEntry;
import at.gv.egiz.asic.api.ASiCFormat;
import at.gv.egiz.asic.api.ASiCVerificationResult;
+import at.gv.egiz.asic.impl.AsicSignedFilesContainer;
import at.gv.egovernment.moa.spss.MOAException;
import at.gv.egovernment.moa.spss.api.SPSSFactory;
import at.gv.egovernment.moa.spss.api.cmsverify.CMSContent;
@@ -32,12 +33,12 @@ public class SimpleCAdESVerifier extends CAdESVerifier {
//get first element
ASiCEntry dataEntry = asic.getDataEntries().iterator().next();
- List<String> signedFiles = new ArrayList<String>();
- signedFiles.add(dataEntry.getEntryName());
+ List<AsicSignedFilesContainer> signedFiles = new ArrayList<AsicSignedFilesContainer>();
+ signedFiles.add(new AsicSignedFilesContainer(dataEntry.getEntryName(), null));
VerifyCMSSignatureResponse verifyResponse =
this.runCMSVerification(dataEntry.getContents(), cadesSignature.getContents(), trustProfileID, date);
-
+
response.add(new ASiCVerificationResult(signedFiles,
verifyResponse));
}
diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/SimpleXAdESVerifier.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/SimpleXAdESVerifier.java
index a71462c..b378d5b 100644
--- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/SimpleXAdESVerifier.java
+++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/verifier/SimpleXAdESVerifier.java
@@ -6,6 +6,7 @@ import at.gv.egiz.asic.api.ASiC;
import at.gv.egiz.asic.api.ASiCEntry;
import at.gv.egiz.asic.api.ASiCFormat;
import at.gv.egiz.asic.api.ASiCVerificationResult;
+import at.gv.egiz.asic.impl.AsicSignedFilesContainer;
import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.MOAException;
import at.gv.egovernment.moa.spss.MOARuntimeException;
@@ -67,13 +68,13 @@ public class SimpleXAdESVerifier extends XAdESVerifier {
for (int i = 0; i < signatureSize; i++) {
- List<String> signedFiles = new ArrayList<String>();
+ List<AsicSignedFilesContainer> signedFiles = new ArrayList<AsicSignedFilesContainer>();
Iterator<ReferenceType> it = xAdESSignaturesType.getSignature().get(i).getSignedInfo().getReference().iterator();
while (it.hasNext()) {
ReferenceType refType = it.next();
if (!refType.getURI().startsWith("#")) {
- signedFiles.add(refType.getURI());
+ signedFiles.add(new AsicSignedFilesContainer(refType.getURI(), refType.getDigestMethod().getAlgorithm()));
}
}
@@ -99,7 +100,7 @@ public class SimpleXAdESVerifier extends XAdESVerifier {
supplementsList.add(profile);
if (addAll) {
- signedFiles.add(dataEntry.getEntryName());
+ signedFiles.add(new AsicSignedFilesContainer(dataEntry.getEntryName(), null));
}
}
String location = "(//ds:Signature)[" + (i + 1) + "]";
diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureResponseBuilder.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureResponseBuilder.java
index 50cd261..67d8b05 100644
--- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureResponseBuilder.java
+++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/xmlbind/VerifyASICSignatureResponseBuilder.java
@@ -25,6 +25,7 @@
package at.gv.egiz.asic.xmlbind;
import at.gv.egiz.asic.api.ASiCVerificationResult;
+import at.gv.egiz.asic.impl.AsicSignedFilesContainer;
import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.MOAException;
import at.gv.egovernment.moa.spss.MOASystemException;
@@ -37,6 +38,8 @@ import at.gv.egovernment.moa.spss.api.xmlbind.VerifyXMLSignatureResponseBuilder;
import at.gv.egovernment.moa.spss.api.xmlverify.AdESFormResults;
import at.gv.egovernment.moa.spss.api.xmlbind.VerifyCMSSignatureResponseBuilder;
import at.gv.egovernment.moaspss.util.Constants;
+import at.gv.egovernment.moaspss.util.MiscUtil;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -96,11 +99,14 @@ public class VerifyASICSignatureResponseBuilder {
throws MOAException {
Element asiCSignatureResultElem = responseDoc.createElementNS(Constants.MOA_NS_URI, "ASiCSignatureResult");
- Iterator<String> signedFiles = aSiCVerificationResult.getSignedFiles().iterator();
+ Iterator<AsicSignedFilesContainer> signedFiles = aSiCVerificationResult.getSignedFiles().iterator();
while (signedFiles.hasNext()) {
- String signedFile = signedFiles.next();
+ AsicSignedFilesContainer signedFile = signedFiles.next();
Element signedFilesElem = responseDoc.createElementNS(Constants.MOA_NS_URI, "signedFiles");
- signedFilesElem.setTextContent(signedFile);
+ signedFilesElem.setTextContent(signedFile.getUri());
+ if (MiscUtil.isNotEmpty(signedFile.getHashAlg()))
+ signedFilesElem.setAttribute("hashAlgorithm", signedFile.getHashAlg());
+
asiCSignatureResultElem.appendChild(signedFilesElem);
}
@@ -141,6 +147,10 @@ public class VerifyASICSignatureResponseBuilder {
signerInfo.getIssuerCountryCode(),
signerInfo.getTslInfos());
+ ResponseBuilderUtils.addSignatureAlgorithm(responseDoc,
+ responseElem,
+ responseElement.getSignatureAlgorithm());
+
ResponseBuilderUtils.addCodeInfoElement(
responseDoc,
responseElem,
diff --git a/moaSig/moa-asic/src/test/java/at/gv/egiz/asic/dev/Main.java b/moaSig/moa-asic/src/test/java/at/gv/egiz/asic/dev/Main.java
index 5005a3b..ec6e902 100644
--- a/moaSig/moa-asic/src/test/java/at/gv/egiz/asic/dev/Main.java
+++ b/moaSig/moa-asic/src/test/java/at/gv/egiz/asic/dev/Main.java
@@ -5,6 +5,7 @@ import at.gv.egiz.asic.api.ASiCFactory;
import at.gv.egiz.asic.api.ASiCFormat;
import at.gv.egiz.asic.api.ASiCVerificationResult;
import at.gv.egiz.asic.impl.ASiCMOAVerifier;
+import at.gv.egiz.asic.impl.AsicSignedFilesContainer;
import at.gv.egiz.asic.xmlbind.VerifyASICSignatureResponseBuilder;
import at.gv.egovernment.moa.spss.MOASystemException;
import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponse;
@@ -79,9 +80,9 @@ public class Main {
// Auswertung der Response
System.out.println();
System.out.println("Signierte Eintraege");
- Iterator<String> signedFilesIterator = aSiCVerificationResult.getSignedFiles().iterator();
+ Iterator<AsicSignedFilesContainer> signedFilesIterator = aSiCVerificationResult.getSignedFiles().iterator();
while (signedFilesIterator.hasNext()) {
- System.out.println(" " + signedFilesIterator.next());
+ System.out.println(" " + signedFilesIterator.next().getUri());
}
System.out.println();
}