summaryrefslogtreecommitdiff
path: root/STALService/src
diff options
context:
space:
mode:
authortkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-12-13 01:26:39 +0000
committertkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-12-13 01:26:39 +0000
commitd311d0f7b7ef9ed5bc383d6744b7d61239aafbc1 (patch)
treeb48a211d1a907ad7af72027b2b2709ecd540b27c /STALService/src
parent8d597612c69c77982c981f711f549bc826b06fd8 (diff)
downloadmocca-d311d0f7b7ef9ed5bc383d6744b7d61239aafbc1.tar.gz
mocca-d311d0f7b7ef9ed5bc383d6744b7d61239aafbc1.tar.bz2
mocca-d311d0f7b7ef9ed5bc383d6744b7d61239aafbc1.zip
Extend STAL to support CMS SignedAttributes
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1262 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.java137
-rw-r--r--STALService/src/test/java/at/gv/egiz/stal/service/translator/STALTranslatorTest.java18
4 files changed, 162 insertions, 14 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 26eeaf55..28d60ed6 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.SignedInfo;
import at.gv.egiz.stal.SignResponse;
import at.gv.egiz.stal.StatusRequest;
import at.gv.egiz.stal.StatusResponse;
@@ -218,7 +219,11 @@ public class STALTranslator {
if (request instanceof SignRequest) {
SignRequestType req = of.createSignRequestType();
req.setKeyIdentifier(((SignRequest) request).getKeyIdentifier());
- req.setSignedInfo(((SignRequest) request).getSignedInfo());
+ SignRequestType.SignedInfo signedInfo = of.createSignRequestTypeSignedInfo();
+ signedInfo.setValue(((SignRequest) request).getSignedInfo().getValue());
+ signedInfo.setIsCMSSignedAttributes(((SignRequest) request).getSignedInfo().isIsCMSSignedAttributes());
+ req.setSignedInfo(signedInfo);
+ req.setSignatureMethod(((SignRequest) request).getSignatureMethod());
//TODO add hashdatainput (refactor signRequestType)
return of.createGetNextRequestResponseTypeSignRequest(req);
} else if (request instanceof InfoboxReadRequest) {
@@ -245,7 +250,11 @@ public class STALTranslator {
} else if (request instanceof SignRequestType) {
SignRequest stalReq = new SignRequest();
stalReq.setKeyIdentifier(((SignRequestType) request).getKeyIdentifier());
- stalReq.setSignedInfo(((SignRequestType) request).getSignedInfo());
+ SignedInfo signedInfo = new SignedInfo();
+ signedInfo.setValue(((SignRequestType) request).getSignedInfo().getValue());
+ signedInfo.setIsCMSSignedAttributes(((SignRequestType) request).getSignedInfo().isIsCMSSignedAttributes());
+ stalReq.setSignedInfo(signedInfo);
+ stalReq.setSignatureMethod(((SignRequestType) request).getSignatureMethod());
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 90479808..f3b00402 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
@@ -121,6 +121,14 @@ public class ObjectFactory {
}
/**
+ * Create an instance of {@link SignRequestType.SignedInfo }
+ *
+ */
+ public SignRequestType.SignedInfo createSignRequestTypeSignedInfo() {
+ return new SignRequestType.SignedInfo();
+ }
+
+ /**
* 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 8249491c..50a00406 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
@@ -27,8 +27,10 @@ package at.gv.egiz.stal.service.types;
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.XmlType;
+import javax.xml.bind.annotation.XmlValue;
/**
@@ -49,7 +51,16 @@ import javax.xml.bind.annotation.XmlType;
* &lt;/restriction>
* &lt;/simpleType>
* &lt;/element>
- * &lt;element name="SignedInfo" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
+ * &lt;element name="SignedInfo">
+ * &lt;complexType>
+ * &lt;simpleContent>
+ * &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>base64Binary">
+ * &lt;attribute name="IsCMSSignedAttributes" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * &lt;/extension>
+ * &lt;/simpleContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;element name="SignatureMethod" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;/extension>
* &lt;/complexContent>
@@ -61,7 +72,8 @@ import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SignRequestType", propOrder = {
"keyIdentifier",
- "signedInfo"
+ "signedInfo",
+ "signatureMethod"
})
public class SignRequestType
extends RequestType
@@ -70,7 +82,9 @@ public class SignRequestType
@XmlElement(name = "KeyIdentifier", required = true)
protected String keyIdentifier;
@XmlElement(name = "SignedInfo", required = true)
- protected byte[] signedInfo;
+ protected SignRequestType.SignedInfo signedInfo;
+ @XmlElement(name = "SignatureMethod")
+ protected String signatureMethod;
/**
* Gets the value of the keyIdentifier property.
@@ -101,9 +115,10 @@ public class SignRequestType
*
* @return
* possible object is
- * byte[]
+ * {@link SignRequestType.SignedInfo }
+ *
*/
- public byte[] getSignedInfo() {
+ public SignRequestType.SignedInfo getSignedInfo() {
return signedInfo;
}
@@ -112,10 +127,116 @@ public class SignRequestType
*
* @param value
* allowed object is
- * byte[]
+ * {@link SignRequestType.SignedInfo }
+ *
+ */
+ public void setSignedInfo(SignRequestType.SignedInfo value) {
+ this.signedInfo = value;
+ }
+
+ /**
+ * Gets the value of the signatureMethod property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSignatureMethod() {
+ return signatureMethod;
+ }
+
+ /**
+ * Sets the value of the signatureMethod property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSignatureMethod(String value) {
+ this.signatureMethod = 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;simpleContent>
+ * &lt;extension base="&lt;http://www.w3.org/2001/XMLSchema>base64Binary">
+ * &lt;attribute name="IsCMSSignedAttributes" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * &lt;/extension>
+ * &lt;/simpleContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
*/
- public void setSignedInfo(byte[] value) {
- this.signedInfo = ((byte[]) value);
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "value"
+ })
+ public static class SignedInfo {
+
+ @XmlValue
+ protected byte[] value;
+ @XmlAttribute(name = "IsCMSSignedAttributes")
+ protected Boolean isCMSSignedAttributes;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setValue(byte[] value) {
+ this.value = ((byte[]) value);
+ }
+
+ /**
+ * Gets the value of the isCMSSignedAttributes property.
+ *
+ * @return
+ * possible object is
+ * {@link Boolean }
+ *
+ */
+ public boolean isIsCMSSignedAttributes() {
+ if (isCMSSignedAttributes == null) {
+ return false;
+ } else {
+ return isCMSSignedAttributes;
+ }
+ }
+
+ /**
+ * Sets the value of the isCMSSignedAttributes property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Boolean }
+ *
+ */
+ public void setIsCMSSignedAttributes(Boolean value) {
+ this.isCMSSignedAttributes = value;
+ }
+
}
}
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 8331c993..98d301a7 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
@@ -28,6 +28,7 @@ package at.gv.egiz.stal.service.translator;
import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
import at.gv.egiz.stal.SignRequest;
+import at.gv.egiz.stal.SignRequest.SignedInfo;
import at.gv.egiz.stal.service.translator.STALTranslator.TranslationHandler;
import at.gv.egiz.stal.service.types.ObjectFactory;
import at.gv.egiz.stal.service.types.RequestType;
@@ -94,13 +95,17 @@ public class STALTranslatorTest {
System.out.println("translate");
SignRequest request = new SignRequest();
request.setKeyIdentifier("kid");
- request.setSignedInfo("signedinfo".getBytes());
+ SignedInfo signedInfo = new SignedInfo();
+ signedInfo.setValue("signedinfo".getBytes());
+ request.setSignedInfo(signedInfo);
STALTranslator instance = new STALTranslator();
JAXBElement<? extends RequestType> result = instance.translate(request);
assertEquals(SignRequestType.class, result.getValue().getClass());
SignRequestType resultT = (SignRequestType) result.getValue();
assertEquals(request.getKeyIdentifier(), resultT.getKeyIdentifier());
- assertEquals(request.getSignedInfo(), resultT.getSignedInfo());
+ assertEquals(request.getSignedInfo().getValue(), resultT.getSignedInfo().getValue());
+ assertEquals(request.getSignedInfo().isIsCMSSignedAttributes(), resultT.getSignedInfo().isIsCMSSignedAttributes());
+ assertEquals(request.getSignatureMethod(), resultT.getSignatureMethod());
}
/**
@@ -111,13 +116,18 @@ public class STALTranslatorTest {
System.out.println("translate");
SignRequestType req = of.createSignRequestType();
req.setKeyIdentifier("kid");
- req.setSignedInfo("signedinfo".getBytes());
+ SignRequestType.SignedInfo signedInfo = of.createSignRequestTypeSignedInfo();
+ signedInfo.setValue("signedinfo".getBytes());
+ req.setSignedInfo(signedInfo);
+ req.setSignatureMethod("signatureMethod");
JAXBElement<? extends RequestType> request = of.createGetNextRequestResponseTypeSignRequest(req);
STALTranslator instance = new STALTranslator();
STALRequest result = instance.translateWSRequest(request);
assertEquals(SignRequest.class, result.getClass());
assertEquals(req.getKeyIdentifier(), ((SignRequest) result).getKeyIdentifier());
- assertEquals(req.getSignedInfo(), ((SignRequest) result).getSignedInfo());
+ assertEquals(req.getSignedInfo().getValue(), ((SignRequest) result).getSignedInfo().getValue());
+ assertEquals(req.getSignedInfo().isIsCMSSignedAttributes(), ((SignRequest) result).getSignedInfo().isIsCMSSignedAttributes());
+ assertEquals(req.getSignatureMethod(), ((SignRequest) result).getSignatureMethod());
}
@Test(expected=RuntimeException.class)