summaryrefslogtreecommitdiff
path: root/STALService/src
diff options
context:
space:
mode:
authortkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-12-13 04:06:05 +0000
committertkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-12-13 04:06:05 +0000
commit438727ab21b5e80d1771279b988d6aed57ba3ab1 (patch)
tree1de5dc68467b378d7ece4a1119ac539dca6462c9 /STALService/src
parentda6c49cbea9c80ad057a5fc3b698ce14ad9a7415 (diff)
downloadmocca-438727ab21b5e80d1771279b988d6aed57ba3ab1.tar.gz
mocca-438727ab21b5e80d1771279b988d6aed57ba3ab1.tar.bz2
mocca-438727ab21b5e80d1771279b988d6aed57ba3ab1.zip
Add ExcludedByteRange to STAL SignatureRequest, honour it for digest calculation
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1264 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'STALService/src')
-rw-r--r--STALService/src/main/java/at/gv/egiz/stal/service/translator/STALTranslator.java13
-rw-r--r--STALService/src/main/java/at/gv/egiz/stal/service/types/ObjectFactory.java8
-rw-r--r--STALService/src/main/java/at/gv/egiz/stal/service/types/SignRequestType.java122
-rw-r--r--STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java18
4 files changed, 160 insertions, 1 deletions
diff --git a/STALService/src/main/java/at/gv/egiz/stal/service/translator/STALTranslator.java b/STALService/src/main/java/at/gv/egiz/stal/service/translator/STALTranslator.java
index 5ddadbe7..ff9e88ca 100644
--- a/STALService/src/main/java/at/gv/egiz/stal/service/translator/STALTranslator.java
+++ b/STALService/src/main/java/at/gv/egiz/stal/service/translator/STALTranslator.java
@@ -41,6 +41,7 @@ import at.gv.egiz.stal.QuitRequest;
import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
import at.gv.egiz.stal.SignRequest;
+import at.gv.egiz.stal.SignRequest.ExcludedByteRange;
import at.gv.egiz.stal.SignRequest.SignedInfo;
import at.gv.egiz.stal.SignResponse;
import at.gv.egiz.stal.StatusRequest;
@@ -225,6 +226,12 @@ public class STALTranslator {
req.setSignedInfo(signedInfo);
req.setSignatureMethod(((SignRequest) request).getSignatureMethod());
req.setDigestMethod(((SignRequest) request).getDigestMethod());
+ if (((SignRequest) request).getExcludedByteRange() != null) {
+ SignRequestType.ExcludedByteRange excludedByteRange = of.createSignRequestTypeExcludedByteRange();
+ excludedByteRange.setFrom(((SignRequest) request).getExcludedByteRange().getFrom());
+ excludedByteRange.setTo(((SignRequest) request).getExcludedByteRange().getTo());
+ req.setExcludedByteRange(excludedByteRange);
+ }
//TODO add hashdatainput (refactor signRequestType)
return of.createGetNextRequestResponseTypeSignRequest(req);
} else if (request instanceof InfoboxReadRequest) {
@@ -257,6 +264,12 @@ public class STALTranslator {
stalReq.setSignedInfo(signedInfo);
stalReq.setSignatureMethod(((SignRequestType) request).getSignatureMethod());
stalReq.setDigestMethod(((SignRequestType) request).getDigestMethod());
+ if (((SignRequestType) request).getExcludedByteRange() != null) {
+ ExcludedByteRange excludedByteRange = new ExcludedByteRange();
+ excludedByteRange.setFrom(((SignRequestType) request).getExcludedByteRange().getFrom());
+ excludedByteRange.setTo(((SignRequestType) request).getExcludedByteRange().getTo());
+ stalReq.setExcludedByteRange(excludedByteRange);
+ }
return stalReq;
} else if (request instanceof QuitRequestType) {
return new QuitRequest();
diff --git a/STALService/src/main/java/at/gv/egiz/stal/service/types/ObjectFactory.java b/STALService/src/main/java/at/gv/egiz/stal/service/types/ObjectFactory.java
index f3b00402..ea7ca837 100644
--- a/STALService/src/main/java/at/gv/egiz/stal/service/types/ObjectFactory.java
+++ b/STALService/src/main/java/at/gv/egiz/stal/service/types/ObjectFactory.java
@@ -129,6 +129,14 @@ public class ObjectFactory {
}
/**
+ * Create an instance of {@link SignRequestType.ExcludedByteRange }
+ *
+ */
+ public SignRequestType.ExcludedByteRange createSignRequestTypeExcludedByteRange() {
+ return new SignRequestType.ExcludedByteRange();
+ }
+
+ /**
* Create an instance of {@link GetHashDataInputType.Reference }
*
*/
diff --git a/STALService/src/main/java/at/gv/egiz/stal/service/types/SignRequestType.java b/STALService/src/main/java/at/gv/egiz/stal/service/types/SignRequestType.java
index 67755d69..84ccdc8a 100644
--- a/STALService/src/main/java/at/gv/egiz/stal/service/types/SignRequestType.java
+++ b/STALService/src/main/java/at/gv/egiz/stal/service/types/SignRequestType.java
@@ -25,10 +25,13 @@
package at.gv.egiz.stal.service.types;
+import java.math.BigInteger;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
@@ -62,6 +65,16 @@ import javax.xml.bind.annotation.XmlValue;
* &lt;/element>
* &lt;element name="SignatureMethod" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="DigestMethod" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="ExcludedByteRange" minOccurs="0">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;attribute name="from" use="required" type="{http://www.w3.org/2001/XMLSchema}unsignedLong" />
+ * &lt;attribute name="to" use="required" type="{http://www.w3.org/2001/XMLSchema}unsignedLong" />
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
* &lt;/sequence>
* &lt;/extension>
* &lt;/complexContent>
@@ -75,7 +88,8 @@ import javax.xml.bind.annotation.XmlValue;
"keyIdentifier",
"signedInfo",
"signatureMethod",
- "digestMethod"
+ "digestMethod",
+ "excludedByteRange"
})
public class SignRequestType
extends RequestType
@@ -89,6 +103,8 @@ public class SignRequestType
protected String signatureMethod;
@XmlElement(name = "DigestMethod")
protected String digestMethod;
+ @XmlElement(name = "ExcludedByteRange")
+ protected SignRequestType.ExcludedByteRange excludedByteRange;
/**
* Gets the value of the keyIdentifier property.
@@ -186,6 +202,110 @@ public class SignRequestType
this.digestMethod = value;
}
+ /**
+ * Gets the value of the excludedByteRange property.
+ *
+ * @return
+ * possible object is
+ * {@link SignRequestType.ExcludedByteRange }
+ *
+ */
+ public SignRequestType.ExcludedByteRange getExcludedByteRange() {
+ return excludedByteRange;
+ }
+
+ /**
+ * Sets the value of the excludedByteRange property.
+ *
+ * @param value
+ * allowed object is
+ * {@link SignRequestType.ExcludedByteRange }
+ *
+ */
+ public void setExcludedByteRange(SignRequestType.ExcludedByteRange value) {
+ this.excludedByteRange = value;
+ }
+
+
+ /**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;attribute name="from" use="required" type="{http://www.w3.org/2001/XMLSchema}unsignedLong" />
+ * &lt;attribute name="to" use="required" type="{http://www.w3.org/2001/XMLSchema}unsignedLong" />
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "")
+ public static class ExcludedByteRange {
+
+ @XmlAttribute(required = true)
+ @XmlSchemaType(name = "unsignedLong")
+ protected BigInteger from;
+ @XmlAttribute(required = true)
+ @XmlSchemaType(name = "unsignedLong")
+ protected BigInteger to;
+
+ /**
+ * Gets the value of the from property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getFrom() {
+ return from;
+ }
+
+ /**
+ * Sets the value of the from property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setFrom(BigInteger value) {
+ this.from = value;
+ }
+
+ /**
+ * Gets the value of the to property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getTo() {
+ return to;
+ }
+
+ /**
+ * Sets the value of the to property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setTo(BigInteger value) {
+ this.to = value;
+ }
+
+ }
+
/**
* <p>Java class for anonymous complex type.
diff --git a/STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java b/STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java
index a82006fc..83adfe30 100644
--- a/STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java
+++ b/STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java
@@ -25,6 +25,8 @@
package at.gv.egiz.stal.service.translator;
+import java.math.BigInteger;
+
import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
import at.gv.egiz.stal.SignRequest;
@@ -107,6 +109,12 @@ public class STALTranslatorTest {
assertEquals(request.getSignedInfo().isIsCMSSignedAttributes(), resultT.getSignedInfo().isIsCMSSignedAttributes());
assertEquals(request.getSignatureMethod(), resultT.getSignatureMethod());
assertEquals(request.getDigestMethod(), resultT.getDigestMethod());
+ if (request.getExcludedByteRange() == null)
+ assertNull(resultT.getExcludedByteRange());
+ else {
+ assertEquals(request.getExcludedByteRange().getFrom(), resultT.getExcludedByteRange().getFrom());
+ assertEquals(request.getExcludedByteRange().getTo(), resultT.getExcludedByteRange().getTo());
+ }
}
/**
@@ -122,6 +130,10 @@ public class STALTranslatorTest {
req.setSignedInfo(signedInfo);
req.setSignatureMethod("signatureMethod");
req.setDigestMethod("digestMethod");
+ SignRequestType.ExcludedByteRange excludedByteRange = of.createSignRequestTypeExcludedByteRange();
+ excludedByteRange.setFrom(BigInteger.ZERO);
+ excludedByteRange.setTo(BigInteger.ONE);
+ req.setExcludedByteRange(excludedByteRange);
JAXBElement<? extends RequestType> request = of.createGetNextRequestResponseTypeSignRequest(req);
STALTranslator instance = new STALTranslator();
STALRequest result = instance.translateWSRequest(request);
@@ -131,6 +143,12 @@ public class STALTranslatorTest {
assertEquals(req.getSignedInfo().isIsCMSSignedAttributes(), ((SignRequest) result).getSignedInfo().isIsCMSSignedAttributes());
assertEquals(req.getSignatureMethod(), ((SignRequest) result).getSignatureMethod());
assertEquals(req.getDigestMethod(), ((SignRequest) result).getDigestMethod());
+ if (req.getExcludedByteRange() == null)
+ assertNull(((SignRequest) result).getExcludedByteRange());
+ else {
+ assertEquals(req.getExcludedByteRange().getFrom(), ((SignRequest) result).getExcludedByteRange().getFrom());
+ assertEquals(req.getExcludedByteRange().getTo(), ((SignRequest) result).getExcludedByteRange().getTo());
+ }
}
@Test(expected=RuntimeException.class)