summaryrefslogtreecommitdiff
path: root/bkucommon/src/test
diff options
context:
space:
mode:
authorwbauer <wbauer@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-03-13 07:49:49 +0000
committerwbauer <wbauer@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-03-13 07:49:49 +0000
commit2882e14d19cfa58ea382083434210aaf0cfea3e3 (patch)
tree55aca764e9655556b05260e339ac86edce180886 /bkucommon/src/test
parent7cc403b3ce468e82a57811336def347cb6c9025e (diff)
downloadmocca-2882e14d19cfa58ea382083434210aaf0cfea3e3.tar.gz
mocca-2882e14d19cfa58ea382083434210aaf0cfea3e3.tar.bz2
mocca-2882e14d19cfa58ea382083434210aaf0cfea3e3.zip
Fixed Bug#405 and added according test case
Fixed Bug#402 Added Feature#403 git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@320 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'bkucommon/src/test')
-rw-r--r--bkucommon/src/test/java/at/gv/egiz/bku/binding/EmptyMultipartSLRequestTest.java96
-rw-r--r--bkucommon/src/test/resources/at/gv/egiz/bku/binding/MultipartEmpty.txt17
2 files changed, 113 insertions, 0 deletions
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/EmptyMultipartSLRequestTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/EmptyMultipartSLRequestTest.java
new file mode 100644
index 00000000..dd315f7f
--- /dev/null
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/EmptyMultipartSLRequestTest.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.binding;
+
+import iaik.security.ecc.provider.ECCProvider;
+import iaik.security.provider.IAIK;
+import iaik.xml.crypto.XSecProvider;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.security.Provider;
+import java.security.Security;
+import java.security.Provider.Service;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+import at.gv.egiz.bku.conf.Configurator;
+import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
+
+public class EmptyMultipartSLRequestTest {
+
+ private static Log log = LogFactory.getLog(EmptyMultipartSLRequestTest.class);
+
+ protected String resourceName = "at/gv/egiz/bku/binding/MultipartEmpty.txt";
+
+ protected BindingProcessor bindingProcessor;
+ protected InputStream dataStream;
+ protected BindingProcessorManager manager;
+
+ @Before
+ public void setUp() throws MalformedURLException, ClassNotFoundException {
+ manager = new BindingProcessorManagerImpl(new DummyStalFactory(),
+ new SLCommandInvokerImpl());
+ HTTPBindingProcessor http = (HTTPBindingProcessor) manager
+ .createBindingProcessor("http://www.at/", null);
+ Map<String, String> headers = new HashMap<String, String>();
+ headers.put("Content-Type", InputDecoderFactory.MULTIPART_FORMDATA
+ + ";boundary=uW10q_I9UeqKyw-1o5EW4jtEAaGs7-mC6o");
+ http.setHTTPHeaders(headers);
+ dataStream = getClass().getClassLoader().getResourceAsStream(resourceName);
+ bindingProcessor = http;
+ Map<String, String> commandMap = new HashMap<String, String>();
+ commandMap
+ .put(
+ "http://www.buergerkarte.at/namespaces/securitylayer/1.2#:CreateXMLSignatureRequest",
+ "at.gv.egiz.bku.slcommands.impl.CreateXMLSignatureCommandImpl");
+ commandMap
+ .put(
+ "http://www.buergerkarte.at/namespaces/securitylayer/1.2#:InfoboxReadRequest",
+ "at.gv.egiz.bku.slcommands.impl.InfoboxReadCommandImpl");
+ SLCommandFactory.getInstance().setCommandImpl(commandMap);
+ Security.insertProviderAt(new IAIK(), 1);
+ Security.insertProviderAt(new ECCProvider(false), 2);
+ XSecProvider.addAsProvider(false);
+ // registering STALProvider as delegation provider for XSECT
+ STALProvider stalProvider = new STALProvider();
+ Security.addProvider(stalProvider);
+ Set<Service> services = stalProvider.getServices();
+ StringBuilder sb = new StringBuilder();
+ for (Service service : services) {
+ String algorithm = service.getType() + "." + service.getAlgorithm();
+ XSecProvider.setDelegationProvider(algorithm, stalProvider.getName());
+ sb.append("\n" + algorithm);
+ }
+ log.debug(sb);
+ }
+
+ @Test
+ public void testBasicNop() {
+ bindingProcessor.consumeRequestStream(dataStream);
+ // manager.process(bindingProcessor);
+ bindingProcessor.run();
+ }
+
+}
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/binding/MultipartEmpty.txt b/bkucommon/src/test/resources/at/gv/egiz/bku/binding/MultipartEmpty.txt
new file mode 100644
index 00000000..97c29894
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/binding/MultipartEmpty.txt
@@ -0,0 +1,17 @@
+POST /http-security-layer-request HTTP/1.1
+User-Agent: Jakarta Commons-HttpClient/3.0
+Host: 127.0.0.1:13495
+Content-Length: 855
+Content-Type: multipart/form-data; boundary=uW10q_I9UeqKyw-1o5EW4jtEAaGs7-mC6o
+
+--uW10q_I9UeqKyw-1o5EW4jtEAaGs7-mC6o
+Content-Disposition: form-data; name="XMLRequest"
+
+<?xml version="1.0" encoding="UTF-8"?><sl:CreateXMLSignatureRequest xmlns:sl="http://www.buergerkarte.at/namespaces/securitylayer/1.2#"><sl:KeyboxIdentifier>SecureSignatureKeypair</sl:KeyboxIdentifier><sl:DataObjectInfo Structure="detached"><sl:DataObject Reference="urn:Document"><sl:LocRefContent>formdata:fileupload</sl:LocRefContent></sl:DataObject><sl:TransformsInfo><sl:FinalDataMetaInfo><sl:MimeType>text/plain</sl:MimeType></sl:FinalDataMetaInfo></sl:TransformsInfo></sl:DataObjectInfo></sl:CreateXMLSignatureRequest>
+--uW10q_I9UeqKyw-1o5EW4jtEAaGs7-mC6o
+Content-Disposition: form-data; name="fileupload"; filename="myfile.txt"
+Content-Type: text/plain; charset=ISO-8859-1
+Content-Transfer-Encoding: binary
+
+
+--uW10q_I9UeqKyw-1o5EW4jtEAaGs7-mC6o--