From 32d17447a258188b2d534bcb0bf65a659ba7b7d0 Mon Sep 17 00:00:00 2001
From: mcentner
Date: Fri, 29 Aug 2008 12:11:34 +0000
Subject: Initial import.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../egiz/bku/slcommands/impl/ErrorResultImpl.java | 60 ++++++++++++++++++++++
1 file changed, 60 insertions(+)
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
(limited to 'bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java')
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
new file mode 100644
index 00000000..555f83bd
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
@@ -0,0 +1,60 @@
+/*
+* 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.slcommands.impl;
+
+import at.buergerkarte.namespaces.securitylayer._1.ErrorResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+import at.gv.egiz.bku.slcommands.ErrorResult;
+import at.gv.egiz.bku.slexceptions.SLException;
+
+import javax.xml.transform.Result;
+
+/**
+ * This class implements the security layer result ErrorResponse.
+ *
+ * @author mcentner
+ */
+public class ErrorResultImpl extends SLResultImpl implements ErrorResult {
+
+ /**
+ * The exception containing information provided in the ErrorResponse.
+ */
+ protected SLException slException;
+
+ /**
+ * Creates a new instance of this ErrorResultImpl with the given
+ * slException containing information provided in the
+ * ErrorResponse.
+ *
+ * @param slException the exception
+ */
+ public ErrorResultImpl(SLException slException) {
+ this.slException = slException;
+ }
+
+ @Override
+ public void writeTo(Result result) {
+
+ ObjectFactory factory = new ObjectFactory();
+ ErrorResponseType responseType = factory.createErrorResponseType();
+ responseType.setErrorCode(slException.getErrorCode());
+ responseType.setInfo(slException.getDetailedMsg());
+
+ writeTo(factory.createErrorResponse(responseType), result);
+
+ }
+}
\ No newline at end of file
--
cgit v1.2.3
From 76bb812a3254be530e403f8db8c01323a31b30c1 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Thu, 11 Sep 2008 13:03:44 +0000
Subject: git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@33
8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKUOnline/pom.xml | 317 ++++++++-------
.../at/gv/egiz/bku/online/conf/Configurator.java | 21 +-
.../egiz/bku/online/conf/SpringConfigurator.java | 17 +
.../gv/egiz/bku/online/webapp/ResultServlet.java | 246 ++++++------
.../egiz/bku/online/webapp/SpringBKUServlet.java | 6 +-
.../gv/egiz/bku/online/conf/defaultConf.properties | 2 +
BKUOnline/src/main/resources/log4j.properties | 21 +-
.../src/main/webapp/WEB-INF/applicationContext.xml | 4 +-
BKUOnline/src/main/webapp/appletPage.jsp | 8 +-
.../main/java/at/gv/egiz/bku/binding/DataUrl.java | 22 +-
.../at/gv/egiz/bku/binding/DataUrlConnection.java | 6 +-
.../gv/egiz/bku/binding/DataUrlConnectionImpl.java | 444 +++++++++++----------
.../gv/egiz/bku/binding/DataUrlConnectionSPI.java | 9 +-
.../egiz/bku/slcommands/impl/ErrorResultImpl.java | 14 +-
.../slexceptions/SLExceptionMessages.properties | 165 ++++----
.../slexceptions/SLExceptionMessages_en.properties | 97 +++++
.../gv/egiz/bku/binding/TestDataUrlConnection.java | 9 +-
17 files changed, 812 insertions(+), 596 deletions(-)
create mode 100644 bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties
(limited to 'bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java')
diff --git a/BKUOnline/pom.xml b/BKUOnline/pom.xml
index a0e45cf6..d31367a8 100644
--- a/BKUOnline/pom.xml
+++ b/BKUOnline/pom.xml
@@ -1,141 +1,180 @@
-
-
- bku
- at.gv.egiz
- 1.0-SNAPSHOT
-
- 4.0.0
- at.gv.egiz
- BKUOnline
- war
- BKU Online
- 1.0-SNAPSHOT
-
-
- at.gv.egiz
- bkucommon
- 1.0-SNAPSHOT
-
-
- commons-logging
- commons-logging
-
-
- org.springframework
- spring-core
- 2.5.5
-
-
- javax.servlet
- servlet-api
- 2.5
- provided
-
-
- org.springframework
- spring-web
- 2.5.5
-
-
- at.gv.egiz
- STALService
- 1.0-SNAPSHOT
- compile
-
-
-
-
- com.sun.xml.ws
-
- jaxws-rt
- 2.1.4
-
-
-
-
-
- Tomcat60
-
-
-
-
- maven-dependency-plugin
-
-
- copyapplet
-
- copy
-
-
-
-
- at.gv.egiz
- BKUApplet
- 1.0-SNAPSHOT
-
-
- commons-logging
- commons-logging
-
-
- iaik
- iaik_jce_me4se
-
-
- ${project.build.directory}/${project.build.finalName}/applet
-
-
-
-
-
-
-
+
+
+ bku
+ at.gv.egiz
+ 1.0-SNAPSHOT
+
+ 4.0.0
+ at.gv.egiz
+ BKUOnline
+ war
+ BKU Online
+ 1.0-SNAPSHOT
+
+
+
+ tlc
+ TLC Repository
+ http://commons.ucalgary.ca/pub/m2
+
+
+
+
+
+ at.gv.egiz
+ bkucommon
+ 1.0-SNAPSHOT
+
+
+ at.gv.egiz
+ BKUViewer
+ 1.0-SNAPSHOT
+
+
+ commons-logging
+ commons-logging
+
+
+ org.springframework
+ spring-core
+ 2.5.5
+
+
+ javax.servlet
+ servlet-api
+ 2.5
+ provided
+
+
+ org.springframework
+ spring-web
+ 2.5.5
+
+
+ at.gv.egiz
+ STALService
+ 1.0-SNAPSHOT
+ compile
+
+
+
+
+ com.sun.xml.ws
+
+ jaxws-rt
+ 2.1.4
+
+
+
+
+
+ Tomcat60
+
+
+ scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/trunk/BKUOnline
+ scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/trunk/BKUOnline
+ scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/trunk/BKUOnline
+
+
+
+
+ maven-dependency-plugin
+
+
+ copyapplet
+
+ copy
+
+
+
+
+ at.gv.egiz
+ BKUApplet
+ 1.0-SNAPSHOT
+
+
+ commons-logging
+ commons-logging
+
+
+ iaik
+ iaik_jce_me4se
+
+
+ ${project.build.directory}/${project.build.finalName}/applet
+
+
+
+
+
+
+ maven-war-plugin
+ 2.0.2
+
+
+
+ true
+
+
+
+
+
+ ${project.version}-r${buildNumber}
+
+
+
+
+
+
+ org.codehaus.mojo
+ maven-buildnumber-plugin
+ 0.9.6
+
+
+ validate
+
+ create
+
+
+
+
+ false
+ false
+
+
+
+
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
index de577139..c09abcc1 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
@@ -17,8 +17,10 @@
package at.gv.egiz.bku.online.conf;
import iaik.security.ecc.provider.ECCProvider;
+import iaik.security.provider.IAIK;
import iaik.xml.crypto.XSecProvider;
+import java.io.IOException;
import java.net.HttpURLConnection;
import java.security.Provider;
import java.security.Security;
@@ -29,22 +31,30 @@ import javax.net.ssl.HttpsURLConnection;
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 iaik.security.provider.IAIK;
/**
*
* TODO currently only the code to get started.
*/
-public class Configurator {
+public abstract class Configurator {
private Log log = LogFactory.getLog(Configurator.class);
+
+ private static Configurator instance = new SpringConfigurator();
protected Properties properties;
- public Configurator() {
+ protected Configurator() {
}
+ public static Configurator getInstance() {
+ return instance;
+ }
+
protected void configUrlConnections() {
HttpsURLConnection.setFollowRedirects(false);
HttpURLConnection.setFollowRedirects(false);
@@ -65,9 +75,14 @@ public class Configurator {
log.debug(sb.toString());
}
+ protected void configViewer() {
+ DataObject.enableHashDataInputValidation(Boolean.parseBoolean(properties.getProperty("ValidateHashDataInputs")));
+ }
+
public void configure() {
configureProviders();
configUrlConnections();
+ configViewer();
}
public void setConfiguration(Properties props) {
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
index 545a69c9..9fe91708 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/SpringConfigurator.java
@@ -49,6 +49,8 @@ import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
+import at.gv.egiz.bku.binding.DataUrl;
+import at.gv.egiz.bku.binding.DataUrlConnection;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
public class SpringConfigurator extends Configurator implements
@@ -71,9 +73,24 @@ public class SpringConfigurator extends Configurator implements
}
}
+ public void configureVersion() {
+ Properties p = new Properties();
+ try {
+ p.load(resourceLoader.getResource("META-INF/MANIFEST.MF").getInputStream());
+ String version = p.getProperty("Implementation-Build");
+ properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY, "citizen-card-environment/1.2 MOCCA "+version);
+ DataUrl.setConfiguration(properties);
+ log.debug("Setting user agent to: "+properties.getProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY));
+ } catch (IOException e) {
+ log.error(e);
+ }
+ }
+
+
public void configure() {
super.configure();
configureSSL();
+ configureVersion();
}
private Set getCACerts() throws IOException,
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
index bc3edf18..28c714c1 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
@@ -1,121 +1,129 @@
/*
-* 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.online.webapp;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.binding.HTTPBindingProcessor;
-import at.gv.egiz.bku.binding.IdFactory;
-
-/**
- * Delivers the result to the browser
- *
- */
-public class ResultServlet extends SpringBKUServlet {
-
- private final static Log log = LogFactory.getLog(ResultServlet.class);
-
- private String encoding = "UTF-8";
- private String expiredPage = "./expiredError.jsp";
-
- public ResultServlet() {
- }
-
- private void myInit() {
- String enc = getServletContext().getInitParameter("responseEncoding");
- if (enc != null) {
- log.debug("Init default encoding to: "+enc);
- encoding = enc;
- }
- String expP = getServletConfig().getInitParameter("expiredPage");
- if (expP != null) {
- log.debug("Init expired page to: "+expP);
- expiredPage = expP;
- }
- }
-
- @Override
- public void init() throws ServletException {
- super.init();
- myInit();
- }
-
- @Override
- public void init(ServletConfig config) throws ServletException {
- super.init(config);
- myInit();
- }
-
-
-
- protected void doPost(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
- doGet(req, resp);
- }
-
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, java.io.IOException {
-
- HttpSession session = req.getSession(false);
- if (session == null) {
- resp.sendRedirect(expiredPage);
- return;
- }
- String sessionId = session.getId();
- if (sessionId == null) {
- resp.sendRedirect(expiredPage);
- return;
- }
- log.debug("Got a result request for session: " + sessionId);
- HTTPBindingProcessor bp = (HTTPBindingProcessor) getBindingProcessorManager().getBindingProcessor(
- IdFactory.getInstance().createId(sessionId));
- if (bp == null) {
- session.invalidate();
- resp.sendRedirect(expiredPage);
- return;
- }
-
- if (bp.getRedirectURL() != null) {
- resp.sendRedirect(bp.getRedirectURL());
- return;
- }
- resp.setStatus(bp.getResponseCode());
- resp.setHeader("Cache-Control","no-store"); //HTTP 1.1
- resp.setHeader("Pragma","no-cache"); //HTTP 1.0
- resp.setDateHeader ("Expires", 0);
- for (Iterator it = bp.getResponseHeaders().keySet()
- .iterator(); it.hasNext();) {
- String header = it.next();
- resp.setHeader(header, bp.getResponseHeaders().get(header));
- }
- resp.setContentType(bp.getResultContentType());
- resp.setCharacterEncoding(encoding);
- bp.writeResultTo(resp.getOutputStream(), encoding);
+ * 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.online.webapp;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.binding.HTTPBindingProcessor;
+import at.gv.egiz.bku.binding.HttpUtil;
+import at.gv.egiz.bku.binding.IdFactory;
+import at.gv.egiz.bku.online.conf.Configurator;
+
+/**
+ * Delivers the result to the browser
+ *
+ */
+public class ResultServlet extends SpringBKUServlet {
+
+ private final static Log log = LogFactory.getLog(ResultServlet.class);
+ public final static String USER_AGENT_PROPERTY_KEY = "UserAgent";
+
+ private String encoding = "UTF-8";
+ private String expiredPage = "./expiredError.jsp";
+
+ public ResultServlet() {
+ }
+
+ private void myInit() {
+ String enc = getServletContext().getInitParameter("responseEncoding");
+ if (enc != null) {
+ log.debug("Init default encoding to: " + enc);
+ encoding = enc;
+ }
+ String expP = getServletConfig().getInitParameter("expiredPage");
+ if (expP != null) {
+ log.debug("Init expired page to: " + expP);
+ expiredPage = expP;
+ }
+ }
+
+ @Override
+ public void init() throws ServletException {
+ super.init();
+ myInit();
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ super.init(config);
+ myInit();
+ }
+
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doGet(req, resp);
+ }
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+ HttpSession session = req.getSession(false);
+ if (session == null) {
+ resp.sendRedirect(expiredPage);
+ return;
+ }
+ String sessionId = session.getId();
+ if (sessionId == null) {
+ resp.sendRedirect(expiredPage);
+ return;
+ }
+ log.debug("Got a result request for session: " + sessionId);
+ HTTPBindingProcessor bp = (HTTPBindingProcessor) getBindingProcessorManager()
+ .getBindingProcessor(IdFactory.getInstance().createId(sessionId));
+ if (bp == null) {
+ session.invalidate();
+ resp.sendRedirect(expiredPage);
+ return;
+ }
+
+ if (bp.getRedirectURL() != null) {
+ resp.sendRedirect(bp.getRedirectURL());
+ return;
+ }
+ resp.setStatus(bp.getResponseCode());
+ resp.setHeader("Cache-Control", "no-store"); // HTTP 1.1
+ resp.setHeader("Pragma", "no-cache"); // HTTP 1.0
+ resp.setDateHeader("Expires", 0);
+ if (Configurator.getInstance().getProperty(USER_AGENT_PROPERTY_KEY) != null) {
+ resp.setHeader(HttpUtil.HTTP_HEADER_USER_AGENT, Configurator.getInstance().getProperty(
+ USER_AGENT_PROPERTY_KEY));
+ } else {
+ resp.setHeader(HttpUtil.HTTP_HEADER_USER_AGENT,
+ "citizen-card-environment/1.2 MOCCA Unknown");
+ }
+ for (Iterator it = bp.getResponseHeaders().keySet().iterator(); it
+ .hasNext();) {
+ String header = it.next();
+ resp.setHeader(header, bp.getResponseHeaders().get(header));
+ }
+ resp.setContentType(bp.getResultContentType());
+ resp.setCharacterEncoding(encoding);
+ bp.writeResultTo(resp.getOutputStream(), encoding);
session.invalidate();
- getBindingProcessorManager().removeBindingProcessor(bp.getId());
- }
-}
+ getBindingProcessorManager().removeBindingProcessor(bp.getId());
+ }
+}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java
index 6ee537b1..ec062e42 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java
@@ -19,13 +19,13 @@ package at.gv.egiz.bku.online.webapp;
import javax.servlet.http.HttpServlet;
import at.gv.egiz.bku.binding.BindingProcessorManager;
+import at.gv.egiz.bku.online.conf.Configurator;
public abstract class SpringBKUServlet extends HttpServlet {
- public final static String BEAN_NAME="bindingProcessorManager";
-
+ public final static String BEAN_NAME="bindingProcessorManager";
+
protected BindingProcessorManager getBindingProcessorManager() {
return (BindingProcessorManager) getServletContext().getAttribute(BEAN_NAME);
}
-
}
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
index 108f8624..cdc2bfad 100644
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/defaultConf.properties
@@ -39,3 +39,5 @@ SSL.sslProtocol=TLS
# ------------ END SSL Config --------------------
+ValidateHashDataInputs=true
+
diff --git a/BKUOnline/src/main/resources/log4j.properties b/BKUOnline/src/main/resources/log4j.properties
index ed14b424..58f09511 100644
--- a/BKUOnline/src/main/resources/log4j.properties
+++ b/BKUOnline/src/main/resources/log4j.properties
@@ -13,9 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# loglever DEBUG, appender STDOUT
-log4j.rootLogger=TRACE, STDOUT
-#log4j.logger.at.gv.egiz.slbinding.RedirectEventFilter=DEBUG, STDOUT
+
+log4j.rootLogger=TRACE, STDOUT, file
# STDOUT appender
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
@@ -24,11 +23,11 @@ log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
#log4j.appender.STDOUT.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
log4j.appender.STDOUT.layout.ConversionPattern=%-5p | %t | %c %x - %m%n
-### FILE appender
-#log4j.appender.file=org.apache.log4j.RollingFileAppender
-#log4j.appender.file.maxFileSize=100KB
-#log4j.appender.file.maxBackupIndex=9
-#log4j.appender.file.File=egovbus_ca.log
-#log4j.appender.file.threshold=info
-#log4j.appender.file.layout=org.apache.log4j.PatternLayout
-#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
\ No newline at end of file
+# FILE appender
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+log4j.appender.file.maxFileSize=500KB
+log4j.appender.file.maxBackupIndex=9
+log4j.appender.file.File=${catalina.home}/logs/bkuonline.log
+log4j.appender.file.threshold=trace
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p | %t | %c{1}:%L - %m%n
\ No newline at end of file
diff --git a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
index f87d09f5..04b07ba4 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
@@ -45,8 +45,8 @@
-
+
diff --git a/BKUOnline/src/main/webapp/appletPage.jsp b/BKUOnline/src/main/webapp/appletPage.jsp
index 684a8dca..fdd7072f 100644
--- a/BKUOnline/src/main/webapp/appletPage.jsp
+++ b/BKUOnline/src/main/webapp/appletPage.jsp
@@ -25,15 +25,15 @@
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
index 8eaeacbd..a8477ece 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
@@ -16,13 +16,14 @@
*/
package at.gv.egiz.bku.binding;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
/**
* Used to handle DataUrl connections as specified in the CCE's HTTP protocol binding.
@@ -30,7 +31,8 @@ import at.gv.egiz.bku.slexceptions.SLRuntimeException;
*/
public class DataUrl {
private static DataUrlConnectionSPI defaultDataUrlConnection = new DataUrlConnectionImpl();
- private static Log log = LogFactory.getLog(DataUrl.class);
+ private static Log log = LogFactory.getLog(DataUrl.class);
+ private static Properties configuration;
private URL url;
@@ -58,5 +60,9 @@ public class DataUrl {
log.error(e);
throw new SLRuntimeException("Cannot instantiate a dataurlconnection:",e);
}
+ }
+
+ public static void setConfiguration(Properties props) {
+ configuration = props;
}
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
index 6d654639..c6ffa32a 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
@@ -34,14 +34,16 @@ import at.gv.egiz.bku.slcommands.SLResult;
*/
public interface DataUrlConnection {
- public static final String DEFAULT_USERAGENT = "citizen-card-environment/1.2 BKU2 1.0";
+ public static final String DEFAULT_USERAGENT = "citizen-card-environment/1.2 MOCCA Unknown";
public static final String FORMPARAM_RESPONSETYPE = "ResponseType";
public static final String DEFAULT_RESPONSETYPE = "HTTP-Security-Layer-RESPONSE";
public static final String FORMPARAM_XMLRESPONSE = "XMLResponse";
public static final String FORMPARAM_BINARYRESPONSE = "BinaryResponse";
public static final String XML_RESPONSE_ENCODING = "UTF-8";
-
+
+ public final static String USER_AGENT_PROPERTY_KEY="UserAgent";
+
public String getProtocol();
public URL getUrl();
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 9f5d70cb..bb0314b5 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
@@ -1,221 +1,235 @@
/*
-* 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 java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.SocketTimeoutException;
-import java.net.URL;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.net.ssl.HttpsURLConnection;
-
-import org.apache.commons.httpclient.methods.multipart.FilePart;
-import org.apache.commons.httpclient.methods.multipart.Part;
-import org.apache.commons.httpclient.methods.multipart.StringPart;
-
-import at.gv.egiz.bku.binding.multipart.InputStreamPartSource;
-import at.gv.egiz.bku.binding.multipart.SLResultPart;
-import at.gv.egiz.bku.slcommands.SLResult;
-import at.gv.egiz.bku.slcommands.SLResult.SLResultType;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.bku.utils.StreamUtil;
-import at.gv.egiz.bku.utils.binding.Protocol;
-
-/**
- * not thread-safe thus newInsance always returns a new object
- *
- */
-public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
-
- public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
- Protocol.HTTPS };
- protected X509Certificate serverCertificate;
- protected Protocol protocol;
- protected URL url;
- private HttpURLConnection connection;
- protected Map requestHttpHeaders;
- protected ArrayList formParams;
- protected String boundary;
-
- protected DataUrlResponse result;
-
- public String getProtocol() {
- if (protocol == null) {
- return null;
- }
- return protocol.toString();
- }
-
- /**
- * opens a connection sets the headers gets the server certificate
- *
- * @throws java.net.SocketTimeoutException
- * @throws java.io.IOException
- * @pre url != null
- * @pre httpHeaders != null
- */
- public void connect() throws SocketTimeoutException, IOException {
- connection = (HttpURLConnection) url.openConnection();
-
+ * 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 java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.net.ssl.HttpsURLConnection;
+
+import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.commons.httpclient.methods.multipart.StringPart;
+
+import at.gv.egiz.bku.binding.multipart.InputStreamPartSource;
+import at.gv.egiz.bku.binding.multipart.SLResultPart;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slcommands.SLResult.SLResultType;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.binding.Protocol;
+
+/**
+ * not thread-safe thus newInsance always returns a new object
+ *
+ */
+public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
+
+ public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
+ Protocol.HTTPS };
+ protected X509Certificate serverCertificate;
+ protected Protocol protocol;
+ protected URL url;
+ private HttpURLConnection connection;
+ protected Map requestHttpHeaders;
+ protected ArrayList formParams;
+ protected String boundary;
+ protected Properties config = null;
+
+ protected DataUrlResponse result;
+
+ public String getProtocol() {
+ if (protocol == null) {
+ return null;
+ }
+ return protocol.toString();
+ }
+
+ /**
+ * opens a connection sets the headers gets the server certificate
+ *
+ * @throws java.net.SocketTimeoutException
+ * @throws java.io.IOException
+ * @pre url != null
+ * @pre httpHeaders != null
+ */
+ public void connect() throws SocketTimeoutException, IOException {
+ connection = (HttpURLConnection) url.openConnection();
+
// FIXXME move this to config.
- HttpURLConnection.setFollowRedirects(false);
-
-
- connection.setDoOutput(true);
- Set headers = requestHttpHeaders.keySet();
- Iterator headerIt = headers.iterator();
- while (headerIt.hasNext()) {
- String name = headerIt.next();
- connection.setRequestProperty(name, requestHttpHeaders.get(name));
- }
- connection.connect();
- if (connection instanceof HttpsURLConnection) {
- HttpsURLConnection ssl = (HttpsURLConnection) connection;
- X509Certificate[] certs = (X509Certificate[]) ssl.getServerCertificates();
- if ((certs != null) && (certs.length >= 1)) {
- serverCertificate = certs[0];
- }
- }
- }
-
- public X509Certificate getServerCertificate() {
- return serverCertificate;
- }
-
- public void setHTTPHeader(String name, String value) {
- if (name != null && value != null) {
- requestHttpHeaders.put(name, value);
- }
- }
-
- public void setHTTPFormParameter(String name, InputStream data,
- String contentType, String charSet, String transferEncoding) {
- InputStreamPartSource source = new InputStreamPartSource(null, data);
- FilePart formParam = new FilePart(name, source, contentType, charSet);
- if (transferEncoding != null) {
- formParam.setTransferEncoding(transferEncoding);
- } else {
- formParam.setTransferEncoding(null);
- }
- formParams.add(formParam);
- }
-
- /**
- * send all formParameters
- *
- * @throws java.io.IOException
- */
- public void transmit(SLResult slResult) throws IOException {
- SLResultPart slResultPart = new SLResultPart(slResult,
- XML_RESPONSE_ENCODING);
- if (slResult.getResultType() == SLResultType.XML) {
- slResultPart.setTransferEncoding(null);
- slResultPart.setContentType(slResult.getMimeType());
- slResultPart.setCharSet(XML_RESPONSE_ENCODING);
- } else {
- slResultPart.setTransferEncoding(null);
- slResultPart.setContentType(slResult.getMimeType());
- }
- formParams.add(slResultPart);
-
- OutputStream os = connection.getOutputStream();
-
- Part[] parts = new Part[formParams.size()];
- Part.sendParts(os, formParams.toArray(parts), boundary.getBytes());
- os.close();
+ HttpURLConnection.setFollowRedirects(false);
+
+ connection.setDoOutput(true);
+ Set headers = requestHttpHeaders.keySet();
+ Iterator headerIt = headers.iterator();
+ while (headerIt.hasNext()) {
+ String name = headerIt.next();
+ connection.setRequestProperty(name, requestHttpHeaders.get(name));
+ }
+ connection.connect();
+ if (connection instanceof HttpsURLConnection) {
+ HttpsURLConnection ssl = (HttpsURLConnection) connection;
+ X509Certificate[] certs = (X509Certificate[]) ssl.getServerCertificates();
+ if ((certs != null) && (certs.length >= 1)) {
+ serverCertificate = certs[0];
+ }
+ }
+ }
+
+ public X509Certificate getServerCertificate() {
+ return serverCertificate;
+ }
+
+ public void setHTTPHeader(String name, String value) {
+ if (name != null && value != null) {
+ requestHttpHeaders.put(name, value);
+ }
+ }
+
+ public void setHTTPFormParameter(String name, InputStream data,
+ String contentType, String charSet, String transferEncoding) {
+ InputStreamPartSource source = new InputStreamPartSource(null, data);
+ FilePart formParam = new FilePart(name, source, contentType, charSet);
+ if (transferEncoding != null) {
+ formParam.setTransferEncoding(transferEncoding);
+ } else {
+ formParam.setTransferEncoding(null);
+ }
+ formParams.add(formParam);
+ }
+
+ /**
+ * send all formParameters
+ *
+ * @throws java.io.IOException
+ */
+ public void transmit(SLResult slResult) throws IOException {
+ SLResultPart slResultPart = new SLResultPart(slResult,
+ XML_RESPONSE_ENCODING);
+ if (slResult.getResultType() == SLResultType.XML) {
+ slResultPart.setTransferEncoding(null);
+ slResultPart.setContentType(slResult.getMimeType());
+ slResultPart.setCharSet(XML_RESPONSE_ENCODING);
+ } else {
+ slResultPart.setTransferEncoding(null);
+ slResultPart.setContentType(slResult.getMimeType());
+ }
+ formParams.add(slResultPart);
+
+ OutputStream os = connection.getOutputStream();
+
+ Part[] parts = new Part[formParams.size()];
+ Part.sendParts(os, formParams.toArray(parts), boundary.getBytes());
+ os.close();
// MultipartRequestEntity PostMethod
- result = new DataUrlResponse(url.toString(), connection.getResponseCode(),
- connection.getInputStream());
-
- Map responseHttpHeaders = new HashMap();
- Map> httpHeaders = connection.getHeaderFields();
- for (Iterator keyIt = httpHeaders.keySet().iterator(); keyIt
- .hasNext();) {
- String key = keyIt.next();
- StringBuffer value = new StringBuffer();
- for (String val : httpHeaders.get(key)) {
- value.append(val);
- value.append(HttpUtil.SEPERATOR[0]);
- }
- String valString = value.substring(0, value.length() - 1);
- if ((key != null)&&(value.length() > 0)) {
- responseHttpHeaders.put(key, valString);
- }
- }
- result.setResponseHttpHeaders(responseHttpHeaders);
- }
-
- @Override
- public DataUrlResponse getResponse() throws IOException {
- return result;
- }
-
- /**
- * inits protocol, url, httpHeaders, formParams
- *
- * @param url
- * must not be null
- */
- @Override
- public void init(URL url) {
-
- for (int i = 0; i < SUPPORTED_PROTOCOLS.length; i++) {
- if (SUPPORTED_PROTOCOLS[i].toString().equalsIgnoreCase(url.getProtocol())) {
- protocol = SUPPORTED_PROTOCOLS[i];
- break;
- }
- }
- if (protocol == null) {
- throw new SLRuntimeException("Protocol " + url.getProtocol()
- + " not supported for data url");
- }
- this.url = url;
- boundary = "--" + IdFactory.getInstance().createId().toString();
- requestHttpHeaders = new HashMap();
- requestHttpHeaders.put(HttpUtil.HTTP_HEADER_USER_AGENT, DEFAULT_USERAGENT);
- requestHttpHeaders.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE,
- HttpUtil.MULTIPART_FOTMDATA + HttpUtil.SEPERATOR[0]
- + HttpUtil.MULTIPART_FOTMDATA_BOUNDARY + "=" + boundary);
-
- formParams = new ArrayList();
- StringPart responseType = new StringPart(FORMPARAM_RESPONSETYPE,
- DEFAULT_RESPONSETYPE);
- responseType.setCharSet("UTF-8");
- responseType.setTransferEncoding(null);
- formParams.add(responseType);
- }
-
- @Override
- public DataUrlConnectionSPI newInstance() {
- return new DataUrlConnectionImpl();
+ result = new DataUrlResponse(url.toString(), connection.getResponseCode(),
+ connection.getInputStream());
+
+ Map responseHttpHeaders = new HashMap();
+ Map> httpHeaders = connection.getHeaderFields();
+ for (Iterator keyIt = httpHeaders.keySet().iterator(); keyIt
+ .hasNext();) {
+ String key = keyIt.next();
+ StringBuffer value = new StringBuffer();
+ for (String val : httpHeaders.get(key)) {
+ value.append(val);
+ value.append(HttpUtil.SEPERATOR[0]);
+ }
+ String valString = value.substring(0, value.length() - 1);
+ if ((key != null) && (value.length() > 0)) {
+ responseHttpHeaders.put(key, valString);
+ }
+ }
+ result.setResponseHttpHeaders(responseHttpHeaders);
}
- @Override
- public URL getUrl() {
- return url;
- }
+ @Override
+ public DataUrlResponse getResponse() throws IOException {
+ return result;
+ }
+
+ /**
+ * inits protocol, url, httpHeaders, formParams
+ *
+ * @param url
+ * must not be null
+ */
+ @Override
+ public void init(URL url) {
+
+ for (int i = 0; i < SUPPORTED_PROTOCOLS.length; i++) {
+ if (SUPPORTED_PROTOCOLS[i].toString().equalsIgnoreCase(url.getProtocol())) {
+ protocol = SUPPORTED_PROTOCOLS[i];
+ break;
+ }
+ }
+ if (protocol == null) {
+ throw new SLRuntimeException("Protocol " + url.getProtocol()
+ + " not supported for data url");
+ }
+ this.url = url;
+ boundary = "--" + IdFactory.getInstance().createId().toString();
+ requestHttpHeaders = new HashMap();
+ if ((config != null)
+ && (config.getProperty(USER_AGENT_PROPERTY_KEY) != null)) {
+ requestHttpHeaders.put(HttpUtil.HTTP_HEADER_USER_AGENT, config
+ .getProperty(USER_AGENT_PROPERTY_KEY));
+ } else {
+ requestHttpHeaders
+ .put(HttpUtil.HTTP_HEADER_USER_AGENT, DEFAULT_USERAGENT);
+
+ }
+ requestHttpHeaders.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE,
+ HttpUtil.MULTIPART_FOTMDATA + HttpUtil.SEPERATOR[0]
+ + HttpUtil.MULTIPART_FOTMDATA_BOUNDARY + "=" + boundary);
+
+ formParams = new ArrayList();
+ StringPart responseType = new StringPart(FORMPARAM_RESPONSETYPE,
+ DEFAULT_RESPONSETYPE);
+ responseType.setCharSet("UTF-8");
+ responseType.setTransferEncoding(null);
+ formParams.add(responseType);
+ }
+
+ @Override
+ public DataUrlConnectionSPI newInstance() {
+ DataUrlConnectionSPI uc = new DataUrlConnectionImpl();
+ uc.setConfiguration(config);
+ return uc;
+ }
+
+ @Override
+ public URL getUrl() {
+ return url;
+ }
+
+ @Override
+ public void setConfiguration(Properties config) {
+ this.config = config;
+ }
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java
index 9e5a66f8..80cc3a0b 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java
@@ -17,6 +17,7 @@
package at.gv.egiz.bku.binding;
import java.net.URL;
+import java.util.Properties;
/**
* Prototype of a DataurlconnectionSPI
@@ -36,7 +37,13 @@ public interface DataUrlConnectionSPI extends DataUrlConnection {
* Initializes the DataUrlConnection
* @param url
*/
- public void init(URL url);
+ public void init(URL url);
+
+ /**
+ * Sets configuration parameters for this connection
+ * @param config
+ */
+ public void setConfiguration(Properties config);
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
index 555f83bd..fb624211 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
@@ -16,12 +16,14 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import at.buergerkarte.namespaces.securitylayer._1.ErrorResponseType;
-import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
-import at.gv.egiz.bku.slcommands.ErrorResult;
-import at.gv.egiz.bku.slexceptions.SLException;
-
-import javax.xml.transform.Result;
+import java.util.Locale;
+
+import javax.xml.transform.Result;
+
+import at.buergerkarte.namespaces.securitylayer._1.ErrorResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+import at.gv.egiz.bku.slcommands.ErrorResult;
+import at.gv.egiz.bku.slexceptions.SLException;
/**
* This class implements the security layer result ErrorResponse.
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
index 8e0a09bc..cf52a4c3 100644
--- a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
@@ -13,85 +13,86 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-test.noerror=This is a test error-message. No error occurred.
-
-ec1000=Unclassified error.
-ec2000=Unclassified error in the transport binding.
-ec2001=HTTP/HTTPS binding: DataURL cannot be resolved.
-ec2002=HTTP/HTTPS binding: StylesheetURL cannot be resolved.
-ec2003=HTTP/HTTPS binding: RedirectURL cannot be resolved.
-ec2004=HTTP/HTTPS binding: XMLRequest parameter missing.
-ec2005=HTTP/HTTPS binding: Unknown parameter encoding.
-ec2006=HTTP/HTTPS binding: Incorrect parameter encoding.
-ec2007=HTTP/HTTPS binding: DataURL server transmits error or unexpected response.
-ec2008=HTTP/HTTPS binding: Error in stylesheet obtained from the StylesheetURL.
-ec2009=HTTP/HTTPS binding: HTTP request to local CCE directed to unauthorised URL.
-ec2010=HTTPS binding: Error while establishing the TLS connection.
-ec3000=Unclassified error in the XML structure of the command request.
-ec3001=XML structure of the command request is not well formed.
-ec3002=XML structure of the command request does not comply with the Security Layer schema.
-ec3003=XML structure of the command request contains an invalid combination of optional elements or attributes.
-ec3004=XML structure contains an element or attribute whose syntax does not match the Security Layer specification.
-ec3005=Protocol version of Security Layer not supported.
-ec4000=Unclassified error while processing command.
-ec4001=Unknown key box identifier.
-ec4002=Unknown info box identifier.
-ec4003=Date to be signed cannot be resolved.
-ec4004=Supplementary object cannot be resolved.
-ec4005=Date to be encrypted cannot be resolved.
-ec4006=Algorithm (signature, encryption, digest, canonicalisation, transformation) not supported.
-ec4007=Error while executing algorithm (signature, encryption, digest, canonicalisation, transformation).
-ec4008=Error while parsing CMS message
-ec4009=No matching decryption key.
-ec4010=Info box command parameters do not match info box type.
-ec4011=Command not implemented.
-ec4100=XML document in which the signature is to be integrated cannot be resolved.
-ec4101=XML document in which the signature is to be integrated cannot be parsed.
-ec4102=Signature cannot be integrated in the existing XML document at the specified location.
-ec4103=Signature certificate not contained in the CMS signature.
-ec4104=Signed data not contained in the CMS signature or XML request.
-ec4105=XML document containing the signature to be verified cannot be resolved.
-ec4106=XML document containing the signature to be verified cannot be parsed.
-ec4107=There is no XML signature at the specified location within the XML document.
-ec4108=Encrypted date cannot be inserted in the existing XML document at the specified location.
-ec4109=Existing XML document is required but missing.
-ec4110=Existing XML document cannot be resolved.
-ec4111=Existing XML document cannot be parsed.
-ec4112=Encrypted data encryption keys cannot be inserted in the existing XML document at the specified location.
-ec4113=Data to be decrypted not contained in either the CMS message or XML request.
-ec4114=XML document to be decrypted cannot be resolved.
-ec4115=XML document to be decrypted cannot be parsed.
-ec4116=At least one specified encryption element cannot be found in the XML document to be decrypted.
-ec4117=No encryption element for binary response.
-ec4118=Date to be hashed cannot be resolved.
-ec4119=Date for which the hash value is to be verified cannot be resolved.
-ec4120=Selected info box identifier already allocated.
-ec4121=Info box with specified identifier does not exist.
-ec4122=Contents of the selected info box cannot be displayed as XML.
-ec4123=Associative array: No entry for the specified key.
-ec5000=Unclassified error in the viewer component.
-ec5001=Display of data of the mime type specified in the command request not supported.
-ec5002=Character encoding of the data to be displayed is invalid or not supported.
-ec5003=Data to be displayed contains unsupported characters.
-ec5004=Standard display format: HTML does not conform to specification.
-ec5005=Standard display format: CSS does not conform to specification.
-ec5006=Standard display format: Format of an embedded image does not conform to specification.
-ec5007=Standard display format: Signature for embedded images missing or does not conform to specification.
-ec6000=Unclassified cancelling by the citizen.
-ec6001=Cancelled by the citizen via the user interface.
-ec6002=Cancelled because of insufficient rights to execute command.
-
-# 3xxx
-#
-
-ec3000.unclassified=Error in the XML structure of the command request. {0}
-ec3002.invalid=XML structure of the command request does not comply with the Security Layer schema. {0}
-
-# 4xxx
-#
-
-ec4000.infobox.invalid=The infobox '{0}' contains invalid content.
-ec4000.idlink.transfomation.failed=Failed to transform CompressedIdentityLink with Stylesheet {0}.
-ec4002.infobox.unknown=Unknown info box identifier {0}.
-ec4003.not.resolved=Data to be signed cannot be resolved from URI={0}.
-ec4011.notimplemented=Command {0} not implemented.
+test.noerror=Das ist eine Test-Fehlermeldung. Es ist kein Fehler aufgetreten.
+
+ec1000=Unklassifizierter Fehler.
+ec2000=Unklassifizierter Fehler in der Transportbindung.
+ec2001=HTTP/HTTPS-Bindung: DataURL kann nicht aufgelöst werden.
+ec2002=HTTP/HTTPS-Bindung: StylesheetURL kann nicht aufgelöst werden.
+ec2003=HTTP/HTTPS-Bindung: RedirectURL kann nicht aufgelöst werden.
+ec2004=HTTP/HTTPS-Bindung: Parameter XMLRequest fehlt.
+ec2005=HTTP/HTTPS-Bindung: Unbekannte Kodierung der Parameter.
+ec2006=HTTP/HTTPS-Bindung: Fehlerhafte Kodierung der Parameter.
+ec2007=HTTP/HTTPS-Bindung: DataURL-Server sendet Fehler oder unerwartete Antwort.
+ec2008=HTTP/HTTPS-Bindung: Fehler im Stylesheet, der von der StylesheetURL bezogen wurde.
+ec2009=HTTP/HTTPS-Bindung: HTTP-Anfrage an lokale BKU wurde an unerlaubte URL gerichtet.
+ec2010=HTTPS-Bindung: Fehler beim Aufbau der TLS-Verbindung.
+ec3000=Unklassifizierter Fehler in der XML-Struktur der Befehlsanfrage.
+ec3001=XML-Struktur der Befehlsanfrage ist nicht wohlgeformt.
+ec3002=XML-Struktur der Befehlsanfrage entspricht nicht dem Schema des Security-Layers.
+ec3003=XML-Struktur der Befehlsanfrage enthält eine unerlaubte Kombination aus optionalen Elementen oder Attributen.
+ec3004=XML-Struktur enthält ein Element oder Attribut, dessen Syntax nicht der Spezifikation des Security-Layer entspricht.
+ec3005=Protokollversion des Security-Layer wird nicht unterstützt.
+ec4000=Unklassifizierter Fehler in der Befehlsabarbeitung.
+ec4001=Unbekannter Keyboxbezeichner.
+ec4002=Unbekannter Infoboxbezeichner.
+ec4003=Zu signierendes Datum kann nicht aufgelöst werden.
+ec4004=Ergänzungsobjekt kann nicht aufgelöst werden.
+ec4005=Zu verschlüsselndes Datum kann nicht aufgelöst werden.
+ec4006=Algorithmus (Signatur, Verschlüsselung, Digest, Kanonisierung, Transformation) wird nicht unterstützt.
+ec4007=Fehler bei der Algorithmusausführung (Signatur, Verschlüsselung, Digest, Kanonisierung, Transformation).
+ec4008=Fehler beim Parsen der CMS-Nachricht.
+ec4009=Kein passender Entschlüsselungsschlüssel vorhanden.
+ec4010=Parameter des Infobox-Befehls passen nicht zum Typ der Infobox.
+ec4011=Befehl ist nicht implementiert.
+ec4100=XML-Dokument, in das die Signatur integriert werden soll, kann nicht aufgelöst werden.
+ec4101=XML-Dokument, in das die Signatur integriert werden soll, kann nicht geparst werden.
+ec4102=Signatur kann nicht am spezifizierten Ort in das bestehende XML-Dokument integriert werden.
+ec4103=Signatorzertifikat ist nicht in der CMS-Signatur enthalten.
+ec4104=Signierte Daten sind weder in der CMS-Signatur noch im XML-Request enthalten.
+ec4105=XML-Dokument, das die zu prüfende Signatur enthält, kann nicht aufgelöst werden.
+ec4106=XML-Dokument, das die zu prüfende Signatur enthält, kann nicht geparst werden.
+ec4107=Am spezifizierten Ort innerhalb des XML-Dokuments befindet sich keine XML-Signatur.
+ec4108=Verschlüsseltes Datum kann nicht am spezifizierten Ort in das bestehende XML-Dokument eingefügt werden.
+ec4109=Bestehendes XML-Dokument ist notwendig, aber nicht vorhanden.
+ec4110=Bestehendes XML-Dokument kann nicht aufgelöst werden.
+ec4111=Bestehendes XML-Dokument kann nicht geparst werden.
+ec4112=Verschlüsselte Datenverschlüsselungsschlüssel können nicht am spezifizierten Ort in das bestehende XML-Dokument eingefügt werden.
+ec4113=Zu entschlüsselnde Daten sind weder in der CMS-Nachricht noch im XML-Request enthalten.
+ec4114=Zu entschlüsselndes XML-Dokument kann nicht aufgelöst werden.
+ec4115=Zu entschlüsselndes XML-Dokument kann nicht geparst werden.
+ec4116=Zumindest ein spezifiziertes Verschlüsselungselement kann nicht im zu entschlüsselnden XML-Dokument gefunden werden.
+ec4117=Kein Verschlüsselungselement für Binärantwort vorhanden.
+ec4118=Zu hashendes Datum kann nicht aufgelöst werden.
+ec4119=Datum, für das der Hashwert zu prüfen ist, kann nicht aufgelöst werden.
+ec4120=Gewählter Infoboxbezeichner bereits vergeben.
+ec4121=Infobox mit spezifiziertem Bezeichner existiert nicht.
+ec4122=Inhalt der ausgewählten Infobox kann nicht als XML dargestellt werden.
+ec4123=Assoziatives Array: Zum spezifizierten Schlüssel existiert kein Eintrag.
+ec5000=Unklassifizierter Fehler in der Anzeigekomponente.
+ec5001=Anzeige von Daten des in der Befehlsanfrage angegebenen Mime-Types wird nicht unterstützt.
+ec5002=Zeichenkodierung der anzuzeigenden Daten ist fehlerhaft oder wird nicht unterstützt.
+ec5003=Anzuzeigende Daten enhalten nicht unterstützte Zeichen.
+ec5004=Standardanzeigeformat: HTML ist nicht spezifikationskonform.
+ec5005=Standardanzeigeformat: CSS ist nicht spezifikationskonform.
+ec5006=Standardanzeigeformat: Format eines eingebundenen Bildes ist nicht spezifikationskonform.
+ec5007=Standardanzeigeformat: Signatur über eingebundene Bilder fehlt oder ist nicht spezifikationskonform.
+ec6000=Unklassifizierter Abbruch durch den Bürger.
+ec6001=Abbruch durch den Bürger über die Benutzerschnittstelle.
+ec6002=Abbruch auf Grund mangelnder Rechte zur Befehlsausführung.
+
+# 3xxx
+#
+
+ec3000.unclassified=Unklassifizierter Fehler in der XML-Struktur der Befehlsanfrage. {0}
+ec3002.invalid=XML-Struktur der Befehlsanfrage entspricht nicht dem Schema des Security-Layers. {0}
+
+# 4xxx
+#
+
+ec4000.infobox.invalid=Die Infobox '{0}' enthält ungültige Daten.
+ec4000.idlink.transfomation.failed=Die komprimierte Personenbindung konnte mit dem Stylesheet {0} nicht transformiert werden.
+ec4002.infobox.unknown=Unbekannter Infoboxbezeichner {0}.
+ec4003.not.resolved=Zu signierendes Datum kann nicht aufgelöst werden (URI={0}).
+ec4011.notimplemented=Befehl {0} ist nicht implementiert.
+
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties
new file mode 100644
index 00000000..8e0a09bc
--- /dev/null
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties
@@ -0,0 +1,97 @@
+# 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.
+
+test.noerror=This is a test error-message. No error occurred.
+
+ec1000=Unclassified error.
+ec2000=Unclassified error in the transport binding.
+ec2001=HTTP/HTTPS binding: DataURL cannot be resolved.
+ec2002=HTTP/HTTPS binding: StylesheetURL cannot be resolved.
+ec2003=HTTP/HTTPS binding: RedirectURL cannot be resolved.
+ec2004=HTTP/HTTPS binding: XMLRequest parameter missing.
+ec2005=HTTP/HTTPS binding: Unknown parameter encoding.
+ec2006=HTTP/HTTPS binding: Incorrect parameter encoding.
+ec2007=HTTP/HTTPS binding: DataURL server transmits error or unexpected response.
+ec2008=HTTP/HTTPS binding: Error in stylesheet obtained from the StylesheetURL.
+ec2009=HTTP/HTTPS binding: HTTP request to local CCE directed to unauthorised URL.
+ec2010=HTTPS binding: Error while establishing the TLS connection.
+ec3000=Unclassified error in the XML structure of the command request.
+ec3001=XML structure of the command request is not well formed.
+ec3002=XML structure of the command request does not comply with the Security Layer schema.
+ec3003=XML structure of the command request contains an invalid combination of optional elements or attributes.
+ec3004=XML structure contains an element or attribute whose syntax does not match the Security Layer specification.
+ec3005=Protocol version of Security Layer not supported.
+ec4000=Unclassified error while processing command.
+ec4001=Unknown key box identifier.
+ec4002=Unknown info box identifier.
+ec4003=Date to be signed cannot be resolved.
+ec4004=Supplementary object cannot be resolved.
+ec4005=Date to be encrypted cannot be resolved.
+ec4006=Algorithm (signature, encryption, digest, canonicalisation, transformation) not supported.
+ec4007=Error while executing algorithm (signature, encryption, digest, canonicalisation, transformation).
+ec4008=Error while parsing CMS message
+ec4009=No matching decryption key.
+ec4010=Info box command parameters do not match info box type.
+ec4011=Command not implemented.
+ec4100=XML document in which the signature is to be integrated cannot be resolved.
+ec4101=XML document in which the signature is to be integrated cannot be parsed.
+ec4102=Signature cannot be integrated in the existing XML document at the specified location.
+ec4103=Signature certificate not contained in the CMS signature.
+ec4104=Signed data not contained in the CMS signature or XML request.
+ec4105=XML document containing the signature to be verified cannot be resolved.
+ec4106=XML document containing the signature to be verified cannot be parsed.
+ec4107=There is no XML signature at the specified location within the XML document.
+ec4108=Encrypted date cannot be inserted in the existing XML document at the specified location.
+ec4109=Existing XML document is required but missing.
+ec4110=Existing XML document cannot be resolved.
+ec4111=Existing XML document cannot be parsed.
+ec4112=Encrypted data encryption keys cannot be inserted in the existing XML document at the specified location.
+ec4113=Data to be decrypted not contained in either the CMS message or XML request.
+ec4114=XML document to be decrypted cannot be resolved.
+ec4115=XML document to be decrypted cannot be parsed.
+ec4116=At least one specified encryption element cannot be found in the XML document to be decrypted.
+ec4117=No encryption element for binary response.
+ec4118=Date to be hashed cannot be resolved.
+ec4119=Date for which the hash value is to be verified cannot be resolved.
+ec4120=Selected info box identifier already allocated.
+ec4121=Info box with specified identifier does not exist.
+ec4122=Contents of the selected info box cannot be displayed as XML.
+ec4123=Associative array: No entry for the specified key.
+ec5000=Unclassified error in the viewer component.
+ec5001=Display of data of the mime type specified in the command request not supported.
+ec5002=Character encoding of the data to be displayed is invalid or not supported.
+ec5003=Data to be displayed contains unsupported characters.
+ec5004=Standard display format: HTML does not conform to specification.
+ec5005=Standard display format: CSS does not conform to specification.
+ec5006=Standard display format: Format of an embedded image does not conform to specification.
+ec5007=Standard display format: Signature for embedded images missing or does not conform to specification.
+ec6000=Unclassified cancelling by the citizen.
+ec6001=Cancelled by the citizen via the user interface.
+ec6002=Cancelled because of insufficient rights to execute command.
+
+# 3xxx
+#
+
+ec3000.unclassified=Error in the XML structure of the command request. {0}
+ec3002.invalid=XML structure of the command request does not comply with the Security Layer schema. {0}
+
+# 4xxx
+#
+
+ec4000.infobox.invalid=The infobox '{0}' contains invalid content.
+ec4000.idlink.transfomation.failed=Failed to transform CompressedIdentityLink with Stylesheet {0}.
+ec4002.infobox.unknown=Unknown info box identifier {0}.
+ec4003.not.resolved=Data to be signed cannot be resolved from URI={0}.
+ec4011.notimplemented=Command {0} not implemented.
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java
index 45e38674..8a607b80 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java
@@ -25,6 +25,7 @@ import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -124,5 +125,11 @@ public class TestDataUrlConnection implements DataUrlConnectionSPI {
@Override
public URL getUrl() {
return url;
- }
+ }
+
+ @Override
+ public void setConfiguration(Properties config) {
+ // TODO Auto-generated method stub
+
+ }
}
--
cgit v1.2.3
From 3edfbe631f24d73324bc4dd0d182ca7737c4d5b5 Mon Sep 17 00:00:00 2001
From: mcentner
Date: Wed, 24 Sep 2008 13:56:53 +0000
Subject: Improved SLResult marshalling.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@66 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../gv/egiz/bku/binding/HTTPBindingProcessor.java | 40 +--
.../java/at/gv/egiz/bku/slcommands/SLResult.java | 7 +-
.../impl/CreateXMLSignatureResultImpl.java | 73 ++---
.../egiz/bku/slcommands/impl/ErrorResultImpl.java | 21 +-
.../slcommands/impl/InfoboxReadCommandImpl.java | 320 ++++++++++++++++-----
.../slcommands/impl/InfoboxReadResultFileImpl.java | 141 +++++++++
.../bku/slcommands/impl/InfoboxReadResultImpl.java | 190 +++---------
.../slcommands/impl/NullOperationResultImpl.java | 5 +-
.../gv/egiz/bku/slcommands/impl/SLResultImpl.java | 166 ++++++++---
9 files changed, 606 insertions(+), 357 deletions(-)
create mode 100644 bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
(limited to 'bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java')
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 19f22126..8f72c3ee 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
@@ -35,6 +35,7 @@ import java.util.Locale;
import java.util.Map;
import javax.net.ssl.SSLHandshakeException;
+import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
@@ -108,7 +109,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
protected SLTargetContext targetContext = new SLTargetContext();
protected URL srcUrl;
protected State currentState = State.INIT;
- protected Transformer transformer = null;
+ protected Templates templates = null;
protected String resultContentType = null;
protected SLResult slResult = null;
protected int responseCode = 200;
@@ -471,10 +472,10 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
resultContentType = HttpUtil.TXT_XML;
}
}
- transformer = getTransformer(getStyleSheetUrl());
- if (transformer != null) {
+ templates = getTemplates(getStyleSheetUrl());
+ if (templates != null) {
log.debug("Output transformation required");
- resultContentType = transformer.getOutputProperty("media-type");
+ resultContentType = templates.getOutputProperties().getProperty("media-type");
log.debug("Got media type from stylesheet: " + resultContentType);
if (resultContentType == null) {
log.debug("Setting to default text/xml result conent type");
@@ -703,7 +704,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
return resultContentType;
}
- protected Transformer getTransformer(String styleSheetURL) {
+ protected Templates getTemplates(String styleSheetURL) {
if (styleSheetURL == null) {
log.debug("Stylesheet URL not set");
return null;
@@ -713,11 +714,10 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
URIResolver resolver = new URIResolverAdapter(URLDereferencer
.getInstance(), urlCtx);
TransformerFactory factory = TransformerFactory.newInstance();
+ factory.setURIResolver(resolver);
StreamData sd = URLDereferencer.getInstance().dereference(styleSheetURL,
urlCtx);
- Transformer t = factory.newTransformer(new StreamSource(sd.getStream()));
- t.setURIResolver(resolver);
- return t;
+ return factory.newTemplates(new StreamSource(sd.getStream()));
} catch (Exception ex) {
log.info("Cannot instantiate transformer", ex);
bindingProcessorError = new SLException(2002);
@@ -726,15 +726,10 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
}
protected void handleBindingProcessorError(OutputStream os, String encoding,
- Transformer transformer) throws IOException {
+ Templates templates) throws IOException {
log.debug("Writing error as result");
ErrorResultImpl error = new ErrorResultImpl(bindingProcessorError);
- try {
- error.writeTo(new StreamResult(new OutputStreamWriter(os, encoding)),
- transformer);
- } catch (TransformerException e) {
- log.fatal("Cannot write error result to stream", e);
- }
+ error.writeTo(new StreamResult(new OutputStreamWriter(os, encoding)), templates);
}
@Override
@@ -745,7 +740,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
}
if (bindingProcessorError != null) {
log.debug("Detected error in binding processor, writing error as result");
- handleBindingProcessorError(os, encoding, transformer);
+ handleBindingProcessorError(os, encoding, templates);
return;
} else if (dataUrlResponse != null) {
log.debug("Writing data url response as result");
@@ -754,10 +749,11 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
InputStreamReader isr = new InputStreamReader(
dataUrlResponse.getStream(), charEnc);
OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
- if (transformer == null) {
+ if (templates == null) {
StreamUtil.copyStream(isr, osw);
} else {
try {
+ Transformer transformer = templates.newTransformer();
transformer.transform(new StreamSource(isr), new StreamResult(osw));
} catch (TransformerException e) {
log.fatal("Exception occured during result transformation", e);
@@ -771,18 +767,12 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
} else if (slResult == null) {
// result not yet assigned -> must be a cancel
bindingProcessorError = new SLException(6001);
- handleBindingProcessorError(os, encoding, transformer);
+ handleBindingProcessorError(os, encoding, templates);
return;
} else {
log.debug("Getting result from invoker");
OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
- try {
- slResult.writeTo(new StreamResult(osw), transformer);
- } catch (TransformerException e) {
- log.fatal("Cannot write result to stream", e);
- // bindingProcessorError = new SLException(2008);
- // handleBindingProcessorError(os, encoding, transformer);
- }
+ slResult.writeTo(new StreamResult(osw), templates);
osw.flush();
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
index 7cf43fda..7989a771 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
@@ -16,9 +16,8 @@
*/
package at.gv.egiz.bku.slcommands;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
public interface SLResult {
@@ -40,5 +39,5 @@ public interface SLResult {
* @param result
* @param transformer may be null.
*/
- public void writeTo(Result result, Transformer transformer) throws TransformerException;
+ public void writeTo(Result result, Templates templates);
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
index d2d2e678..092a13c4 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
@@ -16,28 +16,24 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import at.buergerkarte.namespaces.securitylayer._1.CreateXMLSignatureResponseType;
-import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
-import at.gv.egiz.bku.slcommands.SLCommandFactory;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import at.buergerkarte.namespaces.securitylayer._1.CreateXMLSignatureResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
/**
* This calls implements the result of the security layer command CreateXMLSignature.
@@ -104,35 +100,10 @@ public class CreateXMLSignatureResultImpl extends SLResultImpl {
}
}
-
- @Override
- public void writeTo(Result result) {
-
- try {
- writeTo(result, null);
- } catch (TransformerException e) {
- log.error(e);
- }
-
- }
-
- /* (non-Javadoc)
- * @see at.gv.egiz.bku.slcommands.impl.SLResultImpl#writeTo(javax.xml.transform.Result, javax.xml.transform.Transformer)
- */
- @Override
- public void writeTo(Result result, Transformer transformer) throws TransformerException {
-
- if (transformer == null) {
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- try {
- transformer = transformerFactory.newTransformer();
- } catch (TransformerConfigurationException e) {
- log.error("Failed to create Transformer.", e);
- throw new SLRuntimeException(e);
- }
- }
- transformer.transform(new DOMSource(doc), result);
-
+
+ @Override
+ public void writeTo(Result result, Templates templates) {
+ writeTo(doc, result, templates);
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
index fb624211..176ba001 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
@@ -16,12 +16,9 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import java.util.Locale;
-
import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
-import at.buergerkarte.namespaces.securitylayer._1.ErrorResponseType;
-import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
import at.gv.egiz.bku.slcommands.ErrorResult;
import at.gv.egiz.bku.slexceptions.SLException;
@@ -48,15 +45,9 @@ public class ErrorResultImpl extends SLResultImpl implements ErrorResult {
this.slException = slException;
}
- @Override
- public void writeTo(Result result) {
-
- ObjectFactory factory = new ObjectFactory();
- ErrorResponseType responseType = factory.createErrorResponseType();
- responseType.setErrorCode(slException.getErrorCode());
- responseType.setInfo(slException.getDetailedMsg());
-
- writeTo(factory.createErrorResponse(responseType), result);
-
- }
+ @Override
+ public void writeTo(Result result, Templates templates) {
+ writeErrorTo(slException, result, templates);
+ }
+
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java
index b6745e1f..4d64ae36 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java
@@ -16,55 +16,66 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import iaik.asn1.CodingException;
-import iaik.asn1.DerCoder;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-import at.buergerkarte.namespaces.personenbindung._20020506_.CompressedIdentityLinkType;
-import at.buergerkarte.namespaces.securitylayer._1.AnyChildrenType;
-import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsBinaryFileType;
-import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType;
-import at.gv.egiz.bku.slcommands.InfoboxReadCommand;
-import at.gv.egiz.bku.slcommands.SLCommand;
-import at.gv.egiz.bku.slcommands.SLCommandContext;
-import at.gv.egiz.bku.slcommands.SLResult;
-import at.gv.egiz.bku.slexceptions.SLCommandException;
-import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.idlink.CompressedIdentityLinkFactory;
-import at.gv.egiz.idlink.IdentityLinkTransformer;
-import at.gv.egiz.idlink.ans1.IdentityLink;
-import at.gv.egiz.stal.InfoboxReadRequest;
-import at.gv.egiz.stal.InfoboxReadResponse;
-import at.gv.egiz.stal.STALRequest;
+import iaik.asn1.CodingException;
+import iaik.asn1.DerCoder;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import at.buergerkarte.namespaces.personenbindung._20020506_.CompressedIdentityLinkType;
+import at.buergerkarte.namespaces.securitylayer._1.AnyChildrenType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxAssocArrayPairType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadDataAssocArrayType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsBinaryFileType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadKeys;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadPairs;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadValue;
+import at.gv.egiz.bku.slcommands.InfoboxReadCommand;
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slcommands.SLCommandContext;
+import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.idlink.CompressedIdentityLinkFactory;
+import at.gv.egiz.idlink.IdentityLinkTransformer;
+import at.gv.egiz.idlink.ans1.IdentityLink;
+import at.gv.egiz.stal.InfoboxReadRequest;
+import at.gv.egiz.stal.InfoboxReadResponse;
+import at.gv.egiz.stal.STALRequest;
/**
* This class implements the security layer command
@@ -82,23 +93,45 @@ public class InfoboxReadCommandImpl extends SLCommandImplInfoboxIdentifier
*/
protected String infoboxIdentifier;
/**
- * The IdentityLinkDomainIdentifier value of an IdentyLink infobox.
+ * The IdentityLinkDomainIdentifier value of an IdentyLink infobox.
*/
- protected String identityLinkDomainIdentifier;
+ protected String identityLinkDomainIdentifier;
+
+ /**
+ * The list of certificates to be read from an Certificates infobox.
+ */
+ protected List certificates;
+
+ /**
+ * The result type.
+ */
+ protected int assocArrayResult;
/**
* Is content XML entity?
@@ -125,12 +158,6 @@ public class InfoboxReadCommandImpl extends SLCommandImpl 1) {
+ log.info("UserMakesUnique not supported");
+ // TODO: give more specific error message
+ throw new SLCommandException(4010);
+ }
+ }
+
+ // ReadPairs?
+ if (assocArrayParameters.getReadPairs() != null) {
+ assocArrayResult = ASSOC_ARRAY_READ_PAIRS;
+ ReadPairs readPairs = assocArrayParameters.getReadPairs();
+ if (readPairs.isValuesAreXMLEntities()) {
+ log.info("Got valuesAreXMLEntities but infobox type is binary.");
+ throw new SLCommandException(4010);
+ }
+ certificates = findCertificates(readPairs.getSearchString());
+ if (readPairs.isUserMakesUnique() && certificates.size() > 1) {
+ log.info("UserMakesUnique not supported");
+ // TODO: give more specific error message
+ throw new SLCommandException(4010);
+ }
+ }
+
+ // ReadValue
+ if (assocArrayParameters.getReadValue() != null) {
+ assocArrayResult = ASSOC_ARRAY_READ_VALUE;
+ ReadValue readValue = assocArrayParameters.getReadValue();
+ if (readValue.isValueIsXMLEntity()) {
+ log.info("Got valuesAreXMLEntities but infobox type is binary.");
+ throw new SLCommandException(4010);
+ }
+ String key = readValue.getKey();
+ if (Arrays.asList(INFOXBOX_CERTIFICATES_KEYS).contains(key)) {
+ certificates = Collections.singletonList(key);
+ } else {
+ certificates = Collections.emptyList();
+ }
+ }
+
+ if (assocArrayResult == 0) {
+ log.info("Infobox type is AssocArray but got invalid AssocArrayParameters.");
+ throw new SLCommandException(4010);
+ }
} else {
throw new SLCommandException(4002,
@@ -168,9 +268,15 @@ public class InfoboxReadCommandImpl extends SLCommandImpl findCertificates(String searchString) throws SLCommandException {
+
+ if ("*".equals(searchString) || "**".equals(searchString)) {
+ return Arrays.asList(INFOXBOX_CERTIFICATES_KEYS);
+ }
+
+ if (Pattern.matches(SEARCH_STRING_PATTERN, searchString)) {
+
+// for (int i = 0; i < searchString.length(); i++) {
+// int codePoint = searchString.codePointAt(i);
+//
+// }
+
+ // TODO : build pattern
+ return Collections.emptyList();
+ } else {
+ log.info("Got invalid search string '" + searchString + "'");
+ throw new SLCommandException(4010);
+ }
+
+ }
+
+ private SLResult readCertificates() throws SLCommandException {
+
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ InfoboxReadDataAssocArrayType infoboxReadDataAssocArrayType = objectFactory
+ .createInfoboxReadDataAssocArrayType();
+
+ if (assocArrayResult == ASSOC_ARRAY_READ_KEYS) {
- @Override
- public String getIdentityLinkDomainId() {
- return identityLinkDomainIdentifier;
- }
+ List keys = infoboxReadDataAssocArrayType.getKey();
+ keys.addAll(certificates);
+
+ } else {
+
+ if (certificates != null && !certificates.isEmpty()) {
+
+ List stalRequests = new ArrayList();
+
+ // get certificates
+ InfoboxReadRequest infoboxReadRequest;
+ for (int i = 0; i < certificates.size(); i++) {
+ infoboxReadRequest = new InfoboxReadRequest();
+ infoboxReadRequest.setInfoboxIdentifier(certificates.get(i));
+ stalRequests.add(infoboxReadRequest);
+ }
+
+ requestSTAL(stalRequests);
+
+ List x509Certs = getCertificatesFromResponses();
+
+ for (int i = 0; i < certificates.size(); i++) {
+ InfoboxAssocArrayPairType infoboxAssocArrayPairType = objectFactory.createInfoboxAssocArrayPairType();
+ infoboxAssocArrayPairType.setKey(certificates.get(i));
+ try {
+ infoboxAssocArrayPairType.setBase64Content(x509Certs.get(i).getEncoded());
+ } catch (CertificateEncodingException e) {
+ log.error("Failed to encode certificate.", e);
+ throw new SLCommandException(4000);
+ }
+ infoboxReadDataAssocArrayType.getPair().add(infoboxAssocArrayPairType);
+ }
+
+ }
+
+ }
+
+ return new InfoboxReadResultImpl(infoboxReadDataAssocArrayType);
+
+ }
+
+ @Override
+ public String getIdentityLinkDomainId() {
+ return identityLinkDomainIdentifier;
+ }
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
new file mode 100644
index 00000000..6f41b562
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
@@ -0,0 +1,141 @@
+/*
+* 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.slcommands.impl;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
+import javax.xml.transform.dom.DOMResult;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
+import at.buergerkarte.namespaces.securitylayer._1.Base64XMLContentType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+import at.buergerkarte.namespaces.securitylayer._1.XMLContentType;
+import at.gv.egiz.bku.slcommands.InfoboxReadResult;
+import at.gv.egiz.bku.slcommands.SLCommand;
+import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+
+/**
+ * This class implements the result of the security layer command InfoboxReadRequest.
+ *
+ * @author mcentner
+ */
+public class InfoboxReadResultFileImpl extends SLResultImpl implements
+ InfoboxReadResult {
+
+ /**
+ * Logging facility.
+ */
+ protected static Log log = LogFactory.getLog(InfoboxReadResultFileImpl.class);
+
+ /**
+ * The XML document containing the infobox content.
+ */
+ Document xmlDocument;
+
+ /**
+ * Creates the response document from the given binaryContent.
+ *
+ * @param binaryContent the infobox content
+ * @param preserveSpace the value of the preserveSpace parameter
+ *
+ * @return the created response document
+ */
+ private Document createResponseDocument(byte[] binaryContent, boolean preserveSpace) {
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ Document doc;
+ try {
+ doc = dbf.newDocumentBuilder().newDocument();
+ } catch (ParserConfigurationException e) {
+ // it should always be possible to create a new Document
+ log.error("Failed to create XML document.", e);
+ throw new SLRuntimeException(e);
+ }
+
+ ObjectFactory factory = new ObjectFactory();
+
+ Base64XMLContentType base64XMLContentType = factory.createBase64XMLContentType();
+ if (binaryContent == null) {
+ XMLContentType xmlContentType = factory.createXMLContentType();
+ if (preserveSpace) {
+ xmlContentType.setSpace("preserve");
+ }
+ base64XMLContentType.setXMLContent(xmlContentType);
+ } else {
+ base64XMLContentType.setBase64Content(binaryContent);
+ }
+ InfoboxReadResponseType infoboxReadResponseType = factory.createInfoboxReadResponseType();
+ infoboxReadResponseType.setBinaryFileData(base64XMLContentType);
+
+ JAXBElement infoboxReadResponse = factory.createInfoboxReadResponse(infoboxReadResponseType);
+
+ JAXBContext context = SLCommandFactory.getJaxbContext();
+ try {
+ Marshaller marshaller = context.createMarshaller();
+ marshaller.marshal(infoboxReadResponse, doc);
+ } catch (JAXBException e) {
+ log.error("Failed to marshal 'InfoboxReadResponse' document.", e);
+ throw new SLRuntimeException(e);
+ }
+
+ return doc;
+
+ }
+
+
+ /**
+ * @return an XMLResult for marshalling the infobox to
+ */
+ Result getXmlResult(boolean preserveSpace) {
+
+ xmlDocument = createResponseDocument(null, preserveSpace);
+
+ NodeList nodeList = xmlDocument.getElementsByTagNameNS(SLCommand.NAMESPACE_URI, "XMLContent");
+ return new DOMResult(nodeList.item(0));
+
+ }
+
+ /**
+ * Creates a new result document for this InfoboxReadResult
+ * and sets the given resultBytes as content.
+ *
+ * @param resultBytes
+ */
+ void setResultBytes(byte[] resultBytes) {
+
+ xmlDocument = createResponseDocument(resultBytes, false);
+
+ }
+
+ @Override
+ public void writeTo(Result result, Templates templates) {
+ writeTo(xmlDocument, result, templates);
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java
index 6f07338f..8904eac6 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java
@@ -14,158 +14,38 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package at.gv.egiz.bku.slcommands.impl;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-
-import at.buergerkarte.namespaces.securitylayer._1.Base64XMLContentType;
-import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadResponseType;
-import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
-import at.buergerkarte.namespaces.securitylayer._1.XMLContentType;
-import at.gv.egiz.bku.slcommands.InfoboxReadResult;
-import at.gv.egiz.bku.slcommands.SLCommand;
-import at.gv.egiz.bku.slcommands.SLCommandFactory;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-
-/**
- * This class implements the result of the security layer command InfoboxReadRequest.
- *
- * @author mcentner
- */
-public class InfoboxReadResultImpl extends SLResultImpl implements
- InfoboxReadResult {
-
- /**
- * Logging facility.
- */
- protected static Log log = LogFactory.getLog(InfoboxReadResultImpl.class);
-
- /**
- * The XML document containing the infobox content.
- */
- Document xmlDocument;
-
- /**
- * Creates the response document from the given binaryContent.
- *
- * @param binaryContent the infobox content
- * @param preserveSpace the value of the preserveSpace parameter
- *
- * @return the created response document
- */
- private Document createResponseDocument(byte[] binaryContent, boolean preserveSpace) {
-
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- Document doc;
- try {
- doc = dbf.newDocumentBuilder().newDocument();
- } catch (ParserConfigurationException e) {
- // it should always be possible to create a new Document
- log.error("Failed to create XML document.", e);
- throw new SLRuntimeException(e);
- }
-
- ObjectFactory factory = new ObjectFactory();
-
- Base64XMLContentType base64XMLContentType = factory.createBase64XMLContentType();
- if (binaryContent == null) {
- XMLContentType xmlContentType = factory.createXMLContentType();
- if (preserveSpace) {
- xmlContentType.setSpace("preserve");
- }
- base64XMLContentType.setXMLContent(xmlContentType);
- } else {
- base64XMLContentType.setBase64Content(binaryContent);
- }
- InfoboxReadResponseType infoboxReadResponseType = factory.createInfoboxReadResponseType();
- infoboxReadResponseType.setBinaryFileData(base64XMLContentType);
-
- JAXBElement infoboxReadResponse = factory.createInfoboxReadResponse(infoboxReadResponseType);
-
- JAXBContext context = SLCommandFactory.getJaxbContext();
- try {
- Marshaller marshaller = context.createMarshaller();
- marshaller.marshal(infoboxReadResponse, doc);
- } catch (JAXBException e) {
- log.error("Failed to marshal 'InfoboxReadResponse' document.", e);
- throw new SLRuntimeException(e);
- }
-
- return doc;
-
- }
-
-
- /**
- * @return an XMLResult for marshalling the infobox to
- */
- Result getXmlResult(boolean preserveSpace) {
-
- xmlDocument = createResponseDocument(null, preserveSpace);
-
- NodeList nodeList = xmlDocument.getElementsByTagNameNS(SLCommand.NAMESPACE_URI, "XMLContent");
- return new DOMResult(nodeList.item(0));
-
- }
-
- /**
- * Creates a new result document for this InfoboxReadResult
- * and sets the given resultBytes as content.
- *
- * @param resultBytes
- */
- void setResultBytes(byte[] resultBytes) {
-
- xmlDocument = createResponseDocument(resultBytes, false);
-
- }
-
- @Override
- public void writeTo(Result result) {
-
- try {
- writeTo(result, null);
- } catch (TransformerException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- /* (non-Javadoc)
- * @see at.gv.egiz.bku.slcommands.impl.SLResultImpl#writeTo(javax.xml.transform.Result, javax.xml.transform.Transformer)
- */
- @Override
- public void writeTo(Result result, Transformer transformer) throws TransformerException {
-
- if (transformer == null) {
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- try {
- transformer = transformerFactory.newTransformer();
- } catch (TransformerConfigurationException e) {
- log.error("Failed to create Transformer.", e);
- throw new SLRuntimeException(e);
- }
- }
- transformer.transform(new DOMSource(xmlDocument), result);
-
- }
-
-}
+package at.gv.egiz.bku.slcommands.impl;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
+
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadDataAssocArrayType;
+import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
+
+public class InfoboxReadResultImpl extends SLResultImpl {
+
+ /**
+ * The InfoboxReadResponse
+ */
+ protected InfoboxReadResponseType infoboxReadResponse;
+
+ public InfoboxReadResultImpl(InfoboxReadDataAssocArrayType assocArray) {
+
+ ObjectFactory objectFactory = new ObjectFactory();
+ InfoboxReadResponseType infoboxReadResponseType = objectFactory.createInfoboxReadResponseType();
+
+ infoboxReadResponseType.setAssocArrayData(assocArray);
+
+ this.infoboxReadResponse = infoboxReadResponseType;
+ }
+
+ @Override
+ public void writeTo(Result result, Templates templates) {
+ ObjectFactory objectFactory = new ObjectFactory();
+ JAXBElement response = objectFactory.createInfoboxReadResponse(infoboxReadResponse);
+ writeTo(response, result, templates);
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java
index ae1f91ce..05986f85 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java
@@ -18,6 +18,7 @@ package at.gv.egiz.bku.slcommands.impl;
import javax.xml.bind.JAXBElement;
import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
import at.buergerkarte.namespaces.securitylayer._1.NullOperationResponseType;
import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
@@ -40,8 +41,8 @@ public class NullOperationResultImpl extends SLResultImpl implements NullOperati
}
@Override
- public void writeTo(Result result) {
- writeTo(RESPONSE, result);
+ public void writeTo(Result result, Templates templates) {
+ writeTo(RESPONSE, result, templates);
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java
index a79382b6..57309182 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java
@@ -16,24 +16,33 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.transform.Result;
+import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Node;
+import at.buergerkarte.namespaces.securitylayer._1.ErrorResponseType;
+import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
import at.gv.egiz.bku.slcommands.SLCommandFactory;
import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slexceptions.SLBindingException;
+import at.gv.egiz.bku.slexceptions.SLCommandException;
+import at.gv.egiz.bku.slexceptions.SLException;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
/**
* This class serves as an abstract base class for the implementation of a
@@ -72,46 +81,135 @@ public abstract class SLResultImpl implements SLResult {
return resultingMimeType;
}
+ private Marshaller getMarshaller() {
+ try {
+ JAXBContext context = SLCommandFactory.getJaxbContext();
+ Marshaller marshaller = context.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+ return marshaller;
+ } catch (JAXBException e) {
+ log.fatal("Failed to marshall error response.", e);
+ throw new SLRuntimeException("Failed to marshall error response.", e);
+ }
+ }
+
+ private TransformerHandler getTransformerHandler(Templates templates, Result result) throws SLException {
+ try {
+ SAXTransformerFactory transformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
+ TransformerHandler transformerHandler = transformerFactory.newTransformerHandler(templates);
+ transformerHandler.setResult(result);
+ return transformerHandler;
+ } catch (TransformerFactoryConfigurationError e) {
+ log.error("Failed to create an instance of SAXTransformerFactory.", e);
+ throw new SLBindingException(2000);
+ } catch (IllegalArgumentException e) {
+ log.error("Failed to set result for transformation.", e);
+ throw new SLBindingException(2000);
+ } catch (TransformerConfigurationException e) {
+ log.info("Failed to create an instance of SAXTransformerFactory.", e);
+ throw new SLBindingException(2008);
+ }
+ }
+
+ @Override
+ public void writeTo(Result result) {
+ writeTo(result, null);
+ }
+
+
/**
- * Writes the given response to the result.
+ * Writes the given response to the SAX result using
+ * the given transform templates.
*
- * @param response the security layer response element
- * @param result the result to marshal the response to
+ * @param response
+ * @param result
+ * @param templates
*/
- @SuppressWarnings("unchecked")
- public void writeTo(JAXBElement response, Result result) {
+ protected void writeTo(JAXBElement> response, Result result, Templates templates) {
+ TransformerHandler transformerHandler = null;
+ if (templates != null) {
+ try {
+ transformerHandler = getTransformerHandler(templates, result);
+ } catch (SLException e) {
+ writeErrorTo(e, result, templates);
+ }
+ }
+
+ Marshaller marshaller = getMarshaller();
try {
- JAXBContext context = SLCommandFactory.getJaxbContext();
- Marshaller marshaller = context.createMarshaller();
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
- marshaller.marshal(response, result);
+ if (transformerHandler != null) {
+ marshaller.marshal(response, transformerHandler);
+ } else {
+ marshaller.marshal(response, result);
+ }
} catch (JAXBException e) {
- // TODO Add throws clause to interface
- log.fatal("Failed to marshall JAXBElement.", e);
- throw new RuntimeException("Failed to marshall JAXBElement.", e);
+ log.info("Failed to marshall " + response.getName() + " result." , e);
+ SLCommandException commandException = new SLCommandException(4000);
+ writeErrorTo(commandException, result, templates);
}
+
+ }
+
+ protected void writeTo(Node node, Result result, Templates templates) {
+ if (templates == null) {
+ try {
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.transform(new DOMSource(node), result);
+ } catch (TransformerConfigurationException e) {
+ log.error("Failed to create Transformer.", e);
+ writeErrorTo(new SLException(4000), result, null);
+ } catch (TransformerException e) {
+ log.error("Failed to transform result.", e);
+ writeErrorTo(new SLException(4000), result, null);
+ }
+ } else {
+ try {
+ Transformer transformer = templates.newTransformer();
+ transformer.transform(new DOMSource(node), result);
+ } catch (TransformerConfigurationException e) {
+ log.info("Failed to create transformer.", e);
+ writeErrorTo(new SLException(2008), result, templates);
+ } catch (TransformerException e) {
+ log.error("Failed to transform result.", e);
+ writeErrorTo(new SLException(2008), result, templates);
+ }
+ }
+
}
+
+ protected void writeErrorTo(SLException slException, Result result, Templates templates) {
+
+ TransformerHandler transformerHandler = null;
+ if (templates != null) {
+ try {
+ transformerHandler = getTransformerHandler(templates, result);
+ } catch (SLException e) {
+ // write the exception thrown instead of the given one
+ slException = e;
+ }
+ }
- /* (non-Javadoc)
- * @see at.gv.egiz.bku.slcommands.SLResult#writeTo(javax.xml.transform.Result, javax.xml.transform.Transformer)
- */
- @Override
- public void writeTo(Result result, Transformer transformer) throws TransformerException {
- // TODO Auto-generated method stub
- // fixxme: wb added for testing purposes to be completed
- // begin hack
- if (transformer == null) {
- writeTo(result);
- return;
+ ObjectFactory factory = new ObjectFactory();
+ ErrorResponseType responseType = factory.createErrorResponseType();
+ responseType.setErrorCode(slException.getErrorCode());
+ responseType.setInfo(slException.getDetailedMsg());
+ JAXBElement response = factory.createErrorResponse(responseType);
+
+ Marshaller marshaller = getMarshaller();
+ try {
+ if (transformerHandler != null) {
+ marshaller.marshal(response, transformerHandler);
+ } else {
+ marshaller.marshal(response, result);
+ }
+ } catch (JAXBException e) {
+ log.fatal("Failed to marshall error result." , e);
+ throw new SLRuntimeException("Failed to marshall error result.");
}
- // just a quick hack to proceed with testing
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- writeTo(new StreamResult(os));
- ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
- transformer.transform(new StreamSource(is), result);
- //end hack
+
}
}
--
cgit v1.2.3
From c2ae3db1bc6dcb8ba3eb3461c05e293917c004ca Mon Sep 17 00:00:00 2001
From: mcentner
Date: Thu, 30 Oct 2008 10:33:29 +0000
Subject: Updated SMCC to use exclusive access and to throw exceptions upon
locked or not activated cards. Improved locale support in the security layer
request and response processing. Fixed issue in STAL which prevented the use
of RSA-SHA1 signatures. Added additional parameters to the applet test pages.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@128 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../main/java/at/gv/egiz/bku/gui/PinDocument.java | 2 +-
.../egiz/bku/online/webapp/BKURequestHandler.java | 20 +-
BKUOnline/src/main/webapp/HTTP-ohne.html | 11 +-
BKUOnline/src/main/webapp/appletPage.jsp | 29 +-
.../at/gv/egiz/stal/util/JCEAlgorithmNames.java | 4 +-
.../gv/egiz/bku/binding/HTTPBindingProcessor.java | 3 +-
.../gv/egiz/bku/slcommands/SLCommandContext.java | 17 +-
.../impl/CreateXMLSignatureCommandImpl.java | 4 +-
.../egiz/bku/slcommands/impl/ErrorResultImpl.java | 42 ++-
.../slcommands/impl/InfoboxReadCommandImpl.java | 2 +-
.../gv/egiz/bku/slcommands/impl/SLResultImpl.java | 8 +-
.../bku/slcommands/impl/ErrorResultImplTest.java | 3 +-
smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java | 348 ++++++++++++---------
.../at/gv/egiz/smcc/AbstractSignatureCard.java | 169 +++++++---
.../at/gv/egiz/smcc/FileNotFoundException.java | 38 +++
.../main/java/at/gv/egiz/smcc/LockedException.java | 38 +++
.../at/gv/egiz/smcc/NotActivatedException.java | 44 +++
.../src/main/java/at/gv/egiz/smcc/STARCOSCard.java | 339 ++++++++++++--------
smcc/src/main/java/at/gv/egiz/smcc/SWCard.java | 79 ++++-
.../at/gv/egiz/smcc/SignatureCardException.java | 2 +-
.../java/at/gv/egiz/smcc/SignatureCardFactory.java | 223 +++++++++++--
.../java/at/gv/egiz/smcc/util/SmartCardIO.java | 3 +-
.../test/java/at/gv/egiz/smcc/STARCOSCardTest.java | 92 ++++++
.../bku/smccstal/InfoBoxReadRequestHandler.java | 8 +
.../gv/egiz/bku/smccstal/SignRequestHandler.java | 10 +-
25 files changed, 1149 insertions(+), 389 deletions(-)
create mode 100644 smcc/src/main/java/at/gv/egiz/smcc/FileNotFoundException.java
create mode 100644 smcc/src/main/java/at/gv/egiz/smcc/LockedException.java
create mode 100644 smcc/src/main/java/at/gv/egiz/smcc/NotActivatedException.java
create mode 100644 smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java
(limited to 'bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java')
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
index 8ae9d7a3..2054ae86 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
@@ -46,7 +46,7 @@ class PINDocument extends PlainDocument {
@Override
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
- if (pinSpec.getMaxLength() >= (getLength() + str.length())) {
+ if (pinSpec.getMaxLength() < 0 || pinSpec.getMaxLength() >= (getLength() + str.length())) {
boolean matches = true;
for (int i = 0; i < str.length(); i++) {
Matcher m = pinPattern.matcher(str.substring(i, i + 1));
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
index 6f3b9d7f..9092e3f9 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
@@ -44,6 +44,8 @@ import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage;
*/
public class BKURequestHandler extends SpringBKUServlet {
+ private static final long serialVersionUID = 1L;
+
public final static String REDIRECT_URL = "appletPage.jsp";
protected Log log = LogFactory.getLog(BKURequestHandler.class);
@@ -105,6 +107,8 @@ public class BKURequestHandler extends SpringBKUServlet {
String width = getStringFromStream(bindingProcessor.getFormData("appletWidth"), charset);
String height = getStringFromStream(bindingProcessor.getFormData("appletHeight"), charset);
String background = getStringFromStream(bindingProcessor.getFormData("appletBackground"), charset);
+ String guiStyle = getStringFromStream(bindingProcessor.getFormData("appletGuiStyle"), charset);
+ String hashDataDisplay = getStringFromStream(bindingProcessor.getFormData("appletHashDataDisplay"), charset);
if (width != null) {
try {
log.trace("Found applet width parameter: " + width);
@@ -124,12 +128,16 @@ public class BKURequestHandler extends SpringBKUServlet {
}
}
if (background != null) {
- try {
- log.trace("Found applet background parameter: " + background);
- session.setAttribute("appletBackground", background);
- } catch (NumberFormatException nfe) {
- log.warn(nfe);
- }
+ log.trace("Found applet background parameter: " + background);
+ session.setAttribute("appletBackground", background);
+ }
+ if (guiStyle != null) {
+ log.trace("Found applet GUI style parameter: " + guiStyle);
+ session.setAttribute("appletGuiStyle", guiStyle);
+ }
+ if (hashDataDisplay != null) {
+ log.trace("Found applet hash data display parameter: " + hashDataDisplay);
+ session.setAttribute("appletHashDataDisplay", hashDataDisplay);
}
resp.sendRedirect(REDIRECT_URL);
diff --git a/BKUOnline/src/main/webapp/HTTP-ohne.html b/BKUOnline/src/main/webapp/HTTP-ohne.html
index 1923113e..044432ce 100644
--- a/BKUOnline/src/main/webapp/HTTP-ohne.html
+++ b/BKUOnline/src/main/webapp/HTTP-ohne.html
@@ -92,8 +92,17 @@ legend {
name="appletHeight" value="130" id="appletHeight">
+
+
+ simple
+ advanced
+
+
+
+ external
+ internal
+
-
+
@@ -215,6 +222,11 @@
slf4j-log4j121.5.8
+
+ log4j
+ log4j
+ compile
+
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Configurator.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Configurator.java
index 923a70d9..d8fe3e70 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Configurator.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Configurator.java
@@ -16,8 +16,9 @@
*/
package at.gv.egiz.bku.webstart;
-import at.gv.egiz.bku.utils.StreamUtil;
import iaik.asn1.CodingException;
+import iaik.utils.StreamCopier;
+
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
@@ -42,8 +43,10 @@ import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
+import org.apache.log4j.PropertyConfigurator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -71,7 +74,7 @@ public class Configurator {
public static final String KEYSTORE_FILE = "keystore.ks";
public static final String PASSWD_FILE = ".secret";
- private static final Log log = LogFactory.getLog(Configurator.class);
+ private static final Logger log = LoggerFactory.getLogger(Configurator.class);
/** currently installed configuration version */
private String version;
@@ -110,6 +113,11 @@ public class Configurator {
} else {
initConfig(configDir);
}
+ // re-configure logging
+ // TODO: move to appropriate place
+ String log4jconfig = configDir.getPath() + File.separatorChar + "log4j.properties";
+ log.debug("Reconfiguring logging with " + log4jconfig);
+ PropertyConfigurator.configureAndWatch(log4jconfig);
}
/**
@@ -312,7 +320,7 @@ public class Configurator {
ZipEntry entry = new ZipEntry(relativePath.toString());
zip.putNextEntry(entry);
BufferedInputStream entryIS = new BufferedInputStream(new FileInputStream(dir));
- StreamUtil.copyStream(entryIS, zip);
+ new StreamCopier(entryIS, zip).copyStream();
entryIS.close();
zip.closeEntry();
dir.delete();
@@ -341,7 +349,7 @@ public class Configurator {
File confTemplateFile = new File(configDir, CONF_TEMPLATE_FILE);
InputStream is = Configurator.class.getClassLoader().getResourceAsStream(CONF_TEMPLATE_RESOURCE);
OutputStream os = new BufferedOutputStream(new FileOutputStream(confTemplateFile));
- StreamUtil.copyStream(is, os);
+ new StreamCopier(is, os).copyStream();
os.close();
unzip(confTemplateFile, configDir);
confTemplateFile.delete();
@@ -374,7 +382,7 @@ public class Configurator {
new File(certsDir, f.substring(0, f.lastIndexOf('/'))).mkdirs();
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(certsDir, f)));
log.debug(f);
- StreamUtil.copyStream(Configurator.class.getClassLoader().getResourceAsStream(entry), bos);
+ new StreamCopier(Configurator.class.getClassLoader().getResourceAsStream(entry), bos).copyStream();
bos.close();
} else {
log.trace("ignore " + entry);
@@ -399,8 +407,8 @@ public class Configurator {
}
File f = new File(eF.getParent());
f.mkdirs();
- StreamUtil.copyStream(zipFile.getInputStream(entry),
- new FileOutputStream(eF));
+ new StreamCopier(zipFile.getInputStream(entry),
+ new FileOutputStream(eF)).copyStream();
}
zipFile.close();
}
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Container.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Container.java
index 2feae267..4d1fe658 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Container.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Container.java
@@ -1,6 +1,7 @@
package at.gv.egiz.bku.webstart;
-import at.gv.egiz.bku.utils.StreamUtil;
+import iaik.utils.StreamCopier;
+
import java.awt.AWTPermission;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -24,20 +25,20 @@ import java.security.SecurityPermission;
import java.security.cert.Certificate;
import java.util.PropertyPermission;
import javax.smartcardio.CardPermission;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.security.SslSocketConnector;
import org.mortbay.jetty.webapp.WebAppContext;
import org.mortbay.thread.QueuedThreadPool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Container {
public static final String HTTP_PORT_PROPERTY = "mocca.http.port";
public static final String HTTPS_PORT_PROPERTY = "mocca.http.port";
- private static Log log = LogFactory.getLog(Container.class);
+ private static Logger log = LoggerFactory.getLogger(Container.class);
static {
if (log.isDebugEnabled()) {
@@ -166,7 +167,7 @@ public class Container {
log.debug("copying BKULocal classpath resource to " + webapp);
InputStream is = getClass().getClassLoader().getResourceAsStream("BKULocal.war");
OutputStream os = new BufferedOutputStream(new FileOutputStream(webapp));
- StreamUtil.copyStream(is, os);
+ new StreamCopier(is, os).copyStream();
os.close();
return webapp.getPath();
}
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java
index 2bf42ccb..ef7edef1 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java
@@ -10,8 +10,6 @@ import java.util.Locale;
import java.util.ResourceBundle;
import javax.jnlp.UnavailableServiceException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import com.sun.javaws.security.JavaWebStartSecurity;
import java.awt.AWTException;
@@ -37,6 +35,8 @@ import javax.jnlp.BasicService;
import javax.jnlp.ServiceManager;
import javax.swing.JFrame;
import org.mortbay.util.MultiException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Launcher implements BKUControllerInterface, ActionListener {
public static final String HELP_COMMAND = "help";
@@ -71,9 +71,10 @@ public class Launcher implements BKUControllerInterface, ActionListener {
public static final String SHUTDOWN_COMMAND = "shutdown";
public static final String PIN_COMMAND = "pin";
public static final String ABOUT_COMMAND = "about";
+
+ private static Logger log = LoggerFactory.getLogger(Launcher.class);
- private static Log log = LogFactory.getLog(Launcher.class);
-
+
/** local bku uri */
public static final URL HTTP_SECURITY_LAYER_URL;
public static final URL HTTPS_SECURITY_LAYER_URL;
@@ -93,7 +94,7 @@ public class Launcher implements BKUControllerInterface, ActionListener {
cert = new URL(http, "/installCertificate");
help = new URL(http, "/help");
} catch (MalformedURLException ex) {
- log.error(ex);
+ log.error("Failed to create URL.", ex);
} finally {
HTTP_SECURITY_LAYER_URL = http;
HTTPS_SECURITY_LAYER_URL = https;
@@ -132,6 +133,7 @@ public class Launcher implements BKUControllerInterface, ActionListener {
public Launcher() {
+ log.info("Initializing Launcher");
if (log.isTraceEnabled()) {
SecurityManager sm = System.getSecurityManager();
if (sm instanceof JavaWebStartSecurity) {
@@ -147,7 +149,7 @@ public class Launcher implements BKUControllerInterface, ActionListener {
try {
initConfig();
} catch (Exception ex) {
- log.fatal("Failed to initialize configuration", ex);
+ log.error("Failed to initialize configuration", ex);
trayIcon.displayMessage(messages.getString(CAPTION_ERROR),
messages.getString(ERROR_CONFIG), TrayIcon.MessageType.ERROR);
throw ex;
@@ -156,12 +158,12 @@ public class Launcher implements BKUControllerInterface, ActionListener {
startServer();
initFinished();
} catch (BindException ex) {
- log.fatal("Failed to launch server, " + ex.getMessage(), ex);
+ log.error("Failed to launch server, " + ex.getMessage(), ex);
trayIcon.displayMessage(messages.getString(CAPTION_ERROR),
messages.getString(ERROR_BIND), TrayIcon.MessageType.ERROR);
throw ex;
} catch (MultiException ex) {
- log.fatal("Failed to launch server, " + ex.getMessage(), ex);
+ log.error("Failed to launch server, " + ex.getMessage(), ex);
if (ex.getThrowable(0) instanceof BindException) {
trayIcon.displayMessage(messages.getString(CAPTION_ERROR),
messages.getString(ERROR_BIND), TrayIcon.MessageType.ERROR);
@@ -172,7 +174,7 @@ public class Launcher implements BKUControllerInterface, ActionListener {
throw ex;
} catch (Exception ex) {
ex.printStackTrace();
- log.fatal("Failed to launch server, " + ex.getMessage(), ex);
+ log.error("Failed to launch server, " + ex.getMessage(), ex);
trayIcon.displayMessage(messages.getString(CAPTION_ERROR),
messages.getString(ERROR_START), TrayIcon.MessageType.ERROR);
throw ex;
@@ -379,7 +381,7 @@ public class Launcher implements BKUControllerInterface, ActionListener {
launcher.launch();
} catch (Exception ex) {
ex.printStackTrace();
- log.debug(ex);
+ log.debug("Caught exception " + ex.getMessage(), ex);
log.info("waiting to shutdown...");
Thread.sleep(5000);
log.info("exit");
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/LogSecurityManager.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/LogSecurityManager.java
index 99fd403b..d589812e 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/LogSecurityManager.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/LogSecurityManager.java
@@ -20,8 +20,9 @@ import com.sun.javaws.security.JavaWebStartSecurity;
import java.io.FileDescriptor;
import java.net.InetAddress;
import java.security.Permission;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* JVM argument -Djava.security.debug=access,failure
@@ -31,7 +32,7 @@ import org.apache.commons.logging.LogFactory;
*/
public class LogSecurityManager extends SecurityManager {
- protected static final Log log = LogFactory.getLog(LogSecurityManager.class);
+ protected static final Logger log = LoggerFactory.getLogger(LogSecurityManager.class);
JavaWebStartSecurity sm;
public LogSecurityManager(JavaWebStartSecurity sm) {
@@ -182,6 +183,7 @@ public class LogSecurityManager extends SecurityManager {
}
}
+ @SuppressWarnings("deprecation")
@Override
public void checkMulticast(InetAddress maddr, byte ttl) {
try {
@@ -399,6 +401,7 @@ public class LogSecurityManager extends SecurityManager {
// protected Class[] getClassContext() {
// log.info("getClassContext"); return sm.getClassContext();
// }
+ @SuppressWarnings("deprecation")
@Override
public boolean getInCheck() {
log.info("getInCheck");
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/TLSServerCA.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/TLSServerCA.java
index 08a06570..745042f8 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/TLSServerCA.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/TLSServerCA.java
@@ -16,8 +16,6 @@ import iaik.x509.extensions.SubjectAltName;
import iaik.x509.extensions.SubjectKeyIdentifier;
import java.io.IOException;
import java.math.BigInteger;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.security.GeneralSecurityException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
@@ -27,14 +25,15 @@ import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Random;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class TLSServerCA {
public static final int CA_VALIDITY_Y = 3;
public static final String MOCCA_TLS_SERVER_ALIAS = "server";
public static final int SERVER_VALIDITY_Y = 3;
- private final static Log log = LogFactory.getLog(TLSServerCA.class);
+ private final static Logger log = LoggerFactory.getLogger(TLSServerCA.class);
private KeyPair caKeyPair;
private X509Certificate caCert;
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/AboutDialog.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/AboutDialog.java
index 1e35af58..ba2c007d 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/AboutDialog.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/AboutDialog.java
@@ -11,7 +11,6 @@
package at.gv.egiz.bku.webstart.gui;
-import java.text.Format;
import java.text.MessageFormat;
import java.util.ResourceBundle;
@@ -21,6 +20,11 @@ import java.util.ResourceBundle;
*/
public class AboutDialog extends javax.swing.JDialog {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
/** Creates new form AboutDialog */
public AboutDialog(java.awt.Frame parent, boolean modal, String version) {
super(parent, modal);
@@ -33,7 +37,6 @@ public class AboutDialog extends javax.swing.JDialog {
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
- @SuppressWarnings("unchecked")
// //GEN-BEGIN:initComponents
private void initComponents() {
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/PINManagementInvoker.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/PINManagementInvoker.java
index 55e26313..1f14d751 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/PINManagementInvoker.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/PINManagementInvoker.java
@@ -21,8 +21,9 @@ import java.awt.TrayIcon;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.ResourceBundle;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* GUI is painted using SwingUtilities.invokeLater, but TrayIcon ActionListener Thread (== webstart thread) joined Jetty Thread
@@ -31,7 +32,7 @@ import org.apache.commons.logging.LogFactory;
*/
public class PINManagementInvoker implements Runnable {
- private static final Log log = LogFactory.getLog(PINManagementInvoker.class);
+ private static final Logger log = LoggerFactory.getLogger(PINManagementInvoker.class);
TrayIcon trayIcon;
ResourceBundle messages;
diff --git a/BKUWebStart/src/main/resources/log4j.properties b/BKUWebStart/src/main/resources/log4j.properties
index 76562ccf..81832418 100644
--- a/BKUWebStart/src/main/resources/log4j.properties
+++ b/BKUWebStart/src/main/resources/log4j.properties
@@ -13,23 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# loglever DEBUG, appender STDOUT
-log4j.rootLogger=DEBUG, file
-log4j.logger.org.mortbay.log=INFO
-log4j.logger.pki=INFO
-
-#log4j.additivity.pki=false
+# root log level INFO, appender file
+log4j.rootLogger=INFO, file
-# STDOUT appender
-log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
-log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
-#log4j.appender.STDOUT.layout.ConversionPattern=%5p | %d{dd HH:mm:ss,SSS} | %20c | %10t | %m%n
-#log4j.appender.STDOUT.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
-log4j.appender.STDOUT.layout.ConversionPattern=%-5p |%d | %t | %c %x- %m%n
+# jetty's log level
+log4j.logger.org.mortbay.log=INFO
-### FILE appender
+# file appender
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.datePattern='.'yyyy-MM-dd
log4j.appender.file.File=${user.home}/.mocca/logs/webstart.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %-5p %c{1}:%L - %m%n
\ No newline at end of file
+log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %-5p %c{2} - %m%n
\ No newline at end of file
diff --git a/BKUWebStart/src/test/java/at/gv/egiz/bku/webstart/ConfiguratorTest.java b/BKUWebStart/src/test/java/at/gv/egiz/bku/webstart/ConfiguratorTest.java
index 0ea126cb..4f5798d5 100644
--- a/BKUWebStart/src/test/java/at/gv/egiz/bku/webstart/ConfiguratorTest.java
+++ b/BKUWebStart/src/test/java/at/gv/egiz/bku/webstart/ConfiguratorTest.java
@@ -8,8 +8,6 @@ package at.gv.egiz.bku.webstart;
import java.io.File;
import java.net.URI;
import java.util.zip.ZipOutputStream;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
diff --git a/BKUWebStartPackage/pom.xml b/BKUWebStartPackage/pom.xml
index 63725fc3..0b226785 100644
--- a/BKUWebStartPackage/pom.xml
+++ b/BKUWebStartPackage/pom.xml
@@ -1,3 +1,4 @@
+
4.0.0
@@ -22,7 +23,7 @@
process-resources
- jnlp-download-servlet
+ jnlp-single
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
index 1db8c836..d3945253 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java
@@ -16,7 +16,6 @@
*/
package at.gv.egiz.bku.binding;
-import at.gv.egiz.bku.conf.Configuration;
import at.gv.egiz.bku.conf.Configurator;
import java.net.MalformedURLException;
import java.net.URL;
@@ -89,13 +88,7 @@ public class DataUrl {
if (configuration != null) {
String className = configuration.getProperty(Configurator.DATAURLCONNECTION_CONFIG_P);
if (className != null) {
- try {
- log.info("set DataURLConnection class: " + className);
- Class c = Class.forName(className);
- connection = (DataUrlConnectionSPI) c.newInstance();
- } catch (Exception ex) {
- log.error("failed to instantiate DataURL connection " + className, ex);
- }
+ log.warn("Set DataURLConnection class not supported!");
}
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
index f954a017..384cf71c 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnection.java
@@ -62,7 +62,7 @@ public interface DataUrlConnection {
* @param transferEncoding may be null
*/
public void setHTTPFormParameter(String name, InputStream data, String contentType, String charSet, String transferEncoding);
-
+
/**
* @pre httpHeaders != null
* @throws java.net.SocketTimeoutException
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 4f2d2e00..b092ba41 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
@@ -18,10 +18,14 @@ package at.gv.egiz.bku.binding;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
import java.net.URL;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
@@ -34,6 +38,7 @@ import java.util.Set;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;
+import javax.xml.transform.stream.StreamResult;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.Part;
@@ -47,32 +52,92 @@ import at.gv.egiz.bku.conf.Configurator;
import at.gv.egiz.bku.slcommands.SLResult;
import at.gv.egiz.bku.slcommands.SLResult.SLResultType;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.URLEncodingWriter;
import at.gv.egiz.bku.utils.binding.Protocol;
/**
- * not thread-safe thus newInsance always returns a new object
+ * An implementation of the DataUrlConnectionSPI that supports
+ * multipart/form-data encoding and
+ * application/x-www-form-urlencoded for compatibility with legacy
+ * systems.
*
*/
public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
private final static Log log = LogFactory.getLog(DataUrlConnectionImpl.class);
+
+ public static final byte[] B_DEFAULT_RESPONSETYPE = DEFAULT_RESPONSETYPE.getBytes(Charset.forName("UTF-8"));
+ /**
+ * Supported protocols are HTTP and HTTPS.
+ */
public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
Protocol.HTTPS };
+ /**
+ * The X509 certificate of the DataURL server.
+ */
protected X509Certificate serverCertificate;
+
+ /**
+ * The protocol of the DataURL.
+ */
protected Protocol protocol;
+
+ /**
+ * Use application/x-www-form-urlencoded instead of
+ * standard conform application/x-www-form-urlencoded.
+ */
+ protected boolean urlEncoded = true;
+
+ /**
+ * The value of the DataURL.
+ */
protected URL url;
+
+ /**
+ * The URLConnection used for communication with the DataURL server.
+ */
private HttpURLConnection connection;
+
+ /**
+ * The HTTP request headers.
+ */
protected Map requestHttpHeaders;
- protected ArrayList formParams;
+
+ /**
+ * The HTTP form parameters.
+ */
+ protected ArrayList httpFormParameter;
+
+ /**
+ * The boundary for multipart/form-data requests.
+ */
protected String boundary;
+
+ /**
+ * The configuration properties.
+ */
protected Properties config = null;
+
+ /**
+ * The SSLSocketFactory for HTTPS connections.
+ */
protected SSLSocketFactory sslSocketFactory;
+
+ /**
+ * The HostnameVerifier for HTTPS connections.
+ */
protected HostnameVerifier hostnameVerifier;
+ /**
+ * The response of the DataURL server.
+ */
protected DataUrlResponse result;
+ /* (non-Javadoc)
+ * @see at.gv.egiz.bku.binding.DataUrlConnection#getProtocol()
+ */
public String getProtocol() {
if (protocol == null) {
return null;
@@ -80,13 +145,8 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
return protocol.toString();
}
- /**
- * opens a connection sets the headers gets the server certificate
- *
- * @throws java.net.SocketTimeoutException
- * @throws java.io.IOException
- * @pre url != null
- * @pre httpHeaders != null
+ /* (non-Javadoc)
+ * @see at.gv.egiz.bku.binding.DataUrlConnection#connect()
*/
public void connect() throws SocketTimeoutException, IOException {
connection = (HttpURLConnection) url.openConnection();
@@ -104,9 +164,26 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
https.setHostnameVerifier(hostnameVerifier);
}
} else {
- log.trace("No secure connection with: "+url+ " class="+connection.getClass());
+ log.trace("No secure connection with: " + url + " class="
+ + connection.getClass());
}
connection.setDoOutput(true);
+ // Transfer-Encoding: chunked is problematic ...
+ // e.g. https://issues.apache.org/bugzilla/show_bug.cgi?id=37794
+ // ... therefore disabled.
+ // connection.setChunkedStreamingMode(5*1024);
+ if (urlEncoded) {
+ log.debug("Setting DataURL Content-Type to "
+ + HttpUtil.APPLICATION_URL_ENCODED);
+ connection.addRequestProperty(HttpUtil.HTTP_HEADER_CONTENT_TYPE,
+ HttpUtil.APPLICATION_URL_ENCODED);
+ } else {
+ log.debug("Setting DataURL Content-Type to "
+ + HttpUtil.MULTIPART_FOTMDATA_BOUNDARY);
+ connection.addRequestProperty(HttpUtil.HTTP_HEADER_CONTENT_TYPE,
+ HttpUtil.MULTIPART_FOTMDATA + HttpUtil.SEPERATOR[0]
+ + HttpUtil.MULTIPART_FOTMDATA_BOUNDARY + "=" + boundary);
+ }
Set headers = requestHttpHeaders.keySet();
Iterator headerIt = headers.iterator();
while (headerIt.hasNext()) {
@@ -125,51 +202,128 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
}
}
+ /* (non-Javadoc)
+ * @see at.gv.egiz.bku.binding.DataUrlConnection#getServerCertificate()
+ */
public X509Certificate getServerCertificate() {
return serverCertificate;
}
+ /* (non-Javadoc)
+ * @see at.gv.egiz.bku.binding.DataUrlConnection#setHTTPHeader(java.lang.String, java.lang.String)
+ */
public void setHTTPHeader(String name, String value) {
if (name != null && value != null) {
requestHttpHeaders.put(name, value);
}
}
+ /* (non-Javadoc)
+ * @see at.gv.egiz.bku.binding.DataUrlConnection#setHTTPFormParameter(java.lang.String, java.io.InputStream, java.lang.String, java.lang.String, java.lang.String)
+ */
public void setHTTPFormParameter(String name, InputStream data,
String contentType, String charSet, String transferEncoding) {
- InputStreamPartSource source = new InputStreamPartSource(null, data);
- FilePart formParam = new FilePart(name, source, contentType, charSet);
- if (transferEncoding != null) {
- formParam.setTransferEncoding(transferEncoding);
- } else {
- formParam.setTransferEncoding(null);
+ // if a content type is specified we have to switch to multipart/formdata encoding
+ if (contentType != null && contentType.length() > 0) {
+ urlEncoded = false;
}
- formParams.add(formParam);
+ httpFormParameter.add(new HTTPFormParameter(name, data, contentType,
+ charSet, transferEncoding));
}
- /**
- * send all formParameters
- *
- * @throws java.io.IOException
+
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.bku.binding.DataUrlConnection#transmit(at.gv.egiz.bku.slcommands.SLResult)
*/
public void transmit(SLResult slResult) throws IOException {
- SLResultPart slResultPart = new SLResultPart(slResult,
- XML_RESPONSE_ENCODING);
- if (slResult.getResultType() == SLResultType.XML) {
- slResultPart.setTransferEncoding(null);
- slResultPart.setContentType(slResult.getMimeType());
- slResultPart.setCharSet(XML_RESPONSE_ENCODING);
+ log.trace("Sending data");
+ if (urlEncoded) {
+ //
+ // application/x-www-form-urlencoded (legacy, SL < 1.2)
+ //
+
+ OutputStream os = connection.getOutputStream();
+ OutputStreamWriter streamWriter = new OutputStreamWriter(os, HttpUtil.DEFAULT_CHARSET);
+
+ // ResponseType
+ streamWriter.write(FORMPARAM_RESPONSETYPE);
+ streamWriter.write("=");
+ streamWriter.write(URLEncoder.encode(DEFAULT_RESPONSETYPE, "UTF-8"));
+ streamWriter.write("&");
+
+ // XMLResponse / Binary Response
+ if (slResult.getResultType() == SLResultType.XML) {
+ streamWriter.write(DataUrlConnection.FORMPARAM_XMLRESPONSE);
+ } else {
+ streamWriter.write(DataUrlConnection.FORMPARAM_BINARYRESPONSE);
+ }
+ streamWriter.write("=");
+ streamWriter.flush();
+ URLEncodingWriter urlEnc = new URLEncodingWriter(streamWriter);
+ slResult.writeTo(new StreamResult(urlEnc), false);
+ urlEnc.flush();
+
+ // transfer parameters
+ char[] cbuf = new char[512];
+ int len;
+ for (HTTPFormParameter formParameter : httpFormParameter) {
+ streamWriter.write("&");
+ streamWriter.write(URLEncoder.encode(formParameter.getName(), "UTF-8"));
+ streamWriter.write("=");
+ InputStreamReader reader = new InputStreamReader(formParameter.getData(),
+ (formParameter.getCharSet() != null)
+ ? formParameter.getCharSet()
+ : null);
+ while ((len = reader.read(cbuf)) != -1) {
+ urlEnc.write(cbuf, 0, len);
+ }
+ urlEnc.flush();
+ }
+ streamWriter.close();
+
} else {
- slResultPart.setTransferEncoding(null);
- slResultPart.setContentType(slResult.getMimeType());
- }
- formParams.add(slResultPart);
+ //
+ // multipart/form-data (conforming to SL 1.2)
+ //
- OutputStream os = connection.getOutputStream();
- log.trace("Sending data");
- Part[] parts = new Part[formParams.size()];
- Part.sendParts(os, formParams.toArray(parts), boundary.getBytes());
- os.close();
+ ArrayList parts = new ArrayList();
+
+ // ResponseType
+ StringPart responseType = new StringPart(FORMPARAM_RESPONSETYPE,
+ DEFAULT_RESPONSETYPE, "UTF-8");
+ responseType.setTransferEncoding(null);
+ parts.add(responseType);
+
+ // XMLResponse / Binary Response
+ SLResultPart slResultPart = new SLResultPart(slResult,
+ XML_RESPONSE_ENCODING);
+ if (slResult.getResultType() == SLResultType.XML) {
+ slResultPart.setTransferEncoding(null);
+ slResultPart.setContentType(slResult.getMimeType());
+ slResultPart.setCharSet(XML_RESPONSE_ENCODING);
+ } else {
+ slResultPart.setTransferEncoding(null);
+ slResultPart.setContentType(slResult.getMimeType());
+ }
+ parts.add(slResultPart);
+
+ // transfer parameters
+ for (HTTPFormParameter formParameter : httpFormParameter) {
+ InputStreamPartSource source = new InputStreamPartSource(null,
+ formParameter.getData());
+ FilePart part = new FilePart(formParameter.getName(), source,
+ formParameter.getContentType(), formParameter.getCharSet());
+ part.setTransferEncoding(formParameter.getTransferEncoding());
+ parts.add(part);
+ }
+
+ OutputStream os = connection.getOutputStream();
+ Part.sendParts(os, parts.toArray(new Part[parts.size()]), boundary.getBytes());
+ os.close();
+
+ }
+
// MultipartRequestEntity PostMethod
InputStream is = null;
try {
@@ -241,16 +395,9 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
.put(HttpUtil.HTTP_HEADER_USER_AGENT, Configurator.USERAGENT_DEFAULT);
}
- requestHttpHeaders.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE,
- HttpUtil.MULTIPART_FOTMDATA + HttpUtil.SEPERATOR[0]
- + HttpUtil.MULTIPART_FOTMDATA_BOUNDARY + "=" + boundary);
-
- formParams = new ArrayList();
- StringPart responseType = new StringPart(FORMPARAM_RESPONSETYPE,
- DEFAULT_RESPONSETYPE);
- responseType.setCharSet("UTF-8");
- responseType.setTransferEncoding(null);
- formParams.add(responseType);
+
+ httpFormParameter = new ArrayList();
+
}
@Override
@@ -281,4 +428,107 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
this.hostnameVerifier = hostnameVerifier;
}
+
+ public class HTTPFormParameter {
+
+ private String name;
+
+ private InputStream data;
+
+ private String contentType;
+
+ private String charSet;
+
+ private String transferEncoding;
+
+ /**
+ * @param name
+ * @param data
+ * @param contentType
+ * @param charSet
+ * @param transferEncoding
+ */
+ public HTTPFormParameter(String name, InputStream data, String contentType,
+ String charSet, String transferEncoding) {
+ super();
+ this.name = name;
+ this.data = data;
+ this.contentType = contentType;
+ this.charSet = charSet;
+ this.transferEncoding = transferEncoding;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the data
+ */
+ public InputStream getData() {
+ return data;
+ }
+
+ /**
+ * @param data the data to set
+ */
+ public void setData(InputStream data) {
+ this.data = data;
+ }
+
+ /**
+ * @return the contentType
+ */
+ public String getContentType() {
+ return contentType;
+ }
+
+ /**
+ * @param contentType the contentType to set
+ */
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ /**
+ * @return the charSet
+ */
+ public String getCharSet() {
+ return charSet;
+ }
+
+ /**
+ * @param charSet the charSet to set
+ */
+ public void setCharSet(String charSet) {
+ this.charSet = charSet;
+ }
+
+ /**
+ * @return the transferEncoding
+ */
+ public String getTransferEncoding() {
+ return transferEncoding;
+ }
+
+ /**
+ * @param transferEncoding the transferEncoding to set
+ */
+ public void setTransferEncoding(String transferEncoding) {
+ this.transferEncoding = transferEncoding;
+ }
+
+
+
+ }
}
\ No newline at end of file
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 ef603fc7..a1c4d5fc 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
@@ -22,6 +22,7 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
+import java.io.Writer;
import java.net.URL;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
@@ -46,6 +47,7 @@ import javax.xml.transform.stream.StreamSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import at.gv.egiz.bku.slcommands.ErrorResult;
import at.gv.egiz.bku.slcommands.SLCommand;
import at.gv.egiz.bku.slcommands.SLCommandContext;
import at.gv.egiz.bku.slcommands.SLCommandFactory;
@@ -635,7 +637,6 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
throw new SLBindingException(2006);
}
InputDecoder id = InputDecoderFactory.getDecoder(cl, is);
- id.setContentType(cl);
if (id == null) {
log.error("Cannot get inputdecoder for is");
throw new SLException(2006);
@@ -730,9 +731,20 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
Templates templates) throws IOException {
log.debug("Writing error as result");
ErrorResultImpl error = new ErrorResultImpl(bindingProcessorError, locale);
- error.writeTo(new StreamResult(new OutputStreamWriter(os, encoding)), templates);
+ Writer writer = writeXMLDeclarationAndProcessingInstruction(os, encoding);
+ error.writeTo(new StreamResult(writer), templates, true);
}
+ protected Writer writeXMLDeclarationAndProcessingInstruction(OutputStream os, String encoding) throws IOException {
+ if (encoding == null) {
+ encoding = HttpUtil.DEFAULT_CHARSET;
+ }
+ OutputStreamWriter writer = new OutputStreamWriter(os, encoding);
+ writer.write("\n");
+ writer.write("\n");
+ return writer;
+ }
+
@Override
public void writeResultTo(OutputStream os, String encoding)
throws IOException {
@@ -772,9 +784,16 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements
return;
} else {
log.debug("Getting result from invoker");
- OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
- slResult.writeTo(new StreamResult(osw), templates);
- osw.flush();
+ boolean fragment = false;
+ Writer writer;
+ if (slResult instanceof ErrorResult) {
+ writer = writeXMLDeclarationAndProcessingInstruction(os, encoding);
+ fragment = true;
+ } else {
+ writer = new OutputStreamWriter(os, encoding);
+ }
+ slResult.writeTo(new StreamResult(writer), templates, fragment);
+ writer.flush();
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java
deleted file mode 100644
index cfccb7f1..00000000
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java
+++ /dev/null
@@ -1,259 +0,0 @@
-package at.gv.egiz.bku.binding;
-
-
-import at.gv.egiz.bku.conf.Configurator;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.StringWriter;
-import java.net.HttpURLConnection;
-import java.net.SocketTimeoutException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.security.cert.X509Certificate;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLSocketFactory;
-import javax.xml.transform.stream.StreamResult;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.slcommands.SLResult;
-import at.gv.egiz.bku.slcommands.SLResult.SLResultType;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.bku.utils.binding.Protocol;
-
-/**
- * not thread-safe thus newInsance always returns a new object
- *
- */
-public class LegacyDataUrlConnectionImpl implements DataUrlConnectionSPI {
-
- private final static Log log = LogFactory.getLog(LegacyDataUrlConnectionImpl.class);
-
- public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
- Protocol.HTTPS };
- protected X509Certificate serverCertificate;
- protected Protocol protocol;
- protected URL url;
- private HttpURLConnection connection;
- protected Map requestHttpHeaders;
- protected Map formParams;
- protected String boundary;
- protected Properties config = null;
- protected SSLSocketFactory sslSocketFactory;
- protected HostnameVerifier hostnameVerifier;
-
- protected DataUrlResponse result;
-
- public String getProtocol() {
- if (protocol == null) {
- return null;
- }
- return protocol.toString();
- }
-
- /**
- * opens a connection sets the headers gets the server certificate
- *
- * @throws java.net.SocketTimeoutException
- * @throws java.io.IOException
- * @pre url != null
- * @pre httpHeaders != null
- */
- public void connect() throws SocketTimeoutException, IOException {
- connection = (HttpURLConnection) url.openConnection();
- if (connection instanceof HttpsURLConnection) {
- HttpsURLConnection https = (HttpsURLConnection) connection;
- if (sslSocketFactory != null) {
- log.debug("Setting custom ssl socket factory for ssl connection");
- https.setSSLSocketFactory(sslSocketFactory);
- }
- if (hostnameVerifier != null) {
- log.debug("Setting custom hostname verifier");
- https.setHostnameVerifier(hostnameVerifier);
- }
- }
- connection.setDoOutput(true);
- Set headers = requestHttpHeaders.keySet();
- Iterator headerIt = headers.iterator();
- while (headerIt.hasNext()) {
- String name = headerIt.next();
- connection.setRequestProperty(name, requestHttpHeaders.get(name));
- }
- log.trace("Connecting to: "+url);
- connection.connect();
- if (connection instanceof HttpsURLConnection) {
- HttpsURLConnection ssl = (HttpsURLConnection) connection;
- X509Certificate[] certs = (X509Certificate[]) ssl.getServerCertificates();
- if ((certs != null) && (certs.length >= 1)) {
- log.trace("Server certificate: "+certs[0]);
- serverCertificate = certs[0];
- }
- }
- }
-
- public X509Certificate getServerCertificate() {
- return serverCertificate;
- }
-
- public void setHTTPHeader(String name, String value) {
- if (name != null && value != null) {
- requestHttpHeaders.put(name, value);
- }
- }
-
- public void setHTTPFormParameter(String name, InputStream data,
- String contentType, String charSet, String transferEncoding) {
- StringBuilder sb = new StringBuilder();
- try {
- InputStreamReader reader = new InputStreamReader(data, (charSet != null) ? charSet : "UTF-8");
- char[] c = new char[512];
- for (int l; (l = reader.read(c)) != -1;) {
- sb.append(c, 0, l);
- }
- } catch (IOException e) {
- throw new SLRuntimeException("Failed to set HTTP form parameter.", e);
- }
- formParams.put(name, sb.toString());
- }
-
- /**
- * send all formParameters
- *
- * @throws java.io.IOException
- */
- public void transmit(SLResult slResult) throws IOException {
- StringWriter writer = new StringWriter();
- slResult.writeTo(new StreamResult(writer));
- formParams.put(
- (slResult.getResultType() == SLResultType.XML)
- ? DataUrlConnection.FORMPARAM_XMLRESPONSE
- : DataUrlConnection.FORMPARAM_BINARYRESPONSE,
- writer.toString());
-
- OutputStream os = connection.getOutputStream();
- OutputStreamWriter streamWriter = new OutputStreamWriter(os, HttpUtil.DEFAULT_CHARSET);
-
- log.trace("Sending data");
- Iterator keys = formParams.keySet().iterator();
- while(keys.hasNext()) {
- String key = keys.next();
- streamWriter.write(URLEncoder.encode(key, "UTF-8"));
- streamWriter.write("=");
- streamWriter.write(URLEncoder.encode(formParams.get(key), "UTF-8"));
- if (keys.hasNext()) {
- streamWriter.write("&");
- }
- }
- streamWriter.flush();
- os.close();
-
- // MultipartRequestEntity PostMethod
- InputStream is = null;
- try {
- is = connection.getInputStream();
- } catch (IOException iox) {
- log.info(iox);
- }
- log.trace("Reading response");
- result = new DataUrlResponse(url.toString(), connection.getResponseCode(), is);
- Map responseHttpHeaders = new HashMap();
- Map> httpHeaders = connection.getHeaderFields();
- for (Iterator keyIt = httpHeaders.keySet().iterator(); keyIt
- .hasNext();) {
- String key = keyIt.next();
- StringBuffer value = new StringBuffer();
- for (String val : httpHeaders.get(key)) {
- value.append(val);
- value.append(HttpUtil.SEPERATOR[0]);
- }
- String valString = value.substring(0, value.length() - 1);
- if ((key != null) && (value.length() > 0)) {
- responseHttpHeaders.put(key, valString);
- }
- }
- result.setResponseHttpHeaders(responseHttpHeaders);
- }
-
- @Override
- public DataUrlResponse getResponse() throws IOException {
- return result;
- }
-
- /**
- * inits protocol, url, httpHeaders, formParams
- *
- * @param url
- * must not be null
- */
- @Override
- public void init(URL url) {
-
- for (int i = 0; i < SUPPORTED_PROTOCOLS.length; i++) {
- if (SUPPORTED_PROTOCOLS[i].toString().equalsIgnoreCase(url.getProtocol())) {
- protocol = SUPPORTED_PROTOCOLS[i];
- break;
- }
- }
- if (protocol == null) {
- throw new SLRuntimeException("Protocol " + url.getProtocol()
- + " not supported for data url");
- }
- this.url = url;
- requestHttpHeaders = new HashMap();
- if ((config != null)
- && (config.getProperty(Configurator.USERAGENT_CONFIG_P) != null)) {
- log.debug("setting User-Agent header: " + config.getProperty(Configurator.USERAGENT_CONFIG_P));
- requestHttpHeaders.put(HttpUtil.HTTP_HEADER_USER_AGENT, config
- .getProperty(Configurator.USERAGENT_CONFIG_P));
- } else {
- requestHttpHeaders
- .put(HttpUtil.HTTP_HEADER_USER_AGENT, Configurator.USERAGENT_DEFAULT);
-
- }
- requestHttpHeaders.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE,
- HttpUtil.APPLICATION_URL_ENCODED);
-
- formParams = new HashMap();
- }
-
- @Override
- public DataUrlConnectionSPI newInstance() {
- DataUrlConnectionSPI uc = new LegacyDataUrlConnectionImpl();
- uc.setConfiguration(config);
- uc.setSSLSocketFactory(sslSocketFactory);
- uc.setHostnameVerifier(hostnameVerifier);
- return uc;
- }
-
- @Override
- public URL getUrl() {
- return url;
- }
-
- @Override
- public void setConfiguration(Properties config) {
- this.config = config;
- }
-
- @Override
- public void setSSLSocketFactory(SSLSocketFactory socketFactory) {
- this.sslSocketFactory = socketFactory;
- }
-
- @Override
- public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
- this.hostnameVerifier = hostnameVerifier;
- }
-}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/XWWWFormUrlInputDecoder.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/XWWWFormUrlInputDecoder.java
index f4ebe288..69c659e1 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/XWWWFormUrlInputDecoder.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/XWWWFormUrlInputDecoder.java
@@ -16,86 +16,43 @@
*/
package at.gv.egiz.bku.binding;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URLDecoder;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.fileupload.ParameterParser;
-import org.apache.commons.fileupload.ParameterParser;
-
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.bku.utils.StreamUtil;
-
-/**
- * Implementation based on Java's URLDecoder class
- *
- */
-// FIXME replace this code by a streaming variant
public class XWWWFormUrlInputDecoder implements InputDecoder {
-
- public final static String CHAR_SET = "charset";
- public final static String NAME_VAL_SEP = "=";
- public final static String SEP = "\\&";
-
- private String contentType;
- private InputStream dataStream;
- private String charset = "UTF-8";
-
- protected List decodeInput(InputStream is) throws IOException {
- List result = new LinkedList();
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- StreamUtil.copyStream(is, bos);
- String inputString = new String(bos.toByteArray());
- String[] nameValuePairs = inputString.split(SEP);
- //inputString = URLDecoder.decode(inputString, charset);
- for (int i = 0; i < nameValuePairs.length; i++) {
- String[] fields = nameValuePairs[i].split(NAME_VAL_SEP, 2);
- if (fields.length != 2) {
- throw new SLRuntimeException("Invalid form encoding, missing value");
- }
- String name = URLDecoder.decode(fields[0], charset);
- String value =URLDecoder.decode(fields[1], charset);
- ByteArrayInputStream bais = new ByteArrayInputStream(value
- .getBytes(charset));
- FormParameterImpl fpi = new FormParameterImpl(contentType, name, bais, null);
- result.add(fpi);
- }
- return result;
- }
-
- @SuppressWarnings("unchecked")
+
+ /**
+ * The MIME type 'application/x-www-form-urlencoded'.
+ */
+ public static final String CONTENT_TYPE = "application/x-www-form-urlencoded";
+
+ /**
+ * The form parameter iterator.
+ */
+ protected XWWWFormUrlInputIterator iterator;
+
+ @SuppressWarnings("unchecked")
@Override
public void setContentType(String contentType) {
ParameterParser pp = new ParameterParser();
pp.setLowerCaseNames(true);
Map params = pp.parse(contentType, new char[] { ':', ';' });
- if (!params.containsKey("application/x-www-form-urlencoded")) {
+ if (!params.containsKey(CONTENT_TYPE)) {
throw new IllegalArgumentException(
"not a url encoded content type specification: " + contentType);
}
- String cs = params.get(CHAR_SET);
- if (cs != null) {
- charset = cs;
- }
- this.contentType = contentType;
}
@Override
public Iterator getFormParameterIterator() {
- try {
- return decodeInput(dataStream).iterator();
- } catch (IOException e) {
- throw new SLRuntimeException(e);
- }
+ return iterator;
}
@Override
public void setInputStream(InputStream is) {
- dataStream = is;
+ iterator = new XWWWFormUrlInputIterator(is);
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/XWWWFormUrlInputIterator.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/XWWWFormUrlInputIterator.java
new file mode 100644
index 00000000..f052ce05
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/XWWWFormUrlInputIterator.java
@@ -0,0 +1,376 @@
+package at.gv.egiz.bku.binding;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+public class XWWWFormUrlInputIterator implements Iterator {
+
+ public static final byte NAME_VALUE_SEP = '=';
+
+ public static final byte PARAM_SEP = '&';
+
+ public static final Charset UTF_8 = Charset.forName("UTF-8");
+
+ /**
+ * The default buffer size.
+ */
+ protected static final int DEFAULT_BUFFER_SIZE = 4096;
+
+ /**
+ * Are we done with parsing the input.
+ */
+ protected boolean done = false;
+
+ /**
+ * The x-www-formdata-urlencoded input stream to be parsed.
+ */
+ protected final InputStream in;
+
+ /**
+ * The buffer size.
+ */
+ protected int bufferSize = DEFAULT_BUFFER_SIZE;
+
+ /**
+ * The read buffer.
+ */
+ protected final byte[] buf = new byte[bufferSize];
+
+ /**
+ * The read position.
+ */
+ protected int pos;
+
+ /**
+ * The number of valid bytes in the buffer;
+ */
+ protected int count;
+
+ /**
+ * The parameter returned by the last call of {@link #next()};
+ */
+ protected XWWWFormUrlEncodedParameter currentParameter;
+
+ /**
+ * An IOException that cannot be reported immediately.
+ */
+ protected IOException deferredIOException;
+
+ /**
+ * Creates a new instance of this x-www-formdata-urlencoded input iterator
+ * with the given InputStream in to be parsed.
+ *
+ * @param in the InputStream to be parsed
+ */
+ public XWWWFormUrlInputIterator(InputStream in) {
+ this.in = in;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#hasNext()
+ */
+ @Override
+ public boolean hasNext() {
+ if (done) {
+ return false;
+ }
+ if (currentParameter != null) {
+ // we have to disconnect the current parameter
+ // to look for further parameters
+ try {
+ currentParameter.formParameterValue.disconnect();
+ // fill buffer if empty
+ if (pos >= count) {
+ if ((count = in.read(buf)) == -1) {
+ // done
+ done = true;
+ return false;
+ }
+ pos = 0;
+ }
+ } catch (IOException e) {
+ deferredIOException = e;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public FormParameter next() {
+ if (hasNext()) {
+ // skip separator
+ pos++;
+ currentParameter = new XWWWFormUrlEncodedParameter();
+ return currentParameter;
+ } else {
+ throw new NoSuchElementException();
+ }
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ public class XWWWFormUrlEncodedParameter implements FormParameter {
+
+ /**
+ * The list of header names.
+ */
+ // x-www-form-urlencoded parameters do not provide headers
+ protected final List headers = Collections.emptyList();
+
+ /**
+ * The name of the form parameter.
+ */
+ protected String formParameterName;
+
+ /**
+ * The value of the form parameter.
+ */
+ protected URLDecodingInputStream formParameterValue;
+
+ public XWWWFormUrlEncodedParameter() {
+ // parse parameter name
+ URLDecodingInputStream urldec = new URLDecodingInputStream(in, NAME_VALUE_SEP);
+ InputStreamReader reader = new InputStreamReader(urldec, UTF_8);
+ try {
+ StringBuilder sb = new StringBuilder();
+ char[] b = new char[128];
+ for (int l = 0; (l = reader.read(b)) != -1;) {
+ sb.append(b, 0, l);
+ }
+ formParameterName = sb.toString();
+ // fill buffer if empty
+ if (pos >= count) {
+ if ((count = in.read(buf)) == -1) {
+ throw new IOException("Invalid URL encoding.");
+ }
+ pos = 0;
+ }
+ // skip separator
+ pos++;
+ } catch (IOException e) {
+ deferredIOException = e;
+ formParameterName = "";
+ }
+ formParameterValue = new URLDecodingInputStream(in, PARAM_SEP);
+ }
+
+ @Override
+ public String getFormParameterContentType() {
+ // x-www-form-urlencoded parameters do not specify a content type
+ return null;
+ }
+
+ @Override
+ public String getFormParameterName() {
+ return formParameterName;
+ }
+
+ @Override
+ public InputStream getFormParameterValue() {
+ if (deferredIOException != null) {
+ final IOException e = deferredIOException;
+ deferredIOException = null;
+ return new InputStream() {
+ @Override
+ public int read() throws IOException {
+ throw e;
+ }
+ };
+ } else {
+ return formParameterValue;
+ }
+ }
+
+ @Override
+ public Iterator getHeaderNames() {
+ return headers.iterator();
+ }
+
+ @Override
+ public String getHeaderValue(String headerName) {
+ return null;
+ }
+
+ }
+
+ public class URLDecodingInputStream extends FilterInputStream {
+
+ /**
+ * Has this stream already been closed.
+ */
+ private boolean closed = false;
+
+ /**
+ * Has this stream been disconnected.
+ */
+ private boolean disconnected = false;
+
+ /**
+ * Read until this byte occurs.
+ */
+ protected final byte term;
+
+ /**
+ * Creates a new instance of this URLDecodingInputStream.
+ *
+ * @param in
+ * @param separator
+ */
+ protected URLDecodingInputStream(InputStream in, byte separator) {
+ super(in);
+ this.term = separator;
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.FilterInputStream#read()
+ */
+ @Override
+ public int read() throws IOException {
+ if (closed) {
+ throw new IOException("The stream has already been closed.");
+ }
+ if (disconnected) {
+ return in.read();
+ }
+
+ if (pos >= count) {
+ if ((count = in.read(buf)) == -1) {
+ return -1;
+ }
+ pos = 0;
+ } if (buf[pos] == term) {
+ return -1;
+ } else if (buf[pos] == '+') {
+ pos++;
+ return ' ';
+ } else if (buf[pos] == '%') {
+ if (++pos == count) {
+ if ((count = in.read(buf)) == -1) {
+ throw new IOException("Invalid URL encoding.");
+ }
+ pos = 0;
+ }
+ int c1 = Character.digit(buf[pos], 16);
+ if (++pos == count) {
+ if ((count = in.read(buf)) == -1) {
+ throw new IOException("Invalid URL encoding.");
+ }
+ pos = 0;
+ }
+ int c2 = Character.digit(buf[pos], 16);
+ return ((c1 << 4) | c2);
+ } else {
+ return buf[pos++];
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.FilterInputStream#read(byte[], int, int)
+ */
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ if (closed) {
+ throw new IOException("The stream has already been closed.");
+ }
+ if (disconnected) {
+ return in.read(b, off, len);
+ }
+
+ if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
+ throw new IndexOutOfBoundsException();
+ } else if (len == 0) {
+ return 0;
+ }
+
+ if (pos >= count) {
+ if ((count = in.read(buf)) == -1) {
+ return -1;
+ }
+ pos = 0;
+ }
+ if (buf[pos] == term) {
+ return -1;
+ }
+
+ int l = 0;
+ for (;;) {
+ while (pos < count) {
+ if (l == len || buf[pos] == term) {
+ return l;
+ } else if (buf[pos] == '+') {
+ b[off] = ' ';
+ } else if (buf[pos] == '%') {
+ if (++pos == count && (count = in.read(buf)) == -1) {
+ throw new IOException("Invalid URL encoding.");
+ }
+ int c1 = Character.digit(buf[pos], 16);
+ if (++pos == count && (count = in.read(buf)) == -1) {
+ throw new IOException("Invalid URL encoding.");
+ }
+ int c2 = Character.digit(buf[pos], 16);
+ b[off] = (byte) ((c1 << 4) | c2);
+ } else {
+ b[off] = buf[pos];
+ }
+ pos++;
+ off++;
+ l++;
+ }
+ if ((count = in.read(buf)) == -1) {
+ return l;
+ }
+ pos = 0;
+ }
+ }
+
+ /**
+ * Disconnect from the InputStream and buffer all remaining data.
+ *
+ * @throws IOException
+ */
+ public void disconnect() throws IOException {
+ if (!disconnected) {
+ // don't waste space for a buffer if end of stream has already been
+ // reached
+ byte[] b = new byte[1];
+ if ((read(b)) != -1) {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ os.write(b);
+ b = new byte[1024];
+ for (int l; (l = read(b, 0, b.length)) != -1;) {
+ os.write(b, 0, l);
+ }
+ super.in = new ByteArrayInputStream(os.toByteArray());
+ }
+ disconnected = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.FilterInputStream#close()
+ */
+ @Override
+ public void close() throws IOException {
+ if (!hasNext()) {
+ // don't close the underlying stream until all parts are read
+ super.close();
+ }
+ disconnect();
+ closed = true;
+ }
+
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/SLResultPart.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/SLResultPart.java
index 5585f02e..d896ea9f 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/SLResultPart.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/multipart/SLResultPart.java
@@ -16,37 +16,56 @@
*/
package at.gv.egiz.bku.binding.multipart;
+import at.gv.egiz.bku.binding.DataUrlConnection;
import at.gv.egiz.bku.slcommands.SLResult;
+import at.gv.egiz.bku.slcommands.SLResult.SLResultType;
+
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import javax.xml.transform.stream.StreamResult;
-import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.methods.multipart.PartSource;
-/**
- *
- * @author clemens
- */
public class SLResultPart extends FilePart {
protected SLResult slResult;
protected String encoding;
public SLResultPart(SLResult slResult, String encoding) {
- super("XMLResponse",
- new ByteArrayPartSource(null, "dummySource".getBytes()));
+ super((slResult.getResultType() == SLResultType.XML)
+ ? DataUrlConnection.FORMPARAM_XMLRESPONSE
+ : DataUrlConnection.FORMPARAM_BINARYRESPONSE,
+ new PartSource() {
+
+ @Override
+ public long getLength() {
+ // may return null, as sendData() is overridden
+ return 0;
+ }
+
+ @Override
+ public String getFileName() {
+ // return null, to prevent content-disposition header
+ return null;
+ }
+
+ @Override
+ public InputStream createInputStream() throws IOException {
+ // may return null, as sendData() is overridden below
+ return null;
+ }
+ }
+ );
this.slResult = slResult;
this.encoding = encoding;
}
@Override
protected void sendData(OutputStream out) throws IOException {
- slResult.writeTo(new StreamResult(new OutputStreamWriter(out, encoding)));
- // slResult.writeTo(new StreamResult(new OutputStreamWriter(System.out,
- // encoding)));
- // super.sendData(out);
+ slResult.writeTo(new StreamResult(new OutputStreamWriter(out, encoding)), false);
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/CertValidatorImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/CertValidatorImpl.java
index 125233c1..3b2d1b99 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/conf/CertValidatorImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/CertValidatorImpl.java
@@ -1,7 +1,9 @@
package at.gv.egiz.bku.conf;
+import iaik.logging.LogConfigurationException;
import iaik.logging.TransactionId;
import iaik.logging.impl.TransactionIdImpl;
+import iaik.logging.LoggerConfig;
import iaik.pki.DefaultPKIConfiguration;
import iaik.pki.DefaultPKIProfile;
import iaik.pki.PKIConfiguration;
@@ -18,6 +20,7 @@ import iaik.x509.X509Certificate;
import java.io.File;
import java.util.Date;
+import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -37,6 +40,27 @@ public class CertValidatorImpl implements CertValidator {
* @see at.gv.egiz.bku.conf.CertValidator#init(java.io.File, java.io.File)
*/
public void init(File certDir, File caDir) {
+ // initialize IAIK logging for PKI module
+ log.debug("Configuring logging for IAIK PKI module");
+ iaik.logging.LogFactory.configure(new LoggerConfig() {
+
+ @Override
+ public Properties getProperties() throws LogConfigurationException {
+ return null;
+ }
+
+ @Override
+ public String getNodeId() {
+ return "pki";
+ }
+
+ @Override
+ public String getFactory() {
+ return IAIKCommonsLogFactory.class.getName();
+ }
+ });
+
+
// the parameters specifying the directory certstore
CertStoreParameters[] certStoreParameters = { new DefaultDirectoryCertStoreParameters(
"CS-001", certDir.getAbsolutePath(), true, false) };
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/IAIKCommonsLog.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/IAIKCommonsLog.java
new file mode 100644
index 00000000..1b7dd189
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/IAIKCommonsLog.java
@@ -0,0 +1,144 @@
+/**
+ *
+ */
+package at.gv.egiz.bku.conf;
+
+import iaik.logging.Log;
+import iaik.logging.TransactionId;
+
+/**
+ * @author mcentner
+ *
+ */
+public class IAIKCommonsLog implements Log {
+
+ /**
+ * The id that will be written to the log if the transactionid == null
+ */
+ public final static String NO_ID = "Null-ID";
+
+ protected org.apache.commons.logging.Log commonsLog;
+
+ protected String nodeId;
+
+ public IAIKCommonsLog(org.apache.commons.logging.Log log) {
+ this.commonsLog = log;
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.Log#debug(iaik.logging.TransactionId, java.lang.Object, java.lang.Throwable)
+ */
+ @Override
+ public void debug(TransactionId transactionId, Object message, Throwable t) {
+ if (commonsLog.isDebugEnabled()) {
+ commonsLog.debug(nodeId + ": "
+ + ((transactionId != null) ? transactionId.getLogID() : NO_ID) + ": "
+ + message, t);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.Log#info(iaik.logging.TransactionId, java.lang.Object, java.lang.Throwable)
+ */
+ @Override
+ public void info(TransactionId transactionId, Object message, Throwable t) {
+ if (commonsLog.isInfoEnabled()) {
+ commonsLog.info(nodeId + ": "
+ + ((transactionId != null) ? transactionId.getLogID() : NO_ID) + ": "
+ + message, t);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.Log#warn(iaik.logging.TransactionId, java.lang.Object, java.lang.Throwable)
+ */
+ @Override
+ public void warn(TransactionId transactionId, Object message, Throwable t) {
+ if (commonsLog.isWarnEnabled()) {
+ commonsLog.warn(nodeId + ": "
+ + ((transactionId != null) ? transactionId.getLogID() : NO_ID) + ": "
+ + message, t);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.Log#error(iaik.logging.TransactionId, java.lang.Object, java.lang.Throwable)
+ */
+ @Override
+ public void error(TransactionId transactionId, Object message, Throwable t) {
+ if (commonsLog.isErrorEnabled()) {
+ commonsLog.error(nodeId + ": "
+ + ((transactionId != null) ? transactionId.getLogID() : NO_ID) + ": "
+ + message, t);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.Log#fatal(iaik.logging.TransactionId, java.lang.Object, java.lang.Throwable)
+ */
+ @Override
+ public void fatal(TransactionId transactionId, Object message, Throwable t) {
+ if (commonsLog.isFatalEnabled()) {
+ commonsLog.fatal(nodeId + ": "
+ + ((transactionId != null) ? transactionId.getLogID() : NO_ID) + ": "
+ + message, t);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.Log#setNodeId(java.lang.String)
+ */
+ @Override
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.Log#getNodeId()
+ */
+ @Override
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.Log#isDebugEnabled()
+ */
+ @Override
+ public boolean isDebugEnabled() {
+ return commonsLog.isDebugEnabled();
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.Log#isInfoEnabled()
+ */
+ @Override
+ public boolean isInfoEnabled() {
+ return commonsLog.isInfoEnabled();
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.Log#isWarnEnabled()
+ */
+ @Override
+ public boolean isWarnEnabled() {
+ return commonsLog.isWarnEnabled();
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.Log#isErrorEnabled()
+ */
+ @Override
+ public boolean isErrorEnabled() {
+ return commonsLog.isErrorEnabled();
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.Log#isFatalEnabled()
+ */
+ @Override
+ public boolean isFatalEnabled() {
+ return commonsLog.isFatalEnabled();
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/IAIKCommonsLogFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/IAIKCommonsLogFactory.java
new file mode 100644
index 00000000..14e2c757
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/IAIKCommonsLogFactory.java
@@ -0,0 +1,59 @@
+/**
+ *
+ */
+package at.gv.egiz.bku.conf;
+
+import org.apache.commons.logging.impl.WeakHashtable;
+
+import iaik.logging.Log;
+import iaik.logging.LogConfigurationException;
+import iaik.logging.LogFactory;
+
+/**
+ * @author mcentner
+ *
+ */
+public class IAIKCommonsLogFactory extends LogFactory {
+
+ protected WeakHashtable instances = new WeakHashtable();
+
+ /* (non-Javadoc)
+ * @see iaik.logging.LogFactory#getInstance(java.lang.String)
+ */
+ @Override
+ public Log getInstance(String name) throws LogConfigurationException {
+ org.apache.commons.logging.Log commonsLog = org.apache.commons.logging.LogFactory.getLog(name);
+ Log log = (Log) instances.get(commonsLog);
+ if (log == null) {
+ log = new IAIKCommonsLog(commonsLog);
+ log.setNodeId(node_id_);
+ instances.put(commonsLog, log);
+ }
+ return log;
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.LogFactory#getInstance(java.lang.Class)
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public Log getInstance(Class clazz) throws LogConfigurationException {
+ org.apache.commons.logging.Log commonsLog = org.apache.commons.logging.LogFactory.getLog(clazz);
+ Log log = (Log) instances.get(commonsLog);
+ if (log == null) {
+ log = new IAIKCommonsLog(commonsLog);
+ log.setNodeId(node_id_);
+ instances.put(commonsLog, log);
+ }
+ return log;
+ }
+
+ /* (non-Javadoc)
+ * @see iaik.logging.LogFactory#release()
+ */
+ @Override
+ public void release() {
+ instances.clear();
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java
index fe27bc54..8e3f6ece 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java
@@ -28,6 +28,7 @@ import javax.xml.bind.JAXBException;
import javax.xml.bind.UnmarshalException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.ValidationEvent;
+import javax.xml.bind.ValidationEventLocator;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
@@ -46,11 +47,11 @@ import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
import at.gv.egiz.bku.slexceptions.SLRequestException;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.slexceptions.SLVersionException;
import at.gv.egiz.bku.utils.DebugReader;
import at.gv.egiz.slbinding.RedirectEventFilter;
import at.gv.egiz.slbinding.RedirectUnmarshallerListener;
-import at.gv.egiz.validation.ValidationEventLogger;
-import javax.xml.bind.ValidationEventHandler;
+import at.gv.egiz.validation.ReportingValidationEventHandler;
public class SLCommandFactory {
@@ -60,7 +61,9 @@ public class SLCommandFactory {
public static final String[] SCHEMA_FILES = new String[]{
"at/gv/egiz/bku/slcommands/schema/xml.xsd",
"at/gv/egiz/bku/slcommands/schema/xmldsig-core-schema.xsd",
- "at/gv/egiz/bku/slcommands/schema/Core-1.2.xsd"
+ "at/gv/egiz/bku/slcommands/schema/Core-1.2.xsd",
+ "at/gv/egiz/bku/slcommands/schema/Core.20020225.xsd",
+ "at/gv/egiz/bku/slcommands/schema/Core.20020831.xsd"
};
/**
* Logging facility.
@@ -169,7 +172,10 @@ public class SLCommandFactory {
String slPkg = at.buergerkarte.namespaces.securitylayer._1.ObjectFactory.class.getPackage().getName();
String xmldsigPkg = org.w3._2000._09.xmldsig_.ObjectFactory.class.getPackage().getName();
String cardChannelPkg = at.buergerkarte.namespaces.cardchannel.ObjectFactory.class.getPackage().getName();
- setJaxbContext(JAXBContext.newInstance(slPkg + ":" + xmldsigPkg + ":" + cardChannelPkg));
+ String slPkgLegacy1_0 = at.buergerkarte.namespaces.securitylayer._20020225_.ObjectFactory.class.getPackage().getName();
+ String slPkgLegacy1_1 = at.buergerkarte.namespaces.securitylayer._20020831_.ObjectFactory.class.getPackage().getName();
+ setJaxbContext(JAXBContext.newInstance(slPkg + ":" + xmldsigPkg + ":" + cardChannelPkg
+ + ":" + slPkgLegacy1_0 + ":" + slPkgLegacy1_1));
} catch (JAXBException e) {
log.error("Failed to setup JAXBContext security layer request.", e);
throw new SLRuntimeException(e);
@@ -248,26 +254,9 @@ public class SLCommandFactory {
SLRequestException {
Object object;
+ ReportingValidationEventHandler validationEventHandler = new ReportingValidationEventHandler();
try {
-// ValidatorHandler validator = slSchema.newValidatorHandler();
-// validator.getContentHandler();
-//
-// SAXParserFactory spf = SAXParserFactory.newInstance();
-// spf.setNamespaceAware(true);
-// XMLReader saxReader = spf.newSAXParser().getXMLReader();
-// //TODO extend validator to implement redirectContentHandler (validate+redirect)
-// saxReader.setContentHandler(validator);
-// //TODO get a InputSource
-// SAXSource saxSource = new SAXSource(saxReader, source);
-//
-// Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
-// //turn off duplicate jaxb validation
-// unmarshaller.setSchema(null);
-// unmarshaller.setListener(listener);
-// unmarshaller.unmarshal(saxSource);
-
-
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLEventReader eventReader = inputFactory.createXMLEventReader(source);
RedirectEventFilter redirectEventFilter = new RedirectEventFilter();
@@ -279,7 +268,7 @@ public class SLCommandFactory {
unmarshaller.setSchema(slSchema);
}
log.trace("Before unmarshal().");
- unmarshaller.setEventHandler(new ValidationEventLogger());
+ unmarshaller.setEventHandler(validationEventHandler);
object = unmarshaller.unmarshal(filteredReader);
log.trace("After unmarshal().");
} catch (UnmarshalException e) {
@@ -288,6 +277,13 @@ public class SLCommandFactory {
} else {
log.info("Failed to unmarshall security layer request." + e.getMessage());
}
+ if (validationEventHandler.getErrorEvent() != null) {
+ // Validation Error
+ ValidationEvent errorEvent = validationEventHandler.getErrorEvent();
+ ValidationEventLocator locator = errorEvent.getLocator();
+ throw new SLRequestException(3002,
+ SLExceptionMessages.EC3002_INVALID, new Object[]{errorEvent.getMessage()});
+ }
Throwable cause = e.getCause();
if (cause instanceof SAXParseException) {
throw new SLRequestException(3000,
@@ -328,10 +324,11 @@ public class SLCommandFactory {
* if an unexpected error occurs configuring the unmarshaller, if
* unmarshalling fails with an unexpected error or if the
* corresponding SLCommand could not be instantiated
+ * @throws SLVersionException
*/
@SuppressWarnings("unchecked")
public SLCommand createSLCommand(Source source, SLCommandContext context)
- throws SLCommandException, SLRuntimeException, SLRequestException {
+ throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
DebugReader dr = null;
if (log.isTraceEnabled() && source instanceof StreamSource) {
@@ -361,6 +358,12 @@ public class SLCommandFactory {
}
QName qName = ((JAXBElement) object).getName();
+ if (!SLCommand.NAMESPACE_URI.equals(qName.getNamespaceURI())) {
+ // security layer request version not supported
+ log.info("Unsupported security layer request version : " + qName.getNamespaceURI());
+ throw new SLVersionException(qName.getNamespaceURI());
+ }
+
Class extends SLCommand> implClass = getImplClass(qName);
if (implClass == null) {
// command not supported
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLMarshallerFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLMarshallerFactory.java
new file mode 100644
index 00000000..e0a375cf
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLMarshallerFactory.java
@@ -0,0 +1,172 @@
+/*
+* Copyright 2009 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.slcommands;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.marshal.MarshallerFactory;
+
+public class SLMarshallerFactory {
+
+ static Log log = LogFactory.getLog(SLMarshallerFactory.class);
+
+ /**
+ * The JAXBContext used for result marshaling.
+ *
+ * Note: Different contexts are used for marshaling and unmarshaling of
+ * security layer requests and responses to avoid propagation of namespace
+ * declarations of legacy namespaces into marshaled results.
+ *
+ * @see #jaxbContextLegacy
+ */
+ protected static JAXBContext context;
+
+ /**
+ * The JAXBContext used for marshaling of of results in the legacy namespace.
+ */
+ protected static JAXBContext legacyContext;
+
+ // ------------------- initialization on demand idiom -------------------
+ // see http://en.wikipedia.org/wiki/Initialization_on_demand_holder_idiom
+ // ----------------------------------------------------------------------
+
+ /**
+ * Private constructor called by {@link SLMarshallerFactoryInstanceHolder}.
+ */
+ private SLMarshallerFactory() {
+ // context is initialized immediately while the legacy context is initialized only on demand
+ try {
+ String slPkg = at.buergerkarte.namespaces.securitylayer._1.ObjectFactory.class.getPackage().getName();
+ String xmldsigPkg = org.w3._2000._09.xmldsig_.ObjectFactory.class.getPackage().getName();
+ String cardChannelPkg = at.buergerkarte.namespaces.cardchannel.ObjectFactory.class.getPackage().getName();
+ context = JAXBContext.newInstance(slPkg + ":" + xmldsigPkg + ":" + cardChannelPkg);
+ } catch (JAXBException e) {
+ log.error("Failed to setup JAXBContext security layer request.", e);
+ throw new SLRuntimeException(e);
+ }
+ }
+
+ /**
+ * The lazy instance holder for this SLMarshallerFactory.
+ */
+ private static class SLMarshallerFactoryInstanceHolder {
+ /**
+ * The instance returned by {@link SLMarshallerFactory#getInstance()}
+ */
+ private static final SLMarshallerFactory instance = new SLMarshallerFactory();
+ }
+
+ /**
+ * Get an instance of the SLMarshallerFactory.
+ */
+ public static SLMarshallerFactory getInstance() {
+ return SLMarshallerFactoryInstanceHolder.instance;
+ }
+
+ // ----------------------------------------------------------------------
+
+ /**
+ * Initialize the JAXBContext for the legacy namespace.
+ */
+ private static synchronized void ensureLegacyContext() {
+ // legacy marshaller is initialized only on demand
+ if (legacyContext == null) {
+ try {
+ String slPkgLegacy1_0 = at.buergerkarte.namespaces.securitylayer._20020225_.ObjectFactory.class.getPackage().getName();
+ String slPkgLegacy1_1 = at.buergerkarte.namespaces.securitylayer._20020831_.ObjectFactory.class.getPackage().getName();
+ String xmldsigPkg = org.w3._2000._09.xmldsig_.ObjectFactory.class.getPackage().getName();
+ String cardChannelPkg = at.buergerkarte.namespaces.cardchannel.ObjectFactory.class.getPackage().getName();
+ legacyContext = JAXBContext.newInstance(slPkgLegacy1_0 + ":" + slPkgLegacy1_1 + ":" + xmldsigPkg + ":" + cardChannelPkg);
+ } catch (JAXBException e) {
+ log.error("Failed to setup JAXBContext security layer request.", e);
+ throw new SLRuntimeException(e);
+ }
+ }
+ }
+
+ /**
+ * Creates an SL marshaller.
+ *
+ * @param formattedOutput
+ * true if the marshaller should produce formated
+ * output, false otherwise
+ * @return an SL marshaller
+ */
+ public Marshaller createMarshaller(boolean formattedOutput) {
+ return createMarshaller(formattedOutput, false);
+ }
+
+ /**
+ * Creates an SL marshaller.
+ *
+ * @param formattedOutput
+ * true if the marshaller should produce formated
+ * output, false otherwise
+ * @param fragment
+ * true if the marshaller should produce a XML fragment
+ * (omit XML declaration), false otherwise
+ * @return an SL marshaller
+ */
+ public Marshaller createMarshaller(boolean formattedOutput, boolean fragment) {
+ try {
+ return MarshallerFactory.createMarshaller(context, formattedOutput, fragment);
+ } catch (JAXBException e) {
+ log.fatal("Failed to marshall error response.", e);
+ throw new SLRuntimeException("Failed to marshall error response.", e);
+ }
+ }
+
+ /**
+ * Creates a legacy SL marshaller.
+ *
+ * @param formattedOutput
+ * true if the marshaller should produce formated
+ * output, false otherwise
+ * @return a legacy SL marshaller
+ */
+ public Marshaller createLegacyMarshaller(boolean formattedOutput) {
+ return createLegacyMarshaller(formattedOutput, false);
+ }
+
+ /**
+ * Creates a legacy SL marshaller.
+ *
+ * @param formattedOutput
+ * true if the marshaller should produce formated
+ * output, false otherwise
+ * @param fragment
+ * true if the marshaller should produce a XML fragment
+ * (omit XML declaration), false otherwise
+ * @return a legacy SL marshaller
+ */
+ public Marshaller createLegacyMarshaller(boolean formattedOutput, boolean fragment) {
+ try {
+ ensureLegacyContext();
+ return MarshallerFactory.createMarshaller(legacyContext, formattedOutput, fragment);
+ } catch (JAXBException e) {
+ log.fatal("Failed to marshall error response.", e);
+ throw new SLRuntimeException("Failed to marshall error response.", e);
+ }
+ }
+
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
index 7989a771..e9e483c5 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLResult.java
@@ -32,12 +32,14 @@ public interface SLResult {
*/
public String getMimeType();
- public void writeTo(Result aResult);
+ public void writeTo(Result aResult, boolean fragment);
/**
*
- * @param result
+ * @param result
+ * @param fragment TODO
* @param transformer may be null.
*/
- public void writeTo(Result result, Templates templates);
+ public void writeTo(Result result, Templates templates, boolean fragment);
+
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java
index ce03dcf9..9a4536e6 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java
@@ -16,7 +16,6 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import at.gv.egiz.marshal.NamespacePrefixMapperImpl;
import java.io.ByteArrayOutputStream;
import java.util.Arrays;
import java.util.Collections;
@@ -24,7 +23,6 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
@@ -42,10 +40,8 @@ import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayTy
import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadValue;
import at.gv.egiz.bku.slcommands.InfoboxReadResult;
import at.gv.egiz.bku.slcommands.SLCommandContext;
-import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slcommands.SLMarshallerFactory;
import at.gv.egiz.bku.slexceptions.SLCommandException;
-import at.gv.egiz.marshal.MarshallerFactory;
-import javax.xml.bind.PropertyException;
/**
* An abstract base class for {@link Infobox} implementations of type associative array.
@@ -255,13 +251,10 @@ public abstract class AbstractAssocArrayInfobox extends AbstractInfoboxImpl
}
protected byte[] marshallValue(Object jaxbElement) throws SLCommandException {
- SLCommandFactory commandFactory = SLCommandFactory.getInstance();
- JAXBContext jaxbContext = commandFactory.getJaxbContext();
- ByteArrayOutputStream result;
+ Marshaller marshaller = SLMarshallerFactory.getInstance().createMarshaller(false);
+ ByteArrayOutputStream result = new ByteArrayOutputStream();
try {
- Marshaller marshaller = MarshallerFactory.createMarshaller(jaxbContext);
- result = new ByteArrayOutputStream();
marshaller.marshal(jaxbElement, result);
} catch (JAXBException e) {
log.info("Failed to marshall infobox content.", e);
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
index b352a51e..19df4334 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java
@@ -16,8 +16,6 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import at.gv.egiz.marshal.NamespacePrefixMapperImpl;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
@@ -33,10 +31,8 @@ import org.w3c.dom.Node;
import at.buergerkarte.namespaces.securitylayer._1.CreateXMLSignatureResponseType;
import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
-import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slcommands.SLMarshallerFactory;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.marshal.MarshallerFactory;
-import javax.xml.bind.PropertyException;
/**
* This calls implements the result of the security layer command CreateXMLSignature.
@@ -86,10 +82,9 @@ public class CreateXMLSignatureResultImpl extends SLResultImpl {
JAXBElement createCreateXMLSignatureResponse = factory.createCreateXMLSignatureResponse(createCreateXMLSignatureResponseType);
DocumentFragment fragment = doc.createDocumentFragment();
-
- JAXBContext jaxbContext = SLCommandFactory.getInstance().getJaxbContext();
+
+ Marshaller marshaller = SLMarshallerFactory.getInstance().createMarshaller(false);
try {
- Marshaller marshaller = MarshallerFactory.createMarshaller(jaxbContext);
marshaller.marshal(createCreateXMLSignatureResponse, fragment);
} catch (JAXBException e) {
log.error("Failed to marshall 'CreateXMLSignatureResponse'", e);
@@ -105,8 +100,8 @@ public class CreateXMLSignatureResultImpl extends SLResultImpl {
}
@Override
- public void writeTo(Result result, Templates templates) {
- writeTo(doc, result, templates);
+ public void writeTo(Result result, Templates templates, boolean fragment) {
+ writeTo(doc, result, templates, fragment);
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
index 5d0f0de0..aedde238 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImpl.java
@@ -56,11 +56,11 @@ public class ErrorResultImpl extends SLResultImpl implements ErrorResult {
}
@Override
- public void writeTo(Result result, Templates templates) {
+ public void writeTo(Result result, Templates templates, boolean fragment) {
if (locale == null) {
- writeErrorTo(slException, result, templates);
+ writeErrorTo(slException, result, templates, fragment);
} else {
- writeErrorTo(slException, result, templates, locale);
+ writeErrorTo(slException, result, templates, locale, fragment);
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/GetStatusCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/GetStatusCommandImpl.java
index 46bfe18b..0c2b96f9 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/GetStatusCommandImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/GetStatusCommandImpl.java
@@ -19,10 +19,8 @@ package at.gv.egiz.bku.slcommands.impl;
import at.buergerkarte.namespaces.securitylayer._1.GetStatusRequestType;
import at.gv.egiz.bku.slcommands.GetStatusCommand;
-import at.gv.egiz.bku.slcommands.SLCommandContext;
import at.gv.egiz.bku.slcommands.SLResult;
import at.gv.egiz.bku.slexceptions.SLCommandException;
-import at.gv.egiz.bku.slexceptions.SLException;
import at.gv.egiz.stal.ErrorResponse;
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.STALResponse;
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/GetStatusResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/GetStatusResultImpl.java
index fddd3b0b..fb1f627f 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/GetStatusResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/GetStatusResultImpl.java
@@ -45,8 +45,8 @@ public class GetStatusResultImpl extends SLResultImpl implements GetStatusResult
}
@Override
- public void writeTo(Result result, Templates templates) {
+ public void writeTo(Result result, Templates templates, boolean fragment) {
JAXBElement response = of.createGetStatusResponse(responseType);
- writeTo(response, result, templates);
+ writeTo(response, result, templates, fragment);
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java
index 7a82e43f..160e9589 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java
@@ -18,7 +18,6 @@ package at.gv.egiz.bku.slcommands.impl;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.OutputStream;
import java.net.MalformedURLException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
index 75e44afa..422b424f 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
@@ -16,8 +16,6 @@
*/
package at.gv.egiz.bku.slcommands.impl;
-import at.gv.egiz.marshal.NamespacePrefixMapperImpl;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
@@ -39,10 +37,8 @@ import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
import at.buergerkarte.namespaces.securitylayer._1.XMLContentType;
import at.gv.egiz.bku.slcommands.InfoboxReadResult;
import at.gv.egiz.bku.slcommands.SLCommand;
-import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slcommands.SLMarshallerFactory;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.marshal.MarshallerFactory;
-import javax.xml.bind.PropertyException;
/**
* This class implements the result of the security layer command InfoboxReadRequest.
@@ -98,10 +94,9 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements
infoboxReadResponseType.setBinaryFileData(base64XMLContentType);
JAXBElement infoboxReadResponse = factory.createInfoboxReadResponse(infoboxReadResponseType);
-
- JAXBContext context = SLCommandFactory.getInstance().getJaxbContext();
+
+ Marshaller marshaller = SLMarshallerFactory.getInstance().createMarshaller(false);
try {
- Marshaller marshaller = MarshallerFactory.createMarshaller(context);
marshaller.marshal(infoboxReadResponse, doc);
} catch (JAXBException e) {
log.error("Failed to marshal 'InfoboxReadResponse' document.", e);
@@ -158,8 +153,8 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements
}
@Override
- public void writeTo(Result result, Templates templates) {
- writeTo(xmlDocument, result, templates);
+ public void writeTo(Result result, Templates templates, boolean fragment) {
+ writeTo(xmlDocument, result, templates, fragment);
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java
index e508941d..271ec955 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java
@@ -55,10 +55,10 @@ public class InfoboxReadResultImpl extends SLResultImpl implements InfoboxReadRe
}
@Override
- public void writeTo(Result result, Templates templates) {
+ public void writeTo(Result result, Templates templates, boolean fragment) {
ObjectFactory objectFactory = new ObjectFactory();
JAXBElement response = objectFactory.createInfoboxReadResponse(infoboxReadResponse);
- writeTo(response, result, templates);
+ writeTo(response, result, templates, fragment);
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateResultImpl.java
index 15064756..e12536ba 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateResultImpl.java
@@ -36,8 +36,8 @@ public class InfoboxUpdateResultImpl extends SLResultImpl implements
}
@Override
- public void writeTo(Result result, Templates templates) {
- writeTo(RESPONSE, result, templates);
+ public void writeTo(Result result, Templates templates, boolean fragment) {
+ writeTo(RESPONSE, result, templates, fragment);
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java
index 05986f85..87733e39 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImpl.java
@@ -41,8 +41,8 @@ public class NullOperationResultImpl extends SLResultImpl implements NullOperati
}
@Override
- public void writeTo(Result result, Templates templates) {
- writeTo(RESPONSE, result, templates);
+ public void writeTo(Result result, Templates templates, boolean fragment) {
+ super.writeTo(RESPONSE, result, templates, fragment);
}
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java
index 0452bddf..0077b7b2 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java
@@ -17,12 +17,14 @@
package at.gv.egiz.bku.slcommands.impl;
import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
import java.util.Locale;
-import javax.xml.bind.JAXBContext;
+import javax.xml.XMLConstants;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
+import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
@@ -41,17 +43,15 @@ import org.w3c.dom.Node;
import at.buergerkarte.namespaces.securitylayer._1.ErrorResponseType;
import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory;
-import at.gv.egiz.marshal.NamespacePrefixMapperImpl;
-import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slcommands.SLMarshallerFactory;
import at.gv.egiz.bku.slcommands.SLResult;
import at.gv.egiz.bku.slexceptions.SLBindingException;
import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLException;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.slexceptions.SLVersionException;
import at.gv.egiz.bku.utils.DebugOutputStream;
import at.gv.egiz.bku.utils.DebugWriter;
-import at.gv.egiz.marshal.MarshallerFactory;
-import javax.xml.bind.PropertyException;
/**
* This class serves as an abstract base class for the implementation of a
@@ -90,20 +90,18 @@ public abstract class SLResultImpl implements SLResult {
return resultingMimeType;
}
- private Marshaller getMarshaller() {
- try {
- JAXBContext context = SLCommandFactory.getInstance().getJaxbContext();
- Marshaller marshaller = MarshallerFactory.createMarshaller(context, true);
- return marshaller;
- } catch (JAXBException e) {
- log.fatal("Failed to marshall error response.", e);
- throw new SLRuntimeException("Failed to marshall error response.", e);
- }
+ @Override
+ public void writeTo(Result result, boolean fragment) {
+ writeTo(result, null, false);
}
+ @Override
+ public abstract void writeTo(Result result, Templates templates, boolean fragment);
+
private TransformerHandler getTransformerHandler(Templates templates, Result result) throws SLException {
try {
SAXTransformerFactory transformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
+ transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
TransformerHandler transformerHandler = transformerFactory.newTransformerHandler(templates);
transformerHandler.setResult(result);
return transformerHandler;
@@ -119,12 +117,6 @@ public abstract class SLResultImpl implements SLResult {
}
}
- @Override
- public void writeTo(Result result) {
- writeTo(result, null);
- }
-
-
/**
* Writes the given response to the SAX result using
* the given transform templates.
@@ -133,7 +125,7 @@ public abstract class SLResultImpl implements SLResult {
* @param result
* @param templates
*/
- protected void writeTo(JAXBElement> response, Result result, Templates templates) {
+ protected void writeTo(JAXBElement> response, Result result, Templates templates, boolean fragment) {
DebugWriter dw = null;
DebugOutputStream ds = null;
@@ -154,11 +146,11 @@ public abstract class SLResultImpl implements SLResult {
try {
transformerHandler = getTransformerHandler(templates, result);
} catch (SLException e) {
- writeErrorTo(e, result, templates);
+ writeErrorTo(e, result, templates, fragment);
}
}
- Marshaller marshaller = getMarshaller();
+ Marshaller marshaller = SLMarshallerFactory.getInstance().createMarshaller(true);
try {
if (transformerHandler != null) {
marshaller.marshal(response, transformerHandler);
@@ -168,7 +160,7 @@ public abstract class SLResultImpl implements SLResult {
} catch (JAXBException e) {
log.info("Failed to marshall " + response.getName() + " result." , e);
SLCommandException commandException = new SLCommandException(4000);
- writeErrorTo(commandException, result, templates);
+ writeErrorTo(commandException, result, templates, fragment);
}
if (ds != null) {
@@ -185,7 +177,7 @@ public abstract class SLResultImpl implements SLResult {
}
- protected void writeTo(Node node, Result result, Templates templates) {
+ protected void writeTo(Node node, Result result, Templates templates, boolean fragment) {
DebugWriter dw = null;
DebugOutputStream ds = null;
@@ -205,24 +197,30 @@ public abstract class SLResultImpl implements SLResult {
try {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
+ if (fragment) {
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ }
transformer.transform(new DOMSource(node), result);
} catch (TransformerConfigurationException e) {
log.error("Failed to create Transformer.", e);
- writeErrorTo(new SLException(4000), result, null);
+ writeErrorTo(new SLException(4000), result, null, fragment);
} catch (TransformerException e) {
log.error("Failed to transform result.", e);
- writeErrorTo(new SLException(4000), result, null);
+ writeErrorTo(new SLException(4000), result, null, fragment);
}
} else {
try {
Transformer transformer = templates.newTransformer();
+ if (fragment) {
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ }
transformer.transform(new DOMSource(node), result);
} catch (TransformerConfigurationException e) {
log.info("Failed to create transformer.", e);
- writeErrorTo(new SLException(2008), result, templates);
+ writeErrorTo(new SLException(2008), result, templates, fragment);
} catch (TransformerException e) {
log.error("Failed to transform result.", e);
- writeErrorTo(new SLException(2008), result, templates);
+ writeErrorTo(new SLException(2008), result, templates, fragment);
}
}
@@ -240,11 +238,11 @@ public abstract class SLResultImpl implements SLResult {
}
- protected void writeErrorTo(SLException slException, Result result, Templates templates) {
- writeErrorTo(slException, result, templates, Locale.getDefault());
+ protected void writeErrorTo(SLException slException, Result result, Templates templates, boolean fragment) {
+ writeErrorTo(slException, result, templates, Locale.getDefault(), fragment);
}
- protected void writeErrorTo(SLException slException, Result result, Templates templates, Locale locale) {
+ protected void writeErrorTo(SLException slException, Result result, Templates templates, Locale locale, boolean fragment) {
TransformerHandler transformerHandler = null;
if (templates != null) {
@@ -256,13 +254,33 @@ public abstract class SLResultImpl implements SLResult {
}
}
- ObjectFactory factory = new ObjectFactory();
- ErrorResponseType responseType = factory.createErrorResponseType();
- responseType.setErrorCode(slException.getErrorCode());
- responseType.setInfo(slException.getLocalizedMessage(locale));
- JAXBElement response = factory.createErrorResponse(responseType);
+ Object response;
+
+ Marshaller marshaller;
+ if (slException instanceof SLVersionException
+ && ("http://www.buergerkarte.at/namespaces/securitylayer/20020225#"
+ .equals(((SLVersionException) slException).getNamespaceURI()) ||
+ "http://www.buergerkarte.at/namespaces/securitylayer/20020831#"
+ .equals(((SLVersionException) slException).getNamespaceURI()))) {
+ // issue ErrorResponse in the legacy namespace
+ at.buergerkarte.namespaces.securitylayer._20020225_.ObjectFactory factory
+ = new at.buergerkarte.namespaces.securitylayer._20020225_.ObjectFactory();
+ at.buergerkarte.namespaces.securitylayer._20020225_.ErrorResponseType errorResponseType = factory
+ .createErrorResponseType();
+ errorResponseType.setErrorCode(BigInteger.valueOf(slException
+ .getErrorCode()));
+ errorResponseType.setInfo(slException.getLocalizedMessage(locale));
+ response = factory.createErrorResponse(errorResponseType);
+ marshaller = SLMarshallerFactory.getInstance().createLegacyMarshaller(true, fragment);
+ } else {
+ ObjectFactory factory = new ObjectFactory();
+ ErrorResponseType responseType = factory.createErrorResponseType();
+ responseType.setErrorCode(slException.getErrorCode());
+ responseType.setInfo(slException.getLocalizedMessage(locale));
+ response = factory.createErrorResponse(responseType);
+ marshaller = SLMarshallerFactory.getInstance().createMarshaller(true, fragment);
+ }
- Marshaller marshaller = getMarshaller();
try {
if (transformerHandler != null) {
marshaller.marshal(response, transformerHandler);
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/DataObject.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/DataObject.java
index b64306aa..2088a684 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/DataObject.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/DataObject.java
@@ -81,7 +81,6 @@ import at.gv.egiz.bku.viewer.ValidationException;
import at.gv.egiz.bku.viewer.Validator;
import at.gv.egiz.bku.viewer.ValidatorFactory;
import at.gv.egiz.dom.DOMUtils;
-import at.gv.egiz.marshal.NamespacePrefix;
import at.gv.egiz.marshal.NamespacePrefixMapperImpl;
import at.gv.egiz.slbinding.impl.XMLContentType;
import javax.xml.namespace.NamespaceContext;
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
index 9182e824..26ddb153 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
@@ -16,7 +16,6 @@
*/
package at.gv.egiz.bku.slcommands.impl.xsect;
-import at.gv.egiz.stal.HashDataInput;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -31,9 +30,7 @@ import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
@@ -87,8 +84,6 @@ import at.gv.egiz.bku.utils.urldereferencer.StreamData;
import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer;
import at.gv.egiz.bku.utils.urldereferencer.URLDereferencerContext;
import at.gv.egiz.dom.DOMUtils;
-import at.gv.egiz.marshal.NamespacePrefix;
-import at.gv.egiz.marshal.NamespacePrefixMapperImpl;
import at.gv.egiz.slbinding.impl.XMLContentType;
import at.gv.egiz.stal.STAL;
import at.gv.egiz.xades.QualifyingPropertiesException;
@@ -327,6 +322,8 @@ public class Signature {
*/
public void buildXMLSignature() throws SLCommandException {
+ String signatureId = ctx.getIdValueFactory().createIdValue("Signature");
+
List objects = new ArrayList();
List references = new ArrayList();
@@ -340,7 +337,7 @@ public class Signature {
}
}
- addXAdESObjectAndReference(objects, references);
+ addXAdESObjectAndReference(objects, references, signatureId);
XMLSignatureFactory signatureFactory = ctx.getSignatureFactory();
AlgorithmMethodFactory algorithmMethodFactory = ctx.getAlgorithmMethodFactory();
@@ -369,7 +366,6 @@ public class Signature {
ki = kif.newKeyInfo(Collections.singletonList(x509Data));
}
- String signatureId = ctx.getIdValueFactory().createIdValue("Signature");
String signatureValueId = ctx.getIdValueFactory().createIdValue("SignatureValue");
xmlSignature = signatureFactory.newXMLSignature(si, ki, objects, signatureId, signatureValueId);
@@ -588,7 +584,7 @@ public class Signature {
* @param references
* the list of ds:References to add the created
* ds:Reference to
- *
+ * @param signatureId TODO
* @throws SLCommandException
* if creating and adding the XAdES
* QualifyingProperties fails
@@ -596,7 +592,7 @@ public class Signature {
* if objects or references is
* null
*/
- private void addXAdESObjectAndReference(List objects, List references) throws SLCommandException {
+ private void addXAdESObjectAndReference(List objects, List references, String signatureId) throws SLCommandException {
QualifyingPropertiesFactory factory = QualifyingPropertiesFactory.getInstance();
@@ -630,9 +626,11 @@ public class Signature {
}
}
+ String target = "#" + signatureId;
+
JAXBElement qualifyingProperties;
try {
- qualifyingProperties = factory.createQualifyingProperties111(date, signingCertificates, idValue, dataObjectFormats);
+ qualifyingProperties = factory.createQualifyingProperties111(target, date, signingCertificates, idValue, dataObjectFormats);
} catch (QualifyingPropertiesException e) {
log.error("Failed to create QualifyingProperties.", e);
throw new SLCommandException(4000);
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLExceptionMessages.java b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLExceptionMessages.java
index 5ce5cba1..73ac8d1b 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLExceptionMessages.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLExceptionMessages.java
@@ -47,4 +47,10 @@ public final class SLExceptionMessages {
public static final String EC4011_NOTIMPLEMENTED = "ec4011.notimplemented";
+ //
+ // Legacy error codes
+ //
+
+ public static final String LEC2901_NOTIMPLEMENTED = "lec2901.notimplemented";
+
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLVersionException.java b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLVersionException.java
new file mode 100644
index 00000000..45501746
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slexceptions/SLVersionException.java
@@ -0,0 +1,28 @@
+package at.gv.egiz.bku.slexceptions;
+
+public class SLVersionException extends SLException {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String namespaceURI;
+
+ public SLVersionException(String namespaceURI) {
+ super(2901, SLExceptionMessages.LEC2901_NOTIMPLEMENTED, new Object[] {namespaceURI});
+ this.namespaceURI = namespaceURI;
+ }
+
+ public SLVersionException(int errorCode, String namespaceURI) {
+ super(errorCode);
+ this.namespaceURI = namespaceURI;
+ }
+
+ public SLVersionException(int errorCode, String namespaceURI, String message, Object[] arguments) {
+ super(errorCode, message, arguments);
+ this.namespaceURI = namespaceURI;
+ }
+
+ public String getNamespaceURI() {
+ return namespaceURI;
+ }
+
+}
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/Core.20020225.xsd b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/Core.20020225.xsd
new file mode 100644
index 00000000..76d1d7cb
--- /dev/null
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/Core.20020225.xsd
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/Core.20020831.xsd b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/Core.20020831.xsd
new file mode 100644
index 00000000..6759d791
--- /dev/null
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slcommands/schema/Core.20020831.xsd
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
index 73409c8b..db56184e 100644
--- a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages.properties
@@ -95,5 +95,10 @@ ec4000.infobox.invalid=Die Infobox '{0}' enth
ec4000.idlink.transfomation.failed=Die komprimierte Personenbindung konnte mit dem Stylesheet {0} nicht transformiert werden.
ec4002.infobox.unknown=Unbekannter Infoboxbezeichner {0}.
ec4003.not.resolved=Zu signierendes Datum kann nicht aufgelöst werden (URI={0}).
-ec4011.notimplemented=Befehl {0} ist nicht implementiert.
+ec4011.notimplemented=Befehl {0} ist nicht implementiert.
+
+# Legacy error messages
+#
+
+lec2901.notimplemented=Die in der Anfrage verwendete Version des Security-Layer Protokolls ({0}) wird nicht mehr unterstützt.
diff --git a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties
index 91ca20e8..6c67ba87 100644
--- a/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties
+++ b/bkucommon/src/main/resources/at/gv/egiz/bku/slexceptions/SLExceptionMessages_en.properties
@@ -96,3 +96,7 @@ ec4000.idlink.transfomation.failed=Failed to transform CompressedIdentityLink wi
ec4002.infobox.unknown=Unknown info box identifier {0}.
ec4003.not.resolved=Data to be signed cannot be resolved from URI={0}.
ec4011.notimplemented=Command {0} not implemented.
+
+# Legacy error codes
+#
+lec2901.notimplemented=The version ({0}) of the security-layer protocol used in the request is not supported.
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/XWWWFormUrlInputIteratorTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/XWWWFormUrlInputIteratorTest.java
new file mode 100644
index 00000000..703e4460
--- /dev/null
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/XWWWFormUrlInputIteratorTest.java
@@ -0,0 +1,152 @@
+package at.gv.egiz.bku.binding;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class XWWWFormUrlInputIteratorTest {
+
+ @Test
+ public void testOneParam() throws IOException {
+
+ final String name = "name";
+ final String value = "value";
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ OutputStreamWriter w = new OutputStreamWriter(os, Charset.forName("UTF-8"));
+ w.write(name);
+ w.write("=");
+ w.write(value);
+ w.flush();
+ w.close();
+
+ ByteArrayInputStream in = new ByteArrayInputStream(os.toByteArray());
+ XWWWFormUrlInputIterator decoder = new XWWWFormUrlInputIterator(in);
+
+ assertTrue(decoder.hasNext());
+ FormParameter param = decoder.next();
+ assertNotNull(param);
+ assertEquals(name, param.getFormParameterName());
+ InputStream vis = param.getFormParameterValue();
+ assertNotNull(vis);
+ InputStreamReader r = new InputStreamReader(vis);
+ char[] buf = new char[value.length() + 1];
+ int len = r.read(buf);
+ assertEquals(value.length(), len);
+ assertEquals(value, new String(buf, 0, len));
+ assertFalse(decoder.hasNext());
+ Exception ex = null;
+ try {
+ decoder.next();
+ } catch (Exception e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+
+ }
+
+ @Test
+ public void testTwoParam() throws IOException {
+
+ final String name1 = "name";
+ final String value1 = "value";
+ final String name2 = "Name_2";
+ final String value2 = "Value 2";
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ OutputStreamWriter w = new OutputStreamWriter(os, Charset.forName("UTF-8"));
+ w.write(name1);
+ w.write("=");
+ w.write(value1);
+ w.write("&");
+ w.write(URLEncoder.encode(name2, "UTF-8"));
+ w.write("=");
+ w.write(URLEncoder.encode(value2, "UTF-8"));
+ w.flush();
+ w.close();
+
+ ByteArrayInputStream in = new ByteArrayInputStream(os.toByteArray());
+ XWWWFormUrlInputIterator decoder = new XWWWFormUrlInputIterator(in);
+
+ assertTrue(decoder.hasNext());
+ FormParameter param = decoder.next();
+ assertNotNull(param);
+ assertEquals(name1, param.getFormParameterName());
+ InputStream vis = param.getFormParameterValue();
+ assertNotNull(vis);
+ InputStreamReader r = new InputStreamReader(vis);
+ char[] buf = new char[value1.length() + 1];
+ int len = r.read(buf);
+ assertEquals(value1.length(), len);
+ assertEquals(value1, new String(buf, 0, len));
+
+ assertTrue(decoder.hasNext());
+ param = decoder.next();
+ assertNotNull(param);
+ assertEquals(name2, param.getFormParameterName());
+ vis = param.getFormParameterValue();
+ assertNotNull(vis);
+ r = new InputStreamReader(vis);
+ buf = new char[value2.length() + 1];
+ len = r.read(buf);
+ assertEquals(value2.length(), len);
+ assertEquals(value2, new String(buf, 0, len));
+
+ assertFalse(decoder.hasNext());
+ }
+
+ @Test
+ public void testURLEnc() throws IOException {
+
+ String name = "name";
+ byte[] value = new byte[128];
+ for (int i = 0; i < value.length; i++) {
+ value[i] = (byte) i;
+ }
+
+ String encValue = URLEncoder.encode(new String(value, "UTF-8"), "ASCII");
+ System.out.println(encValue);
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ OutputStreamWriter w = new OutputStreamWriter(os, Charset.forName("UTF-8"));
+ w.write(name);
+ w.write("=");
+ w.write(encValue);
+ w.flush();
+ w.close();
+
+ ByteArrayInputStream in = new ByteArrayInputStream(os.toByteArray());
+ XWWWFormUrlInputIterator decoder = new XWWWFormUrlInputIterator(in);
+
+ assertTrue(decoder.hasNext());
+ FormParameter param = decoder.next();
+ assertNotNull(param);
+ assertEquals(name, param.getFormParameterName());
+ InputStream vis = param.getFormParameterValue();
+ assertNotNull(vis);
+ byte[] buf = new byte[value.length];
+ int len = vis.read(buf);
+ assertArrayEquals(value, buf);
+ assertEquals(value.length, len);
+ assertFalse(decoder.hasNext());
+ Exception ex = null;
+ try {
+ decoder.next();
+ } catch (Exception e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+
+ }
+
+
+}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/SLCommandFactoryTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/SLCommandFactoryTest.java
index cd931878..7a087b38 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/SLCommandFactoryTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/SLCommandFactoryTest.java
@@ -33,6 +33,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLRequestException;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.slexceptions.SLVersionException;
import at.gv.egiz.stal.dummy.DummySTAL;
public class SLCommandFactoryTest {
@@ -54,7 +55,7 @@ public class SLCommandFactoryTest {
}
@Test
- public void createNullOperationCommand() throws SLCommandException, SLRuntimeException, SLRequestException {
+ public void createNullOperationCommand() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
Reader requestReader = new StringReader(
"");
Source source = new StreamSource(requestReader);
@@ -65,7 +66,7 @@ public class SLCommandFactoryTest {
}
@Test(expected=SLCommandException.class)
- public void createUnsupportedCommand() throws SLCommandException, SLRuntimeException, SLRequestException {
+ public void createUnsupportedCommand() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
Reader requestReader = new StringReader(
"");
Source source = new StreamSource(requestReader);
@@ -75,7 +76,7 @@ public class SLCommandFactoryTest {
}
@Test(expected=SLRequestException.class)
- public void createMalformedCommand() throws SLCommandException, SLRuntimeException, SLRequestException {
+ public void createMalformedCommand() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
Reader requestReader = new StringReader(
"" +
"missplacedContent" +
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java
index 8fdec375..4e9b4cd7 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java
@@ -41,6 +41,7 @@ import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLRequestException;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.slexceptions.SLVersionException;
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.dummy.DummySTAL;
//@Ignore
@@ -66,7 +67,7 @@ public class CreateXMLSignatureComandImplTest {
}
@Test
- public void testCreateXMLSignatureRequest() throws SLCommandException, SLRuntimeException, SLRequestException {
+ public void testCreateXMLSignatureRequest() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/createxmlsignaturerequest/CreateXMLSignatureRequest.xml");
assertNotNull(inputStream);
@@ -76,11 +77,11 @@ public class CreateXMLSignatureComandImplTest {
assertTrue(command instanceof CreateXMLSignatureCommand);
SLResult result = command.execute();
- result.writeTo(new StreamResult(System.out));
+ result.writeTo(new StreamResult(System.out), false);
}
// @Test(expected=SLCommandException.class)
- public void testInfboxReadRequestInvalid1() throws SLCommandException, SLRuntimeException, SLRequestException {
+ public void testInfboxReadRequestInvalid1() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-1.xml");
assertNotNull(inputStream);
@@ -90,7 +91,7 @@ public class CreateXMLSignatureComandImplTest {
}
// @Test(expected=SLCommandException.class)
- public void testInfboxReadRequestInvalid2() throws SLCommandException, SLRuntimeException, SLRequestException {
+ public void testInfboxReadRequestInvalid2() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-2.xml");
assertNotNull(inputStream);
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImplTest.java
index f10ca520..aa2bcd62 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImplTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/ErrorResultImplTest.java
@@ -36,7 +36,7 @@ public class ErrorResultImplTest {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
StreamResult result = new StreamResult(stream);
- errorResult.writeTo(result);
+ errorResult.writeTo(result, false);
System.out.println(stream.toString());
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java
index b0d11d47..bfc784f7 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java
@@ -39,6 +39,7 @@ import at.gv.egiz.bku.slcommands.SLResult;
import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLRequestException;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.slexceptions.SLVersionException;
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.dummy.DummySTAL;
@@ -63,7 +64,7 @@ public class InfoboxReadComandImplTest {
}
@Test
- public void testInfboxReadRequest() throws SLCommandException, SLRuntimeException, SLRequestException {
+ public void testInfboxReadRequest() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.xml");
assertNotNull(inputStream);
@@ -73,11 +74,11 @@ public class InfoboxReadComandImplTest {
assertTrue(command instanceof InfoboxReadCommand);
SLResult result = command.execute();
- result.writeTo(new StreamResult(System.out));
+ result.writeTo(new StreamResult(System.out), false);
}
@Test(expected=SLCommandException.class)
- public void testInfboxReadRequestInvalid1() throws SLCommandException, SLRuntimeException, SLRequestException {
+ public void testInfboxReadRequestInvalid1() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-1.xml");
assertNotNull(inputStream);
@@ -87,7 +88,7 @@ public class InfoboxReadComandImplTest {
assertTrue(command instanceof InfoboxReadCommand);
}
- public void testInfboxReadRequestInvalid2() throws SLCommandException, SLRuntimeException, SLRequestException {
+ public void testInfboxReadRequestInvalid2() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-2.xml");
assertNotNull(inputStream);
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImplTest.java
index 8632b67c..e9b0775f 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImplTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/NullOperationResultImplTest.java
@@ -33,7 +33,7 @@ public class NullOperationResultImplTest {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
StreamResult result = new StreamResult(stream);
- nullOperationResult.writeTo(result);
+ nullOperationResult.writeTo(result, false);
System.out.println(stream.toString());
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java
index f9c60b86..a17f0797 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java
@@ -23,7 +23,6 @@ import iaik.asn1.CodingException;
import java.io.IOException;
import java.io.InputStream;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
@@ -42,10 +41,12 @@ import at.gv.egiz.bku.slcommands.InfoboxReadCommand;
import at.gv.egiz.bku.slcommands.SLCommand;
import at.gv.egiz.bku.slcommands.SLCommandContext;
import at.gv.egiz.bku.slcommands.SLCommandFactory;
+import at.gv.egiz.bku.slcommands.SLMarshallerFactory;
import at.gv.egiz.bku.slcommands.SLResult;
import at.gv.egiz.bku.slexceptions.SLCommandException;
import at.gv.egiz.bku.slexceptions.SLRequestException;
import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.slexceptions.SLVersionException;
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.dummy.DummySTAL;
@@ -93,9 +94,7 @@ public class SVPersonendatenInfoboxImplTest {
JAXBElement ehic = new ObjectFactory().createEHIC(attributeList);
- JAXBContext jaxbContext = SLCommandFactory.getInstance().getJaxbContext();
-
- Marshaller marshaller = jaxbContext.createMarshaller();
+ Marshaller marshaller = SLMarshallerFactory.getInstance().createMarshaller(false);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
@@ -105,7 +104,7 @@ public class SVPersonendatenInfoboxImplTest {
@Ignore
@Test
- public void testInfboxReadRequest() throws SLCommandException, SLRuntimeException, SLRequestException {
+ public void testInfboxReadRequest() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.xml");
assertNotNull(inputStream);
@@ -115,12 +114,12 @@ public class SVPersonendatenInfoboxImplTest {
assertTrue(command instanceof InfoboxReadCommand);
SLResult result = command.execute();
- result.writeTo(new StreamResult(System.out));
+ result.writeTo(new StreamResult(System.out), false);
}
@Ignore
@Test(expected=SLCommandException.class)
- public void testInfboxReadRequestInvalid1() throws SLCommandException, SLRuntimeException, SLRequestException {
+ public void testInfboxReadRequestInvalid1() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-1.xml");
assertNotNull(inputStream);
@@ -131,7 +130,7 @@ public class SVPersonendatenInfoboxImplTest {
}
@Ignore
- public void testInfboxReadRequestInvalid2() throws SLCommandException, SLRuntimeException, SLRequestException {
+ public void testInfboxReadRequestInvalid2() throws SLCommandException, SLRuntimeException, SLRequestException, SLVersionException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-2.xml");
assertNotNull(inputStream);
diff --git a/utils/src/main/java/at/buergerkarte/namespaces/securitylayer/_1/TransformsInfoType.java b/utils/src/main/java/at/buergerkarte/namespaces/securitylayer/_1/TransformsInfoType.java
index 5ee40b95..e4a8f48e 100644
--- a/utils/src/main/java/at/buergerkarte/namespaces/securitylayer/_1/TransformsInfoType.java
+++ b/utils/src/main/java/at/buergerkarte/namespaces/securitylayer/_1/TransformsInfoType.java
@@ -24,11 +24,15 @@
package at.buergerkarte.namespaces.securitylayer._1;
+import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlType;
import org.w3._2000._09.xmldsig_.TransformsType;
+import org.w3c.dom.Element;
/**
@@ -58,8 +62,9 @@ import org.w3._2000._09.xmldsig_.TransformsType;
})
public class TransformsInfoType {
- @XmlElement(name = "Transforms", namespace = "http://www.w3.org/2000/09/xmldsig#")
- protected TransformsType transforms;
+ @XmlElementRef(name = "Transforms", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class)
+ @XmlAnyElement(lax = true)
+ protected Object transforms;
@XmlElement(name = "FinalDataMetaInfo", required = true)
protected MetaInfoType finalDataMetaInfo;
@@ -68,10 +73,12 @@ public class TransformsInfoType {
*
* @return
* possible object is
- * {@link TransformsType }
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link Object }
+ * {@link Element }
*
*/
- public TransformsType getTransforms() {
+ public Object getTransforms() {
return transforms;
}
@@ -80,10 +87,12 @@ public class TransformsInfoType {
*
* @param value
* allowed object is
- * {@link TransformsType }
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link Object }
+ * {@link Element }
*
*/
- public void setTransforms(TransformsType value) {
+ public void setTransforms(Object value) {
this.transforms = value;
}
diff --git a/utils/src/main/java/at/buergerkarte/namespaces/securitylayer/_20020225_/ErrorResponseType.java b/utils/src/main/java/at/buergerkarte/namespaces/securitylayer/_20020225_/ErrorResponseType.java
new file mode 100644
index 00000000..69b5cd9d
--- /dev/null
+++ b/utils/src/main/java/at/buergerkarte/namespaces/securitylayer/_20020225_/ErrorResponseType.java
@@ -0,0 +1,98 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs
+// See http://java.sun.com/xml/jaxb
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2009.09.07 at 09:47:31 AM CEST
+//
+
+
+package at.buergerkarte.namespaces.securitylayer._20020225_;
+
+import java.math.BigInteger;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ *
Java class for ErrorResponseType complex type.
+ *
+ *
The following schema fragment specifies the expected content contained within this class.
+ *
+ *
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ErrorResponseType", propOrder = {
+ "errorCode",
+ "info"
+})
+public class ErrorResponseType {
+
+ @XmlElement(name = "ErrorCode", required = true)
+ protected BigInteger errorCode;
+ @XmlElement(name = "Info", required = true)
+ protected String info;
+
+ /**
+ * Gets the value of the errorCode property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getErrorCode() {
+ return errorCode;
+ }
+
+ /**
+ * Sets the value of the errorCode property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setErrorCode(BigInteger value) {
+ this.errorCode = value;
+ }
+
+ /**
+ * Gets the value of the info property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getInfo() {
+ return info;
+ }
+
+ /**
+ * Sets the value of the info property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setInfo(String value) {
+ this.info = value;
+ }
+
+}
diff --git a/utils/src/main/java/at/buergerkarte/namespaces/securitylayer/_20020225_/ObjectFactory.java b/utils/src/main/java/at/buergerkarte/namespaces/securitylayer/_20020225_/ObjectFactory.java
new file mode 100644
index 00000000..a02f9ca1
--- /dev/null
+++ b/utils/src/main/java/at/buergerkarte/namespaces/securitylayer/_20020225_/ObjectFactory.java
@@ -0,0 +1,280 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs
+// See http://java.sun.com/xml/jaxb
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2009.09.07 at 09:47:31 AM CEST
+//
+
+
+package at.buergerkarte.namespaces.securitylayer._20020225_;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the at.buergerkarte.namespaces.securitylayer._20020225_ package.
+ *
An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _CreateXMLSignatureRequest_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "CreateXMLSignatureRequest");
+ private final static QName _InfoboxUpdateRequest_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "InfoboxUpdateRequest");
+ private final static QName _ErrorResponse_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "ErrorResponse");
+ private final static QName _VerifyXMLSignatureResponse_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "VerifyXMLSignatureResponse");
+ private final static QName _CreateSessionKeyResponse_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "CreateSessionKeyResponse");
+ private final static QName _GetPropertiesRequest_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "GetPropertiesRequest");
+ private final static QName _GetPropertiesResponse_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "GetPropertiesResponse");
+ private final static QName _InfoboxAvailableResponse_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "InfoboxAvailableResponse");
+ private final static QName _InfoboxAvailableRequest_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "InfoboxAvailableRequest");
+ private final static QName _CreateSessionKeyRequest_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "CreateSessionKeyRequest");
+ private final static QName _InfoboxUpdateResponse_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "InfoboxUpdateResponse");
+ private final static QName _CreateXMLSignatureResponse_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "CreateXMLSignatureResponse");
+ private final static QName _GetStatusResponse_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "GetStatusResponse");
+ private final static QName _CreateCMSSignatureRequest_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "CreateCMSSignatureRequest");
+ private final static QName _CreateSymmetricSecretRequest_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "CreateSymmetricSecretRequest");
+ private final static QName _VerifyXMLSignatureRequest_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "VerifyXMLSignatureRequest");
+ private final static QName _CreateSymmetricSecretResponse_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "CreateSymmetricSecretResponse");
+ private final static QName _CreateCMSSignatureResponse_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "CreateCMSSignatureResponse");
+ private final static QName _VerifyCMSSignatureResponse_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "VerifyCMSSignatureResponse");
+ private final static QName _InfoboxReadResponse_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "InfoboxReadResponse");
+ private final static QName _VerifyCMSSignatureRequest_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "VerifyCMSSignatureRequest");
+ private final static QName _InfoboxReadRequest_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "InfoboxReadRequest");
+ private final static QName _GetStatusRequest_QNAME = new QName("http://www.buergerkarte.at/namespaces/securitylayer/20020225#", "GetStatusRequest");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: at.buergerkarte.namespaces.securitylayer._20020225_
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link ErrorResponseType }
+ *
+ */
+ public ErrorResponseType createErrorResponseType() {
+ return new ErrorResponseType();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.buergerkarte.at/namespaces/securitylayer/20020225#", name = "CreateXMLSignatureRequest")
+ public JAXBElement