summaryrefslogtreecommitdiff
path: root/bkucommon
diff options
context:
space:
mode:
Diffstat (limited to 'bkucommon')
-rw-r--r--bkucommon/pom.xml80
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java16
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java4
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java3
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java59
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java1
-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
8 files changed, 224 insertions, 52 deletions
diff --git a/bkucommon/pom.xml b/bkucommon/pom.xml
index ccc1814d..5084abcb 100644
--- a/bkucommon/pom.xml
+++ b/bkucommon/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>bku</artifactId>
<groupId>at.gv.egiz</groupId>
@@ -10,7 +11,43 @@
<artifactId>bkucommon</artifactId>
<name>BKU Common</name>
<version>1.0.5-SNAPSHOT</version>
- <url>http://maven.apache.org</url>
+
+ <build>
+ <plugins>
+ <!--
+ plugin> <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId> <executions> <execution>
+ <id>MOA-SPSS</id> <goals> <goal>wsimport</goal> </goals>
+ </execution> </executions> <configuration>
+ <extension>true</extension> <verbose>true</verbose>
+ <packageName>moaspss.generated</packageName>
+ <wsdlDirectory>${basedir}/src/test/wsdl</wsdlDirectory> <wsdlFiles>
+ <wsdlFile>MOA-SPSS-1.3.wsdl</wsdlFile> </wsdlFiles>
+ <sourceDestDir>${project.build.directory}/generated-sources/moaspss</sourceDestDir>
+ <staleFile>${project.build.directory}/generated-sources/moaspss/.staleFlag</staleFile>
+ <xnocompile>true</xnocompile> </configuration> </plugin
+ -->
+ <!--
+ skip tests temporarily <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId> <configuration>
+ <skip>true</skip> </configuration> </plugin
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ </manifest>
+ <manifestEntries>
+ <SignatureLayout>1.0</SignatureLayout>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<dependency>
<groupId>at.gv.egiz</groupId>
@@ -58,35 +95,14 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <scope>test</scope>
- </dependency>
- <!-- dependency to ensure NamespacePrefixmapper -->
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- </dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- dependency to ensure NamespacePrefixmapper -->
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </dependency>
</dependencies>
- <build>
- <plugins>
- <!--
- plugin> <groupId>org.codehaus.mojo</groupId>
- <artifactId>jaxws-maven-plugin</artifactId> <executions> <execution>
- <id>MOA-SPSS</id> <goals> <goal>wsimport</goal> </goals>
- </execution> </executions> <configuration>
- <extension>true</extension> <verbose>true</verbose>
- <packageName>moaspss.generated</packageName>
- <wsdlDirectory>${basedir}/src/test/wsdl</wsdlDirectory> <wsdlFiles>
- <wsdlFile>MOA-SPSS-1.3.wsdl</wsdlFile> </wsdlFiles>
- <sourceDestDir>${project.build.directory}/generated-sources/moaspss</sourceDestDir>
- <staleFile>${project.build.directory}/generated-sources/moaspss/.staleFlag</staleFile>
- <xnocompile>true</xnocompile> </configuration> </plugin -->
- <!--
- skip tests temporarily <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId> <configuration>
- <skip>true</skip> </configuration> </plugin -->
- </plugins>
- </build>
</project> \ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
index 4c235456..c8bddbbd 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
@@ -225,10 +225,17 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
this.url = url;
boundary = "--" + IdFactory.getInstance().createId().toString();
requestHttpHeaders = new HashMap<String, String>();
- if ((config != null)
- && (config.getProperty(Configurator.USERAGENT_CONFIG_P) != null)) {
- requestHttpHeaders.put(HttpUtil.HTTP_HEADER_USER_AGENT, config
- .getProperty(Configurator.USERAGENT_CONFIG_P));
+
+ if (config != null) {
+ String sigLayout="";
+ String version = config.getProperty(Configurator.SIGNATURE_LAYOUT);
+ if ((version != null) && (!"".equals(version.trim()))) {
+ requestHttpHeaders.put(Configurator.SIGNATURE_LAYOUT, version);
+ } else {
+ log.debug("Do not set siglayout header");
+ }
+ String userAgent = config.getProperty(Configurator.USERAGENT_CONFIG_P, Configurator.USERAGENT_DEFAULT);
+ requestHttpHeaders.put(HttpUtil.HTTP_HEADER_USER_AGENT, userAgent);
} else {
requestHttpHeaders
.put(HttpUtil.HTTP_HEADER_USER_AGENT, Configurator.USERAGENT_DEFAULT);
@@ -251,6 +258,7 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
DataUrlConnectionSPI uc = new DataUrlConnectionImpl();
uc.setConfiguration(config);
uc.setSSLSocketFactory(sslSocketFactory);
+ uc.setHostnameVerifier(hostnameVerifier);
return uc;
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java
index 43f42331..d0b2dac1 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java
@@ -672,10 +672,10 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
} else {
FormParameterStore fps = new FormParameterStore();
fps.init(fp);
- if (!fps.isEmpty()) {
+ //if (!fps.isEmpty()) {
log.debug("Setting form parameter: " + fps.getFormParameterName());
formParameterMap.put(fps.getFormParameterName(), fps);
- }
+ //}
}
}
if (slCommand == null) {
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java
index b11a4d85..5ea7b25e 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java
@@ -29,7 +29,8 @@ public class HttpUtil {
public final static String CHAR_SET = "charset";
public final static String DEFAULT_CHARSET = "ISO-8859-1";
public final static String HTTP_HEADER_CONTENT_TYPE = "Content-Type";
- public static final String HTTP_HEADER_USER_AGENT = "User-Agent";
+ public static final String HTTP_HEADER_USER_AGENT = "User-Agent";
+ public static final String HTTP_HEADER_SERVER = "Server";
public final static String HTTP_HEADER_REFERER = "Referer";
public final static String CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding";
public final static String MULTIPART_FOTMDATA = "multipart/form-data";
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
index 6213ffcf..8a94e88d 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java
@@ -9,6 +9,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
+import java.net.URL;
import java.security.GeneralSecurityException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
@@ -26,6 +27,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
@@ -39,7 +42,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import at.gv.egiz.bku.binding.DataUrl;
-import at.gv.egiz.bku.binding.DataUrlConnection;
import at.gv.egiz.bku.slcommands.impl.xsect.DataObject;
import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
@@ -55,10 +57,12 @@ public abstract class Configurator {
public static final String USERAGENT_DEFAULT = "citizen-card-environment/1.2 MOCCA/UNKNOWN";
public static final String USERAGENT_BASE = "citizen-card-environment/1.2 MOCCA/";
+ public static final String SIGNATURE_LAYOUT = "SignatureLayout";
protected Properties properties;
protected CertValidator certValidator;
+ protected String signaturLayoutVersion;
protected Configurator() {
}
@@ -161,7 +165,7 @@ public abstract class Configurator {
log.debug("Registering security providers");
Security.insertProviderAt(new IAIK(), 1);
Security.insertProviderAt(new ECCProvider(false), 2);
-
+
// registering STALProvider as delegation provider for XSECT
STALProvider stalProvider = new STALProvider();
Set<Service> services = stalProvider.getServices();
@@ -171,8 +175,10 @@ public abstract class Configurator {
XSecProvider.setDelegationProvider(algorithm, stalProvider.getName());
sb.append("\n" + algorithm);
}
- log.debug("Registered STALProvider as XSecProvider delegation provider for the following services : " + sb.toString());
-
+ log
+ .debug("Registered STALProvider as XSecProvider delegation provider for the following services : "
+ + sb.toString());
+
Security.addProvider(stalProvider);
XSecProvider.addAsProvider(false);
sb = new StringBuilder();
@@ -193,6 +199,31 @@ public abstract class Configurator {
}
}
+ public void configureSingatureLayoutVersion() {
+ if (properties.get(SIGNATURE_LAYOUT) == null) {
+ try {
+ String classContainer = Configurator.class.getProtectionDomain()
+ .getCodeSource().getLocation().toString();
+ URL manifestUrl = new URL("jar:" + classContainer
+ + "!/META-INF/MANIFEST.MF");
+ Manifest manifest = new Manifest(manifestUrl.openStream());
+ Attributes att = manifest.getMainAttributes();
+ String layout = null;
+ if (att != null) {
+ layout = att.getValue(SIGNATURE_LAYOUT);
+ }
+ if (layout != null) {
+ log.info("Setting signature layout to: " + layout);
+ properties.put(SIGNATURE_LAYOUT, layout);
+ } else {
+ log.warn("No signature layout version defined");
+ }
+ } catch (Exception ex) {
+ log.warn("Cannot read manifest", ex);
+ }
+ }
+ }
+
public void configureNetwork() {
String proxy = getProperty("HTTPProxyHost");
String portString = getProperty("HTTPProxyPort");
@@ -217,15 +248,15 @@ public abstract class Configurator {
if (is != null) {
p.load(getManifest());
String version = p.getProperty("Implementation-Build");
- properties.setProperty(USERAGENT_CONFIG_P,
- USERAGENT_BASE + version);
+ if (version == null) {
+ version="UNKNOWN";
+ }
+ properties.setProperty(USERAGENT_CONFIG_P, USERAGENT_BASE + version);
log.debug("Setting user agent to: "
- + properties
- .getProperty(USERAGENT_CONFIG_P));
+ + properties.getProperty(USERAGENT_CONFIG_P));
} else {
log.warn("Cannot read manifest");
- properties.setProperty(USERAGENT_CONFIG_P,
- USERAGENT_DEFAULT);
+ properties.setProperty(USERAGENT_CONFIG_P, USERAGENT_DEFAULT);
}
} catch (IOException e) {
log.error(e);
@@ -240,6 +271,7 @@ public abstract class Configurator {
configViewer();
configureSSL();
configureVersion();
+ configureSingatureLayoutVersion();
configureNetwork();
}
@@ -280,11 +312,14 @@ public abstract class Configurator {
sslCtx.init(km, new TrustManager[] { pkixTM }, null);
}
DataUrl.setSSLSocketFactory(sslCtx.getSocketFactory());
- URLDereferencer.getInstance().setSSLSocketFactory(sslCtx.getSocketFactory());
+ URLDereferencer.getInstance().setSSLSocketFactory(
+ sslCtx.getSocketFactory());
} catch (Exception e) {
log.error("Cannot configure SSL", e);
}
- if ((disableAll != null && Boolean.parseBoolean(disableAll)) || (disableHostnameVerification != null && Boolean.parseBoolean(disableHostnameVerification))) {
+ if ((disableAll != null && Boolean.parseBoolean(disableAll))
+ || (disableHostnameVerification != null && Boolean
+ .parseBoolean(disableHostnameVerification))) {
log.warn("---------------------------------");
log.warn(" Disabling Hostname Verification ");
log.warn("---------------------------------");
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java
index a6399c9b..f5394157 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java
@@ -105,7 +105,6 @@ public class LocRefDereferencer implements URIDereferencer {
throw new URIReferenceException("Failed to dereference URI '" + locRef
+ "'. " + e.getMessage(), e);
}
-
return new OctetStreamData(streamData.getStream(), locRef, streamData
.getContentType());
}
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--