summaryrefslogtreecommitdiff
path: root/BKUOnline/src
diff options
context:
space:
mode:
Diffstat (limited to 'BKUOnline/src')
-rw-r--r--BKUOnline/src/main/custom-binding/stalservice-custom.xml102
-rw-r--r--BKUOnline/src/main/custom-binding/staltypes-custom.xml70
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java69
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java91
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java120
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SessionTimeout.java49
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java31
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java38
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java43
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java554
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java220
-rw-r--r--BKUOnline/src/main/resources/commons-logging.properties16
-rw-r--r--BKUOnline/src/main/resources/log4j.properties34
-rw-r--r--BKUOnline/src/main/webapp/HTTP-ohne.html85
-rw-r--r--BKUOnline/src/main/webapp/META-INF/MANIFEST.MF3
-rw-r--r--BKUOnline/src/main/webapp/META-INF/context.xml18
-rw-r--r--BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml43
-rw-r--r--BKUOnline/src/main/webapp/WEB-INF/sun-jaxws.xml36
-rw-r--r--BKUOnline/src/main/webapp/WEB-INF/web.xml97
-rw-r--r--BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.wsdl82
-rw-r--r--BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd135
-rw-r--r--BKUOnline/src/main/webapp/appletPage.jsp65
-rw-r--r--BKUOnline/src/main/webapp/expired.html28
-rw-r--r--BKUOnline/src/main/webapp/index.html59
-rw-r--r--BKUOnline/src/main/webapp/js/deployJava.js886
-rw-r--r--BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java362
26 files changed, 3336 insertions, 0 deletions
diff --git a/BKUOnline/src/main/custom-binding/stalservice-custom.xml b/BKUOnline/src/main/custom-binding/stalservice-custom.xml
new file mode 100644
index 00000000..384b04f7
--- /dev/null
+++ b/BKUOnline/src/main/custom-binding/stalservice-custom.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!--
+ Binding customization for STAL service (stal.wsdl)
+ JAX-WS does not yet support "schema component designator"s (SCD, http://www.w3.org/TR/xmlschema-ref/)
+-->
+<bindings xmlns="http://java.sun.com/xml/ns/jaxws"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ wsdlLocation="../webapp/WEB-INF/wsdl/stal.wsdl">
+
+
+ <!-- default settings
+ <enableWrapperStyle>true</enableWrapperStyle>
+ <enableAsyncMapping>false</enableAsyncMapping-->
+ <package name="at.gv.egiz.stal.service" />
+
+ <!-- wsdl:portType customization -->
+ <bindings node="wsdl:definitions/wsdl:portType[@name='STALPortType']">
+ <!-- change generated SEI class -->
+ <!--class name="STALServiceI" /-->
+
+ <!-- override default settings -->
+ <enableWrapperStyle>true</enableWrapperStyle>
+ <enableAsyncMapping>false</enableAsyncMapping>
+ </bindings>
+
+ <!-- wsdl:portType operation customization -->
+ <bindings node="wsdl:definitions/wsdl:portType[@name='STALPortType']/wsdl:operation[@name='nextRequest']">
+ <!-- rename method name -->
+ <method name="getNextRequest">
+ <javadoc>Fetch the next request.</javadoc>
+ </method>
+
+ <!-- rename method params -->
+ <parameter part="wsdl:definitions/wsdl:message[@name='NextRequestRequest']/wsdl:part[@name='part1']" name="request" />
+
+ <!-- override default settings -->
+ <enableWrapperStyle>true</enableWrapperStyle>
+ <enableAsyncMapping>false</enableAsyncMapping>
+ </bindings>
+
+ <bindings node="wsdl:definitions/wsdl:portType[@name='STALPortType']/wsdl:operation[@name='getHashDataInput']">
+ <!-- rename method name -->
+ <method name="getHashDataInput">
+ <javadoc>Fetch the signed references corresponding to the previous SignatureRequest.</javadoc>
+ </method>
+
+ <!-- rename method params -->
+ <parameter part="wsdl:definitions/wsdl:message[@name='GetHashDataInputRequest']/wsdl:part[@name='part1']" name="request" />
+
+ <!-- override default settings -->
+ <enableWrapperStyle>true</enableWrapperStyle>
+ <enableAsyncMapping>false</enableAsyncMapping>
+ </bindings>
+
+ <!-- wsdl:service customization -->
+ <!--bindings node="wsdl:definitions/wsdl:service[@name='STALService']">
+ <class name="STALService"/>
+ </bindings-->
+
+ <!-- change the port accessor method -->
+ <!-- bindings node="wsdl:definitions/wsdl:service[@name='STALService']/wsdl:port[@name='STALPort']">
+ <method name="getSTALServicePort"/>
+ </bindings -->
+
+ <!-- INLINED SCHEMA CUSTOMIZATION
+ <bindings node="wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='http://danu.iaik.tugraz.at/xml']">
+ <jaxb:schemaBindings>
+ <jaxb:package name="iaik.ws.sample.sandbox.generated.service.jaxb" />
+ </jaxb:schemaBindings>
+ </bindings-->
+
+ <!-- EXTERNAL SCHEMA CUSTOMIZATION in custom-jaxb.xml -->
+
+ <!--bindings node="wsdl:definitions" xmlns:jws="http://java.sun.com/xml/ns/javaee">
+ <jws:handler-chains>
+ <jws:handler-chain>
+ <jws:handler>
+ <jws:handler-class>fromwsdlhandler.common.LoggingHandler</jws:handler-class>
+ </jws:handler>
+ </jws:handler-chain>
+ </jws:handler-chains>
+ </bindings-->
+
+</bindings> \ No newline at end of file
diff --git a/BKUOnline/src/main/custom-binding/staltypes-custom.xml b/BKUOnline/src/main/custom-binding/staltypes-custom.xml
new file mode 100644
index 00000000..2ea42082
--- /dev/null
+++ b/BKUOnline/src/main/custom-binding/staltypes-custom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!--
+ Binding customization for STAL schema (stal.xsd)
+ Use JAXB version 2.1 which supports "schema component designator" (SCD, http://www.w3.org/TR/xmlschema-ref/)
+
+ All request/response types are generated to at.gv.egiz.stal
+ and renamed (...Type suffix removed),
+ except for the base types of the modified implClasses ErrorResponse and SignRequest
+
+ IMPORTANT: WHEN REGENERATING CLASSES MAKE SURE TO BACKUP MODIFIED IMPLCLASSES (ErrorResponse and SignRequest)
+-->
+<bindings xmlns='http://java.sun.com/xml/ns/jaxb' version='2.1'
+ xmlns:xs='http://www.w3.org/2001/XMLSchema'
+ xmlns:stal="http://www.egiz.gv.at/stal"
+ xmlns:xjc='http://java.sun.com/xml/ns/jaxb/xjc'
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xsi:schemaLocation='http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd
+ http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd'>
+ <bindings scd="x-schema::stal" xmlns:stal="http://www.egiz.gv.at/stal">
+ <schemaBindings>
+ <!-- generate all classes to at.gv.egiz.stal, then move service-only classes to at.gv.egiz.stal.service -->
+ <package name="at.gv.egiz.stal"/>
+ </schemaBindings>
+ </bindings>
+ <bindings scd="/type::stal:RequestType">
+ <class name="STALRequest"/>
+ </bindings>
+ <bindings scd="/type::stal:ResponseType">
+ <class name="STALResponse"/>
+ </bindings>
+ <bindings scd="/type::stal:InfoboxReadResponseType">
+ <class name="InfoboxReadResponse"/>
+ </bindings>
+ <bindings scd="/type::stal:SignResponseType">
+ <class name="SignResponse"/>
+ </bindings>
+ <bindings scd="/type::stal:ErrorResponseType">
+ <class name="ErrorResponse"/>
+ <!--class implClass="at.gv.egiz.stal.types.ErrorResponse"/-->
+ </bindings>
+ <bindings scd="/type::stal:InfoboxReadRequestType" >
+ <class name="InfoboxReadRequest"/>
+ </bindings>
+ <bindings scd="/type::stal:SignRequestType" >
+ <class name="SignRequest"/>
+ <!--class implClass="at.gv.egiz.stal.types.SignRequest"/-->
+ </bindings>
+ <bindings scd="/type::stal:QuitRequestType" >
+ <class name="QuitRequest"/>
+ </bindings>
+ <!--bindings scd="/type::stal:GetHashDataInputFaultType" >
+ <class name="GetHashDataInputFault"/>
+ </bindings-->
+</bindings>
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
new file mode 100644
index 00000000..0cb717c4
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
@@ -0,0 +1,69 @@
+/*
+* 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.conf;
+
+import iaik.security.ecc.provider.ECCProvider;
+import iaik.xml.crypto.XSecProvider;
+
+import java.net.HttpURLConnection;
+import java.security.Provider;
+import java.security.Security;
+
+import javax.net.ssl.HttpsURLConnection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
+
+/**
+ *
+ * TODO currently only the code to get started.
+ */
+public class Configurator {
+ private Log log = LogFactory.getLog(Configurator.class);
+
+ public Configurator() {
+ configure();
+ }
+
+ protected void configUrlConnections() {
+ HttpsURLConnection.setFollowRedirects(false);
+ HttpURLConnection.setFollowRedirects(false);
+ }
+
+ protected void configureProviders() {
+ log.debug("Registering security providers");
+ Security.addProvider(new STALProvider());
+ XSecProvider.addAsProvider(false);
+ Security.insertProviderAt(new ECCProvider(false), 1);
+ StringBuffer sb = new StringBuffer();
+ sb.append("Following providers are now registered: ");
+ int i = 1;
+ for (Provider prov : Security.getProviders()) {
+ sb.append((i++) + ". : " + prov);
+ }
+ log.debug("Configured provider" + sb.toString());
+ }
+
+ public void configure() {
+ configureProviders();
+ configUrlConnections();
+
+ }
+
+}
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
new file mode 100644
index 00000000..53a7c164
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
@@ -0,0 +1,91 @@
+/*
+* 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.util.Enumeration;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+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.org.apache.tomcat.util.http.AcceptLanguage;
+
+/**
+ * Handles SL requests and instantiates BindingProcessors
+ *
+ */
+public class BKURequestHandler extends SpringBKUServlet {
+
+ public final static String REDIRECT_URL ="appletPage.jsp";
+
+ protected Log log = LogFactory.getLog(BKURequestHandler.class);
+
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+ log.debug("Got new request");
+ String lang = req.getHeader("Accept-Language");
+ Locale locale = AcceptLanguage.getLocale(lang);
+ log.debug("Using locale: "+locale);
+ HttpSession session = req.getSession();
+ if (session != null) {
+ session.invalidate();
+ }
+ String id = req.getSession(true).getId();
+ log.debug("Using session id: "+id);
+ HTTPBindingProcessor bindingProcessor;
+ if (req.isSecure()) {
+ bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
+ .createBindingProcessor("https", id, locale);
+ } else {
+ bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
+ .createBindingProcessor("http", id, locale);
+ }
+ Map<String, String> headerMap = new HashMap<String, String>();
+ for (Enumeration<String> headerName = req.getHeaderNames(); headerName
+ .hasMoreElements();) {
+ String header = headerName.nextElement();
+ if (header != null) {
+ headerMap.put(header, req.getHeader(header));
+ }
+ }
+ String charset = req.getCharacterEncoding();
+ String contentType = req.getContentType();
+ if (charset != null) {
+ contentType += ";"+charset;
+ }
+ headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, contentType);
+ bindingProcessor.setHTTPHeaders(headerMap);
+ bindingProcessor.consumeRequestStream(req.getInputStream());
+ req.getInputStream().close();
+ getBindingProcessorManager().process(bindingProcessor);
+ resp.sendRedirect(REDIRECT_URL);
+ }
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+ doPost(req, resp);
+ }
+}
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
new file mode 100644
index 00000000..6c1a4c3a
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
@@ -0,0 +1,120 @@
+/*
+* 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<String> 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();
+ }
+}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SessionTimeout.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SessionTimeout.java
new file mode 100644
index 00000000..2b56166c
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SessionTimeout.java
@@ -0,0 +1,49 @@
+/*
+* 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 javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.binding.BindingProcessorManager;
+import at.gv.egiz.bku.binding.IdFactory;
+
+/**
+ * Session listener to trigger the removal of the BindingProcessor
+ *
+ */
+public class SessionTimeout implements HttpSessionListener {
+
+ private static Log log = LogFactory.getLog(SessionTimeout.class);
+
+ @Override
+ public void sessionCreated(HttpSessionEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void sessionDestroyed(HttpSessionEvent event) {
+ BindingProcessorManager manager = (BindingProcessorManager) event.getSession().getServletContext().getAttribute(SpringBKUServlet.BEAN_NAME);
+ log.info("Removing session: "+event.getSession().getId());
+ manager.removeBindingProcessor(IdFactory.getInstance().createId(event.getSession().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
new file mode 100644
index 00000000..6ee537b1
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/SpringBKUServlet.java
@@ -0,0 +1,31 @@
+/*
+* 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 javax.servlet.http.HttpServlet;
+
+import at.gv.egiz.bku.binding.BindingProcessorManager;
+
+public abstract class SpringBKUServlet extends HttpServlet {
+
+ public final static String BEAN_NAME="bindingProcessorManager";
+
+ protected BindingProcessorManager getBindingProcessorManager() {
+ return (BindingProcessorManager) getServletContext().getAttribute(BEAN_NAME);
+ }
+
+}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
new file mode 100644
index 00000000..38c568ab
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
@@ -0,0 +1,38 @@
+/*
+* 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.
+*/
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.stal.service.impl;
+
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.STALFactory;
+
+/**
+ *
+ * @author clemens
+ */
+public class RequestBrokerSTALFactory implements STALFactory {
+
+ @Override
+ public STAL createSTAL() {
+ return new STALRequestBrokerImpl();
+ }
+
+}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java
new file mode 100644
index 00000000..aad9b874
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java
@@ -0,0 +1,43 @@
+/*
+* 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.
+*/
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package at.gv.egiz.stal.service.impl;
+
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.HashDataInputCallback;
+import java.util.List;
+import java.util.concurrent.TimeoutException;
+
+/**
+ *
+ * @author clemens
+ */
+public interface STALRequestBroker extends STAL {
+
+ public static final int ERR_6000 = 6000;
+ public static final long TIMEOUT_MS = 1000*60*5; //300000;
+
+ public List<STALRequest> nextRequest(List<STALResponse> response);
+// public void setResponse(List<STALResponse> response) throws TimeoutException;
+// public void interruptRequestHandling(ErrorResponseType error);
+ public HashDataInputCallback getHashDataInput();
+}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
new file mode 100644
index 00000000..19548247
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
@@ -0,0 +1,554 @@
+/*
+* 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.
+*/
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package at.gv.egiz.stal.service.impl;
+
+import at.gv.egiz.stal.ErrorResponse;
+import at.gv.egiz.stal.QuitRequest;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.HashDataInputCallback;
+import at.gv.egiz.stal.SignRequest;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * An instance of STALRequestBroker is shared between a producer threads (SLCommand)
+ * and multiple consumer threads (STALService).
+ * This implementation assures that handleRequest is executed only once the previous invocation returned.
+ * The BindingProcessor assures that a new SLCommand calls handleRequest() only once
+ * the bindingProcessor called handleRequest(QUIT) after the previous SLCommand's handleRequest() returned.
+ *
+ * Multiple STALService threads might call nextRequest()/getSignedReferences() in any order.
+ *
+ * @author clemens
+ */
+public class STALRequestBrokerImpl implements STALRequestBroker {
+
+ private static final Log log = LogFactory.getLog(STALRequestBrokerImpl.class);
+// protected RequestResponseBroker broker;
+ protected List<STALRequest> requests = null;
+ protected List<STALResponse> responses = null;
+ protected HashDataInputCallback currentHashDataInputCallback;
+ private boolean isHandlingRequest = false;
+ private boolean expectingResponse = false;
+// private Object handleRequestCondition = new Object();
+// private Object gotResponsesCondition = new Object();
+// public STALRequestBrokerImpl() {
+// broker = new RequestResponseBroker();
+// new Thread(handler).start();
+// }
+
+// @Override
+// public HashDataInputCallback getCurrentHashDataInputCallback() {
+// return broker.getCurrentHashDataInputCallback();
+// }
+ /**
+ * Produce requests (and HashDataInputCallback) and wait for responses.
+ * The next thread may enter once we consumed the responses.
+ *
+ * @param requests
+ * @return
+ *
+ * @pre requests either single SignRequest, QuitRequest or multiple ReadInfoboxRequests
+ */
+ @Override
+ public synchronized List<STALResponse> handleRequest(List<STALRequest> requests) {
+ while (isHandlingRequest) {
+ log.trace("waiting to produce request");
+ try {
+ long beforeWait = System.currentTimeMillis();
+ wait(TIMEOUT_MS);
+ if (System.currentTimeMillis() - beforeWait >= TIMEOUT_MS) {
+ log.warn("timeout while waiting to produce request");
+ return Collections.singletonList((STALResponse) new ErrorResponse(ERR_6000));
+ }
+ } catch (InterruptedException ex) {
+ log.warn("interrupt while waiting to produce request: " + ex.getMessage());
+ }
+ }
+ log.trace("produce request");
+ isHandlingRequest = true;
+
+ this.requests = requests;
+ currentHashDataInputCallback = null;
+ for (STALRequest request : requests) {
+ if (request instanceof SignRequest) {
+ log.trace("Received SignRequest, keep HashDataInput callback.");
+ currentHashDataInputCallback = ((SignRequest) request).getHashDataInput();
+ break;
+ } else if (request instanceof QuitRequest) {
+ //alternative1:
+ //for QUIT requests, do not wait for responses, but for request consumation
+ // (i.e. set isHandlingReq to false once QUIT is consumed)
+ log.trace("Received QuitRequest, do not wait for responses.");
+ log.trace("notifying request consumers");
+ notify();
+ //alternative2:
+ //wait for QUIT to be consumed
+ // (i.e. notify me noce QUIT is consumed)
+// while (this.requests != null) {
+// try {
+// long beforeWait = System.currentTimeMillis();
+// wait(TIMEOUT_MS);
+// if (System.currentTimeMillis() - beforeWait >= TIMEOUT_MS) {
+// log.warn("timeout while waiting for QUIT to be consumed");
+// this.requests = null;
+// isHandlingRequest = false;
+// return Collections.singletonList((STALResponse) new ErrorResponse(ERR_6000));
+// }
+// } catch (InterruptedException ex) {
+// log.warn("interrupt while waiting for QUIT to be consumed: " + ex.getMessage());
+// }
+// }
+// isHandlingRequest = false;
+ return new ArrayList<STALResponse>();
+ } else if (log.isTraceEnabled()) {
+ log.trace("Received STAL request: " + request.getClass().getName());
+ }
+ }
+ log.trace("notifying request consumers");
+ notify();
+
+ while (this.responses == null) {
+ log.trace("waiting to consume response");
+ try {
+ long beforeWait = System.currentTimeMillis();
+ wait(TIMEOUT_MS);
+ if (System.currentTimeMillis() - beforeWait >= TIMEOUT_MS) {
+ log.warn("timeout while waiting to consume response");
+ this.requests = null;
+ currentHashDataInputCallback = null;
+ isHandlingRequest = false;
+ return Collections.singletonList((STALResponse) new ErrorResponse(ERR_6000));
+ }
+ } catch (InterruptedException ex) {
+ log.warn("interrupt while waiting to consume response: " + ex.getMessage());
+ }
+ }
+ log.trace("consuming responses");
+ List<STALResponse> resps = responses;
+ responses = null;
+ log.trace("notifying response producers");
+ notify();
+
+ isHandlingRequest = false;
+ log.trace("notifying request producers");
+ notify();
+
+ return resps;
+ }
+
+ /**
+ *
+ * @param responses
+ * @return QUIT if expected responses are not provided
+ */
+ @Override
+ public synchronized List<STALRequest> nextRequest(List<STALResponse> responses) {
+ if (responses != null && responses.size() > 0) {
+ if (!expectingResponse) {
+ log.warn("Received unexpected response in nextRequest()");
+ return Collections.singletonList((STALRequest) new QuitRequest());
+ }
+ while (this.responses != null) {
+ log.trace("waiting to produce response");
+ try {
+ long beforeWait = System.currentTimeMillis();
+ wait(TIMEOUT_MS);
+ if (System.currentTimeMillis() - beforeWait >= TIMEOUT_MS) {
+ log.warn("timeout while waiting to produce response");
+ return Collections.singletonList((STALRequest) new QuitRequest());
+ }
+ } catch (InterruptedException ex) {
+ log.warn("interrupt while waiting to produce response: " + ex.getMessage());
+ }
+ }
+ log.trace("produce response");
+ this.responses = responses;
+ //reset HashDataInputCallback
+ if (log.isTraceEnabled()) {
+ for (STALResponse response : responses) {
+ log.trace("Received STAL response: " + response.getClass().getName());
+ }
+ }
+ log.trace("notifying response consumers");
+ notify();
+ } else {
+ if (expectingResponse) {
+ // while (expectingResponse) wait();
+ log.warn("No expected response received in nextRequest()");
+ return Collections.singletonList((STALRequest) new QuitRequest());
+ }
+ log.trace("expecting non-null response in next nextRequest(response)");
+ expectingResponse = true;
+ }
+ while (this.requests == null) {
+ log.trace("waiting to consume request");
+ try {
+ long beforeWait = System.currentTimeMillis();
+ wait(TIMEOUT_MS);
+ if (System.currentTimeMillis() - beforeWait >= TIMEOUT_MS) {
+ log.warn("timeout while waiting to consume request");
+ return Collections.singletonList((STALRequest) new QuitRequest());
+ }
+ } catch (InterruptedException ex) {
+ log.warn("interrupt while waiting to consume request: " + ex.getMessage());
+ }
+ }
+ log.trace("consume request");
+ List<STALRequest> reqs = requests;
+ //TODO check if QUIT and set isHandlingReq to false here?
+ // (rename isHandlingReq -> produce)
+ // handleReq(QUIT) doesn't wait() and returns immediately
+ // cf. handleReq(QUIT)
+ requests = null;
+ //no need to notify; request producer is waiting for isHandlingRequest
+ //(alt2: the QUIT producer returned immediately and didn't notify)
+ //(alt1: the QUIT producer is waiting for notification on QUIT consumption)
+ if (reqs.size() > 0 && reqs.get(0) instanceof QuitRequest) {
+ isHandlingRequest = false;
+ log.trace("consumed QUIT, notifying request producers");
+ notify();
+ log.trace("expecting no response in next nextRequest()");
+ expectingResponse = false;
+ //notify no-response request consumers
+ }
+ return reqs;
+ }
+
+ @Override
+ public synchronized HashDataInputCallback getHashDataInput() {
+ log.trace("return current HashDataInput callback");
+ return currentHashDataInputCallback;
+ }
+// /**
+// * Causes the calling thread to sleep until response is passed via nextRequest()
+// * (except for QUIT request, which returns immediately).
+// * The requestList may contain at most one signRequest.
+// * The signRequest's signedRefCallback is stored until a response to the signRequest is provided (2nd nextRequest() call),
+// * i.e. until handleRequest() returns.
+// *
+// * @param aRequestList
+// * @return
+// * @pre requestList contains at most one signRequest
+// */
+// @Override
+// public List<STALResponse> handleRequest(List<STALRequest> requestList) {
+// try {
+// if (log.isTraceEnabled()) {
+// log.trace("HandleRequest (" + requestList.size() + " requests)");
+// }
+//
+// broker.produceRequests(requestList);
+//
+// // QUIT returns immediately
+// if (requestList.size() == 1 && requestList.get(0) instanceof QuitRequest) {
+// log.trace("Received QUIT request, do not wait for responses.");
+// return new ArrayList<STALResponse>();
+// }
+// return broker.consumeResponses();
+// } catch (InterruptedException ex) {
+// log.error("Interrupted while handling STAL request list: " + ex.getMessage());
+// return Collections.singletonList((STALResponse) new ErrorResponse());
+// } catch (TimeoutException ex) {
+// log.error("Timeout during handle request: " + ex.getMessage());
+// ErrorResponse err = new ErrorResponse();
+// err.setErrorCode(ERR_6000);
+// return Collections.singletonList((STALResponse) err);
+// }
+// }
+//
+// @Override
+// public void setResponse(List<STALResponse> responses) {
+// try {
+//// if (responses != null && responses.size() > 0) {
+//// List<STALResponse> stalResponses = translateResponses(responses);
+// broker.produceResponses(responses);
+//// } else {
+//// log.trace("Received emtpy responses list, do not add.");
+//// }
+// } catch (InterruptedException ex) {
+// log.error("Interrupted while setting STAL response: " + ex.getMessage());
+//// broker.interrupt(new ErrorResponse());
+// } catch (TimeoutException ex) {
+// log.error("Timeout during setResponse: " + ex.getMessage());
+// }
+// }
+//
+// /**
+// * TODO split in nextRequest(void) and setResponses(responses)
+// * <br/>
+// * Translate (possibly empty) STAL-WS response list to STAL responses and
+// * wait until request(s) are available and translate to STAL-WS requests.
+// * @param prevResponse if null or zero-length, they are not passed to the handler
+// * @return
+// */
+// @Override
+// public List<STALRequest> nextRequest() { //List<ResponseType> responses) {
+// try {
+//// if (responses != null && responses.size() > 0) {
+//// List<STALResponse> stalResponses = translateResponses(responses);
+//// broker.produceResponses(stalResponses);
+//// } else {
+//// log.trace("Received emtpy responses list, do not add.");
+//// }
+//
+//// List<? extends STALRequest> stalRequests = broker.consumeRequests();
+//// List<RequestType> requests = translateRequests(stalRequests);
+// return broker.consumeRequests();
+//// } catch (InterruptedException ex) {
+//// log.error("Interrupted while requesting next STAL request: " + ex.getMessage());
+//// return Collections.singletonList((STALResponse) new ErrorResponse());
+// } catch (InterruptedException ex) {
+// log.error("Interrupted while requesting next STAL request: " + ex.getMessage());
+//// broker.interrupt(new ErrorResponse());
+// return new ArrayList<STALRequest>();
+// } catch (TimeoutException ex) {
+// log.error("Timeout during nextRequest: " + ex.getMessage());
+// return new ArrayList<STALRequest>();
+// }
+// }
+//
+//// @Override
+//// public void interruptRequestHandling(ErrorResponseType error) {
+//// if (log.isTraceEnabled()) {
+//// log.trace("Received Error: " + error.getErrorMessage());
+//// }
+//// broker.interrupt(new ErrorResponse(error.getErrorCode()));
+//// }
+//
+// //TODO
+//// private List<RequestType> translateRequests(List<? extends STALRequest> stalRequests) {
+//// List<RequestType> requests = new ArrayList<RequestType>(stalRequests.size());
+//// for (STALRequest stalRequest : stalRequests) {
+//// if (stalRequest instanceof InfoboxReadRequest) {
+//// InfoboxReadRequestType req = new InfoboxReadRequestType();
+//// req.setInfoboxIdentifier(((InfoboxReadRequest) stalRequest).getInfoboxIdentifier());
+//// log.warn("TODO consider domain identifier for infobox " + req.getInfoboxIdentifier());
+//// req.setDomainIdentifier("TODO");
+//// requests.add(req);
+//// } else if (stalRequest instanceof SignRequest) {
+//// //TODO
+//// //remember current sign request for getSignedReferences()
+//// throw new UnsupportedOperationException("SignRequest unsupported");
+//// } else if (stalRequest instanceof QuitRequest) {
+//// requests.add(new QuitRequestType());
+//// } else {
+//// log.error("Unknown STAL request: " + stalRequest.getClass().getName());
+//// }
+//// }
+//// return requests;
+//// }
+//
+//// private List<STALResponse> translateResponses(List<ResponseType> responses) {
+//// List<STALResponse> stalResponses = new ArrayList<STALResponse>(responses.size());
+//// for (ResponseType response : responses) {
+//// if (response instanceof InfoboxReadResponseType) {
+//// byte[] infoboxValue = ((InfoboxReadResponseType) response).getInfoboxValue();
+//// stalResponses.add(new InfoboxReadResponse(infoboxValue));
+//// } else if (response instanceof SignResponseType) {
+//// byte[] signatureValue = ((SignResponseType) response).getSignatureValue();
+//// stalResponses.add(new SignResponse(signatureValue));
+//// } else if (response instanceof ErrorResponseType) {
+//// int errorCode = ((ErrorResponseType) response).getErrorCode();
+//// log.warn("TODO consider error msg: " + ((ErrorResponseType) response).getErrorMessage());
+//// stalResponses.add(new ErrorResponse(errorCode));
+//// } else {
+//// log.error("Unknown STAL service response " + response.getId() + ": " + response.getClass().getName());
+//// }
+//// }
+//// return stalResponses;
+//// }
+// /**
+// * synchronize on this, not on request/response lists since they are nulled
+// */
+// // protected since outer handler field is protected
+// protected class RequestResponseBroker { //implements Runnable {
+//
+// protected List<STALRequest> requests = null;
+// protected List<STALResponse> responses = null;
+// protected HashDataInputCallback currentHashDataInputCallback;
+//
+//// @Override
+//// public void run() {
+//// while (true) {
+//// ;
+//// }
+//// //TODO handler lifecycle in run()?
+//// }
+// /**
+// * wait until requests are consumed,
+// * produce requests, remember sigRefCallback and notify consumer
+// * (no need for synchronized?)
+// * @param requests
+// */
+// public synchronized void produceRequests(List<STALRequest> requests) throws InterruptedException, TimeoutException {
+//// synchronized (requests) {
+//
+// // requests is null, since there's only one producer thread calling handleRequests()
+// // and handleRequest() returns only if nextRequest() was called
+// while (this.requests != null) {
+//// requests.wait();
+// long before = System.currentTimeMillis();
+// log.trace("waiting to produce requests ...");
+// wait(); //TIMEOUT_MS);
+// if (System.currentTimeMillis() - before >= TIMEOUT_MS) {
+// log.error("Timeout while waiting to produce requests.");
+// throw new TimeoutException();
+// }
+// }
+// log.trace("producing requests");
+// this.requests = requests;
+// // getSignedReferences does not produce responses,
+// // so the command thread will not continue (and no further signRequest can possibly be produced)
+// // once the ws-client sends nextRequest with responses to the signRequest, the callback is invalidated
+//
+// // reset callback if for some reason produceResponse() wasn't called
+// currentHashDataInputCallback = null;
+// for (STALRequest request : requests) {
+// if (request instanceof SignRequest) {
+// log.trace("keep hashdatainput callback");
+// currentHashDataInputCallback = ((SignRequest) request).getHashDataInput();
+// break;
+// }
+// }
+//
+//// requests.notify();
+// log.trace("notifying request consumers (TODO not only consumers)");
+// notify();
+//// }
+// }
+//
+// /**
+// * wait until requests are produced and consume them
+// * @return
+// */
+// public synchronized List<STALRequest> consumeRequests() throws InterruptedException, TimeoutException {
+// List<STALRequest> retVal = null;
+//// synchronized (requests) {
+// while (requests == null) {
+//// requests.wait();
+// long before = System.currentTimeMillis();
+// log.trace("waiting to consumer requests ...");
+// wait(); //TIMEOUT_MS);
+// if (System.currentTimeMillis() - before >= TIMEOUT_MS) {
+// log.error("Timeout while waiting to consume requests.");
+// throw new TimeoutException();
+// }
+// }
+// log.trace("consuming requests");
+// retVal = requests;
+// requests = null;
+//// }
+// log.trace("???notify request producers???");
+// return retVal;
+// }
+//
+// /**
+// * wait until previous responses are consumed,
+// * produce responses and notify consumer
+// * @param responses
+// */
+// public synchronized void produceResponses(List<STALResponse> responses) throws InterruptedException, TimeoutException {
+//// synchronized (responses) {
+// while (this.responses != null) {
+//// responses.wait();
+// long before = System.currentTimeMillis();
+// log.trace("waiting to produce responses ...");
+// wait(); //TIMEOUT_MS);
+// if (System.currentTimeMillis() - before >= TIMEOUT_MS) {
+// log.error("Timeout while waiting to produce responses.");
+// throw new TimeoutException();
+// }
+// }
+// log.trace("producing responses");
+// this.responses = responses;
+// //invalidate sigrefcallback (from now on handleRequest() may be called, producing new requests)
+// //make sure the provided responses are for the corresponding signrequest
+// if (this.requests == null) {//requests already consumed=>responses correspond to these
+// log.trace("resetting current hashdatainput");
+// currentHashDataInputCallback = null;
+// }
+//// responses.notify();
+// log.trace("notify response consumers (TODO only consumers?)");
+// notify();
+//// }
+// }
+//
+// /**
+// * wait until responses are available, consume them
+// * @return
+// * @throws java.lang.Exception
+// */
+// public synchronized List<STALResponse> consumeResponses() throws InterruptedException, TimeoutException {
+// List<STALResponse> retVal = null;
+//// synchronized (responses) {
+// while (responses == null) {
+//// responses.wait();
+// long before = System.currentTimeMillis();
+// log.trace("waiting to consume responses ...");
+// wait(); //TIMEOUT_MS);
+// if (System.currentTimeMillis() - before >= TIMEOUT_MS) {
+// log.error("Timeout while waiting to consume responses.");
+// throw new TimeoutException();
+// }
+// }
+// log.trace("consuming responses");
+// retVal = responses;
+// responses = null;
+//// }
+// log.trace("???notify response producers???");
+// return retVal;
+// }
+//
+// /**
+// * get the signrefcallback until handleRequest() is called the next time.
+// * @return null if last request was not a signRequest
+// */
+// public synchronized HashDataInputCallback getCurrentHashDataInputCallback() {
+// log.trace("obtain current hashdatainput");
+// return currentHashDataInputCallback;
+// }
+// /**
+// * add the error to responses and notify (response-) consumers
+// * @param error
+// */
+//// public synchronized void interrupt(ErrorResponse error) {
+////// synchronized (responses) {
+//// if (responses == null) {
+//// responses = Collections.singletonList((STALResponse) error);
+//// } else {
+//// responses.add(error);
+//// }
+////// responses.notify();
+//// notify();
+////// }
+//// }
+// }
+ @Override
+ public void setLocale(Locale locale) {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java
new file mode 100644
index 00000000..3e8ad6f3
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java
@@ -0,0 +1,220 @@
+/*
+* 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.
+*/
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package at.gv.egiz.stal.service.impl;
+
+import at.gv.egiz.bku.binding.BindingProcessor;
+import at.gv.egiz.bku.binding.BindingProcessorManager;
+import at.gv.egiz.stal.service.*;
+import at.gv.egiz.bku.binding.Id;
+import at.gv.egiz.bku.binding.IdFactory;
+import at.gv.egiz.stal.ErrorResponse;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.HashDataInputCallback;
+import at.gv.egiz.stal.InfoboxReadRequest;
+import at.gv.egiz.stal.QuitRequest;
+import at.gv.egiz.stal.SignRequest;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.servlet.ServletContext;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author clemens
+ */
+@WebService(endpointInterface = "at.gv.egiz.stal.service.STALPortType")
+public class STALServiceImpl implements STALPortType {
+
+ public static final String BINDING_PROCESSOR_MANAGER = "bindingProcessorManager";
+ public static final String TEST_SESSION_ID = "TestSession";
+ protected static final Log log = LogFactory.getLog(STALServiceImpl.class);
+ @Resource
+ WebServiceContext wsContext;
+ protected IdFactory idF = IdFactory.getInstance();
+
+ @Override
+ public GetNextRequestResponseType getNextRequest(GetNextRequestType request) {
+
+ // HttpSession session = ((HttpServletRequest)
+ // mCtx.get(MessageContext.SERVLET_REQUEST)).getSession();
+ String sessId = request.getSessionId();
+ List<STALResponse> responses = request.getResponse();
+ if (log.isDebugEnabled()) {
+ log.debug("Received GetNextRequest for session " + sessId
+ + " containing " + responses.size() + " responses");
+ }
+
+ GetNextRequestResponseType response = new GetNextRequestResponseType();
+ response.setSessionId(sessId);
+
+ if (TEST_SESSION_ID.equals(sessId)) {
+ if (responses.size() > 0 && responses.get(0) instanceof ErrorResponse) {
+ log
+ .info("Received TestSession GetNextRequest(ErrorResponse), returning QuitRequest");
+ response.getRequest().add(new QuitRequest());
+ } else {
+ log
+ .info("Received TestSession GetNextRequest, returning InfoboxReadRequest ");
+ SignRequest sig = new SignRequest();
+ sig.setKeyIdentifier("SecureSignatureKeypair");
+ sig.setSignedInfo("<dsig:SignedInfo xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\"><dsig:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /> <dsig:SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1\" /> <dsig:Reference Id=\"signed-data-reference-0-1214921968-27971781-24309\" URI=\"#signed-data-object-0-1214921968-27971781-13578\"><dsig:Transforms> <dsig:Transform Algorithm=\"http://www.w3.org/2002/06/xmldsig-filter2\"> <xpf:XPath xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\" Filter=\"intersect\">id('signed-data-object-0-1214921968-27971781-13578')/node()</xpf:XPath></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /> <dsig:DigestValue>H1IePEEfGQ2SG03H6LTzw1TpCuM=</dsig:DigestValue></dsig:Reference><dsig:Reference Id=\"etsi-data-reference-0-1214921968-27971781-25439\" Type=\"http://uri.etsi.org/01903/v1.1.1#SignedProperties\" URI=\"#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-data-object-0-1214921968-27971781-3095')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)\"><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><dsig:DigestValue>yV6Q+I60buqR4mMaxA7fi+CV35A=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo>".getBytes());
+ response.getRequest().add(sig);
+ InfoboxReadRequest req = new InfoboxReadRequest();
+ req.setInfoboxIdentifier("IdentityLink");
+ req.setDomainIdentifier("hansiwurzel");
+ response.getRequest().add(req);
+ req = new InfoboxReadRequest();
+ req.setInfoboxIdentifier("CertifiedKeypair");
+ response.getRequest().add(req);
+ req = new InfoboxReadRequest();
+ req.setInfoboxIdentifier("SecureSignatureKeypair");
+ response.getRequest().add(req);
+ }
+ return response;
+ }
+
+ // get Session Id
+ Id sessionId = idF.createId(sessId);
+ STALRequestBroker stal = getStal(sessionId);
+
+ if (stal == null) {
+ log.error("Failed to get STAL for session " + sessId
+ + ", returning QuitRequest");
+ response.getRequest().add(new QuitRequest());
+ } else {
+ List<STALResponse> responsesIn = request.getResponse();
+ for (STALResponse resp : responsesIn) {
+ log.debug(resp);
+ }
+ List<STALRequest> requestsOut = ((STALRequestBroker) stal)
+ .nextRequest(responsesIn);
+ response.getRequest().addAll(requestsOut);
+ if (log.isDebugEnabled()) {
+ log.debug("Returning GetNextRequestResponse for session " + sessId
+ + " containing " + requestsOut.size() + " requests");
+ }
+ }
+ return response;
+ }
+
+ @Override
+ public GetHashDataInputResponseType getHashDataInput(
+ GetHashDataInputType request) throws GetHashDataInputFault {
+
+ String sessId = request.getSessionId();
+ if (log.isDebugEnabled()) {
+ log.debug("Received GetHashDataInputRequest for session " + sessId
+ + " containing " + request.getReference().size() + " referencese");
+ }
+
+ // get Session Id
+ Id sessionId = idF.createId(sessId);
+ STALRequestBroker stal = getStal(sessionId);
+
+ if (stal == null) {
+ String msg = "Failed to get STAL for session " + sessId;
+ log.error(msg);
+ GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
+ faultInfo.setErrorCode(1);
+ faultInfo.setErrorMessage(msg);
+ throw new GetHashDataInputFault(msg, faultInfo);
+ } else {
+ GetHashDataInputResponseType response = new GetHashDataInputResponseType();
+ response.setSessionId(sessId);
+
+ HashDataInputCallback hashDataInput = stal.getHashDataInput();
+ if (TEST_SESSION_ID.equals(sessId)) {
+ log
+ .debug("Received TestSession GetHashDataInput, setting dummy HashDataInputCallback");
+ hashDataInput = new HashDataInputCallback() {
+
+ @Override
+ public InputStream getHashDataInput(String referenceId) {
+ byte[] hd = ("dummyhashdatainput_" + referenceId).getBytes();
+ return new ByteArrayInputStream(hd);
+ }
+ };
+ }
+ if (hashDataInput != null) {
+ List<GetHashDataInputType.Reference> references = request
+ .getReference();
+ for (GetHashDataInputType.Reference reference : references) {
+ String refId = reference.getID();
+ if (log.isDebugEnabled()) {
+ log.debug("Resolving HashDataInput for reference " + refId);
+ }
+ ByteArrayOutputStream baos = null;
+ try {
+ InputStream hdi = hashDataInput.getHashDataInput(refId);
+ baos = new ByteArrayOutputStream(hdi.available());
+ int c;
+ while ((c = hdi.read()) != -1) {
+ baos.write(c);
+ }
+ GetHashDataInputResponseType.Reference ref = new GetHashDataInputResponseType.Reference();
+ ref.setID(refId);
+ ref.setValue(baos.toByteArray());
+ response.getReference().add(ref);
+ } catch (IOException ex) {
+ String msg = "Failed to get HashDataInput for reference " + refId;
+ log.error(msg, ex);
+ GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
+ faultInfo.setErrorCode(1);
+ faultInfo.setErrorMessage(msg);
+ throw new GetHashDataInputFault(msg, faultInfo, ex);
+ } finally {
+ try {
+ baos.close();
+ } catch (IOException ex) {
+ }
+ }
+ }
+ } else {
+ log.warn("Could not resolve any HashDataInputs for session " + sessId
+ + ", no callback provided.");
+ }
+ return response;
+ }
+ }
+
+ private STALRequestBroker getStal(Id sessionId) {
+ // log.warn("RETURNING DUMMY STAL REQUEST BROKER");
+ // return new STALRequestBrokerImpl();
+
+ MessageContext mCtx = wsContext.getMessageContext();
+ ServletContext sCtx = (ServletContext) mCtx
+ .get(MessageContext.SERVLET_CONTEXT);
+ BindingProcessorManager bpMgr = (BindingProcessorManager) sCtx
+ .getAttribute(BINDING_PROCESSOR_MANAGER);
+ BindingProcessor bp = bpMgr.getBindingProcessor(sessionId);
+ return (bp == null) ? null : (STALRequestBroker) bp.getSTAL();
+ }
+}
diff --git a/BKUOnline/src/main/resources/commons-logging.properties b/BKUOnline/src/main/resources/commons-logging.properties
new file mode 100644
index 00000000..0d497b1b
--- /dev/null
+++ b/BKUOnline/src/main/resources/commons-logging.properties
@@ -0,0 +1,16 @@
+# 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.
+
+org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
diff --git a/BKUOnline/src/main/resources/log4j.properties b/BKUOnline/src/main/resources/log4j.properties
new file mode 100644
index 00000000..ed14b424
--- /dev/null
+++ b/BKUOnline/src/main/resources/log4j.properties
@@ -0,0 +1,34 @@
+# 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.
+
+# loglever DEBUG, appender STDOUT
+log4j.rootLogger=TRACE, STDOUT
+#log4j.logger.at.gv.egiz.slbinding.RedirectEventFilter=DEBUG, STDOUT
+
+# 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 | %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
diff --git a/BKUOnline/src/main/webapp/HTTP-ohne.html b/BKUOnline/src/main/webapp/HTTP-ohne.html
new file mode 100644
index 00000000..9cdd67ab
--- /dev/null
+++ b/BKUOnline/src/main/webapp/HTTP-ohne.html
@@ -0,0 +1,85 @@
+<!--
+ 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.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>Infobox Requests</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+</head>
+<body>
+<h1>Securitykapsel - HTTP-Bindung</h1>
+<style type="text/css">
+fieldset {
+ padding: 1em;
+ font: 80%/ 1 sans-serif;
+ background-color: #F2EFE9;
+ padding-left: 5em;
+}
+
+fieldset.submit {
+ float: none;
+ width: auto;
+ border: 0 none #FFF;
+ padding-left: 14em;
+ border-style: none;
+ background-color: transparent;
+}
+
+label {
+ float: left;
+ width: 8em;
+ margin-right: 0.5em;
+ padding-top: 0.2em;
+ text-align: right;
+ font-weight: bold;
+ color: #000;
+ padding-top: 0.2em;
+}
+
+legend {
+ border: 1px solid;
+ padding: 2px 6px
+}
+</style>
+
+<p>
+<form action="./http-security-layer-request" method="Post"
+ enctype="application/x-www-form-urlencoded">
+<fieldset><legend>Enter XML Request</legend>
+<p><label for="XMLRequest">XML Request</label> <textarea
+ name="XMLRequest" rows=15 cols="60" id="XMLRequest">
+<?xml version="1.0" encoding="UTF-8" ?>
+<sl:InfoboxReadRequest
+ xmlns:sl="http://www.buergerkarte.at/namespaces/securitylayer/1.2#">
+<sl:InfoboxIdentifier>IdentityLink</sl:InfoboxIdentifier>
+<sl:BinaryFileParameters ContentIsXMLEntity="true" />
+</sl:InfoboxReadRequest>
+</textarea></p>
+<!--
+<p><label for="RedirectURL">RedirectURL</label> <input
+ name="RedirectURL" value="" id="RedirectURL"></p>
+<p><label for="DataURL">DataURL</label> <input name="DataURL"
+ value="" id="DataURL"></p>
+<p><label for="StyleSheetURL">StyleSheetURL</label> <input
+ name="StyleSheetURL" value="" id="StyleSheetURL"></p>
+<p>
+ --></fieldset>
+<fieldset class="submit"><input type="submit" class="submit"></fieldset>
+</form>
+
+</body>
+</html>
diff --git a/BKUOnline/src/main/webapp/META-INF/MANIFEST.MF b/BKUOnline/src/main/webapp/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..5e949512
--- /dev/null
+++ b/BKUOnline/src/main/webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/BKUOnline/src/main/webapp/META-INF/context.xml b/BKUOnline/src/main/webapp/META-INF/context.xml
new file mode 100644
index 00000000..3568c9ec
--- /dev/null
+++ b/BKUOnline/src/main/webapp/META-INF/context.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<Context path="/bkuonline"/>
diff --git a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
new file mode 100644
index 00000000..7a2f12b8
--- /dev/null
+++ b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
+ <bean id="STALFactory" class="at.gv.egiz.stal.service.impl.RequestBrokerSTALFactory"
+ scope="singleton" />
+ <bean id="commandInvoker" class="at.gv.egiz.bku.binding.SLCommandInvokerImpl" />
+ <bean id="bindingProcessorManager" class="at.gv.egiz.bku.binding.BindingProcessorManagerImpl"
+ scope="singleton">
+ <constructor-arg ref="STALFactory"></constructor-arg>
+ <constructor-arg ref="commandInvoker"></constructor-arg>
+ </bean>
+ <bean
+ class="org.springframework.web.context.support.ServletContextAttributeExporter">
+ <property name="attributes">
+ <map>
+ <entry key="bindingProcessorManager">
+ <ref bean="bindingProcessorManager" />
+ </entry>
+ </map>
+ </property>
+ </bean>
+ <!-- Configure Configuration -->
+ <bean id="configurator" class="at.gv.egiz.bku.online.conf.Configurator"
+ scope="singleton">
+ </bean>
+</beans> \ No newline at end of file
diff --git a/BKUOnline/src/main/webapp/WEB-INF/sun-jaxws.xml b/BKUOnline/src/main/webapp/WEB-INF/sun-jaxws.xml
new file mode 100644
index 00000000..6e8f8b69
--- /dev/null
+++ b/BKUOnline/src/main/webapp/WEB-INF/sun-jaxws.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!--
+ Description: tomcat deployement
+-->
+
+<endpoints
+ xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
+ version="2.0">
+
+ <endpoint
+ name="STALPort"
+ interface="at.gv.egiz.stal.service.STALPortType"
+ implementation="at.gv.egiz.stal.service.impl.STALServiceImpl"
+ wsdl="WEB-INF/wsdl/stal.wsdl"
+ service="{http://www.egiz.gv.at/wsdl/stal}STALService"
+ port="{http://www.egiz.gv.at/wsdl/stal}STALPort"
+ url-pattern="/stal" />
+
+</endpoints>
diff --git a/BKUOnline/src/main/webapp/WEB-INF/web.xml b/BKUOnline/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000..417dabb8
--- /dev/null
+++ b/BKUOnline/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<web-app id="bkuonline" version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <display-name>http-security-layer-request</display-name>
+
+ <!-- Begin Spring Config -->
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>/WEB-INF/applicationContext.xml</param-value>
+ </context-param>
+ <listener>
+ <listener-class>
+ org.springframework.web.context.ContextLoaderListener
+ </listener-class>
+ </listener>
+ <!-- End Spring Config -->
+
+ <!-- Begin BKU Config -->
+ <listener>
+ <listener-class>at.gv.egiz.bku.online.webapp.SessionTimeout</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>BKUServlet</servlet-name>
+ <servlet-class>at.gv.egiz.bku.online.webapp.BKURequestHandler</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>ResultServlet</servlet-name>
+ <servlet-class>at.gv.egiz.bku.online.webapp.ResultServlet</servlet-class>
+ <init-param>
+ <param-name>responseEncoding</param-name>
+ <param-value>UTF-8</param-value>
+ </init-param>
+ <init-param>
+ <param-name>expiredPage</param-name>
+ <!-- FIXME -->
+ <param-value>expired.html</param-value>
+ </init-param>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>BKUServlet</servlet-name>
+ <url-pattern>/http-security-layer-request</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>BKUServlet</servlet-name>
+ <url-pattern>/https-security-layer-request</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>ResultServlet</servlet-name>
+ <url-pattern>/bkuResult</url-pattern>
+ </servlet-mapping>
+ <!-- End BKU Config -->
+
+
+
+ <!-- Begin STAL Config -->
+ <listener>
+ <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>STALPort</servlet-name>
+ <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>STALPort</servlet-name>
+ <url-pattern>/stal</url-pattern>
+ </servlet-mapping>
+ <!-- End STAL Config -->
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ <welcome-file>index.htm</welcome-file>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>default.html</welcome-file>
+ <welcome-file>default.htm</welcome-file>
+ <welcome-file>default.jsp</welcome-file>
+ </welcome-file-list>
+ <session-config>
+ <session-timeout>3</session-timeout>
+ </session-config>
+</web-app> \ No newline at end of file
diff --git a/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.wsdl b/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.wsdl
new file mode 100644
index 00000000..a9f16a12
--- /dev/null
+++ b/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.wsdl
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<definitions name="stal" targetNamespace="http://www.egiz.gv.at/wsdl/stal"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.egiz.gv.at/wsdl/stal" xmlns:ns="http://www.egiz.gv.at/stal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema targetNamespace="http://www.egiz.gv.at/wsdl/stal">
+ <xsd:import namespace="http://www.egiz.gv.at/stal" schemaLocation="stal.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="NextRequestRequest">
+ <part name="part1" element="ns:GetNextRequest"/>
+ </message>
+ <message name="NextRequestResponse">
+ <part name="part1" element="ns:GetNextRequestResponse"/>
+ </message>
+ <message name="GetHashDataInputRequest">
+ <part name="part1" element="ns:GetHashDataInput"/>
+ </message>
+ <message name="GetHashDataInputResponse">
+ <part name="part1" element="ns:GetHashDataInputResponse"/>
+ </message>
+ <message name="GetHashDataInputFault">
+ <part name="part1" element="ns:GetHashDataInputFault"/>
+ </message>
+ <portType name="STALPortType">
+ <operation name="nextRequest">
+ <input name="input1" message="tns:NextRequestRequest"/>
+ <output name="output1" message="tns:NextRequestResponse"/>
+ </operation>
+ <operation name="getHashDataInput">
+ <input name="input2" message="tns:GetHashDataInputRequest"/>
+ <output name="output2" message="tns:GetHashDataInputResponse"/>
+ <fault name="fault1" message="tns:GetHashDataInputFault"/>
+ </operation>
+ </portType>
+ <binding name="STALBinding" type="tns:STALPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="nextRequest">
+ <soap:operation/>
+ <input name="input1">
+ <soap:body use="literal"/>
+ </input>
+ <output name="output1">
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="getHashDataInput">
+ <soap:operation/>
+ <input name="input2">
+ <soap:body use="literal"/>
+ </input>
+ <output name="output2">
+ <soap:body use="literal"/>
+ </output>
+ <fault name="fault1">
+ <soap:fault name="fault1"/>
+ </fault>
+ </operation>
+ </binding>
+ <service name="STALService">
+ <port name="STALPort" binding="tns:STALBinding">
+ <soap:address location="http://localhost:${HttpDefaultPort}/stal"/>
+ </port>
+ </service>
+</definitions>
diff --git a/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd b/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd
new file mode 100644
index 00000000..6627db00
--- /dev/null
+++ b/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.egiz.gv.at/stal"
+ xmlns:tns="http://www.egiz.gv.at/stal"
+ elementFormDefault="qualified">
+ <element name="GetNextRequest" type="tns:GetNextRequestType"/>
+ <element name="GetNextRequestResponse" type="tns:GetNextRequestResponseType"/>
+ <element name="GetHashDataInput" type="tns:GetHashDataInputType"/>
+ <element name="GetHashDataInputResponse" type="tns:GetHashDataInputResponseType"/>
+ <element name="GetHashDataInputFault" type="tns:GetHashDataInputFaultType"/>
+ <complexType name="GetNextRequestType">
+ <sequence>
+ <element name="Response" type="tns:ResponseType" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="sessionId" type="string"/>
+ <!--choice maxOccurs="unbounded">
+ <element name="InfoboxReadResponse" type="tns:InfoboxReadResponseType"/>
+ <element name="SignResponse" type="tns:SignResponseType"/>
+ <element name="ErrorResponse" type="tns:ErrorResponseType"/>
+ </choice-->
+ </complexType>
+ <complexType name="ResponseType" abstract="true">
+ <attribute name="Id" type="ID"/>
+ </complexType>
+ <complexType name="InfoboxReadResponseType">
+ <complexContent>
+ <extension base="tns:ResponseType">
+ <sequence>
+ <element name="InfoboxValue" type="base64Binary"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="SignResponseType">
+ <complexContent>
+ <extension base="tns:ResponseType">
+ <sequence>
+ <element name="SignatureValue" type="base64Binary"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="ErrorResponseType">
+ <complexContent>
+ <extension base="tns:ResponseType">
+ <sequence>
+ <element name="ErrorCode" type="int"/>
+ <element name="ErrorMessage" type="string"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="GetNextRequestResponseType">
+ <sequence>
+ <element name="Request" type="tns:RequestType" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="sessionId" type="string"/>
+ <!--choice maxOccurs="unbounded">
+ <element name="InfoboxReadRequest" type="tns:InfoboxReadRequestType"/>
+ <element name="SignRequest" type="tns:SignRequestType"/>
+ <element name="QuitRequest" type="tns:QuitRequestType"/>
+ </choice-->
+ </complexType>
+ <complexType name="RequestType" abstract="true"/>
+ <complexType name="InfoboxReadRequestType">
+ <complexContent>
+ <extension base="tns:RequestType">
+ <sequence>
+ <element name="InfoboxIdentifier" type="string"/>
+ <element name="DomainIdentifier" type="string" minOccurs="0"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="SignRequestType">
+ <complexContent>
+ <extension base="tns:RequestType">
+ <sequence>
+ <element name="KeyIdentifier" type="string"/>
+ <element name="SignedInfo" type="base64Binary"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <complexType name="QuitRequestType">
+ <complexContent>
+ <extension base="tns:RequestType"/>
+ </complexContent>
+ </complexType>
+ <complexType name="GetHashDataInputType">
+ <sequence>
+ <element name="Reference" maxOccurs="unbounded">
+ <complexType>
+ <attribute name="ID" type="string"/>
+ </complexType>
+ </element>
+ </sequence>
+ <attribute name="sessionId" type="string"/>
+ </complexType>
+ <complexType name="GetHashDataInputResponseType">
+ <sequence>
+ <element name="Reference" maxOccurs="unbounded">
+ <complexType>
+ <simpleContent>
+ <extension base="base64Binary">
+ <attribute name="ID" type="ID"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+ </element>
+ </sequence>
+ <attribute name="sessionId" type="string"/>
+ </complexType>
+ <complexType name="GetHashDataInputFaultType">
+ <sequence>
+ <element name="ErrorCode" type="int"/>
+ <element name="ErrorMessage" type="string"/>
+ </sequence>
+ </complexType>
+</schema>
diff --git a/BKUOnline/src/main/webapp/appletPage.jsp b/BKUOnline/src/main/webapp/appletPage.jsp
new file mode 100644
index 00000000..684a8dca
--- /dev/null
+++ b/BKUOnline/src/main/webapp/appletPage.jsp
@@ -0,0 +1,65 @@
+<!--
+ 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.
+-->
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Applet BKU Test</title>
+</head>
+<body>
+<script src="./js/deployJava.js"></script>
+<script>
+ if (!deployJava.versionCheck('1.6.0')) {
+ document
+ .write('<b>Diese Anwendung benötigt die Java Platform Version 1.6.0 oder höher.</b>' + '<input type="submit" value="Java Platform 1.6.0 installieren" onclick="deployJava.installLatestJRE();">');
+ } else {
+ var attributes = {
+ codebase :'applet',
+ code :'at.gv.egiz.bku.online.applet.BKUApplet.class',
+ archive :'BKUApplet-1.0-SNAPSHOT.jar, commons-logging-1.1.1.jar, iaik_jce_me4se-3.04.jar',
+ width :500,
+ height :200
+ };
+ var parameters = {
+ WSDL_URL :'../stal?wsdl',
+ SessionID : '<%= session.getId() %>',
+ redirectURL : '../bkuResult'
+ };
+ var version = '1.6.0';
+ deployJava.runApplet(attributes, parameters, version);
+ }
+</script>
+<br />
+<script>
+ document.write('App Name: ' + navigator.appName + '<BR>');
+ document.write('User Agent: ' + navigator.userAgent + '<BR>');
+ var list = deployJava.getJREs();
+ if (list.length == 0) {
+ document.write('No Detectable Java Platforms are Installed<BR>');
+ } else {
+ var result = list[0];
+ for ( var i = 1; i < list.length; i++) {
+ result += ", " + list[i];
+ }
+ document.write("You have the following Java Platform(s) installed:"
+ + result + "<BR>");
+ }
+</script>
+</body>
+</html>
diff --git a/BKUOnline/src/main/webapp/expired.html b/BKUOnline/src/main/webapp/expired.html
new file mode 100644
index 00000000..67ca94bc
--- /dev/null
+++ b/BKUOnline/src/main/webapp/expired.html
@@ -0,0 +1,28 @@
+<!--
+ 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.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Session Expired</title>
+</head>
+<body>
+ <p>
+ Ihre Sitzung ist abgelaufen. Ein neuer BKU request kann im <a href="HTTP-ohne.html">Requestformular</a> erstellt werden.
+ </p>
+</body>
+</html> \ No newline at end of file
diff --git a/BKUOnline/src/main/webapp/index.html b/BKUOnline/src/main/webapp/index.html
new file mode 100644
index 00000000..8f1a338e
--- /dev/null
+++ b/BKUOnline/src/main/webapp/index.html
@@ -0,0 +1,59 @@
+<!--
+ 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.
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>BKU Online</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+</head>
+<body>
+<style type="text/css">
+ .box {
+ margin-top: 10px;
+ color: #292929;
+ width: 300px;
+ border: 1px solid #BABABA;
+ background-color: #ddd;
+ padding-left: 10px;
+ padding-right: 10px;
+ margin-left: 10px;
+ margin-bottom: 1em;
+ -o-border-radius: 10px;
+ -moz-border-radius: 12px;
+ -webkit-border-radius: 10px;
+ -webkit-box-shadow: 0px 3px 7px #adadad;
+ border-radius: 10px;
+ -moz-box-sizing: border-box;
+ -opera-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ -khtml-box-sizing: border-box;
+ box-sizing: border-box;
+ overflow: hidden;
+ }
+</style>
+<div id="animDiv" class="box">
+<p>
+<h1>TestRequest</h1>
+<a href="HTTP-ohne.html">Security Layer Request</a>
+<h1>STAL Service</h1>
+<a href="stal">STAL Service Endpoint Information</a>
+</p>
+</div>
+
+
+</body>
+</html>
diff --git a/BKUOnline/src/main/webapp/js/deployJava.js b/BKUOnline/src/main/webapp/js/deployJava.js
new file mode 100644
index 00000000..4d8a0ca3
--- /dev/null
+++ b/BKUOnline/src/main/webapp/js/deployJava.js
@@ -0,0 +1,886 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Sun Microsystems nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * deployJava.js
+ *
+ * This file is part of the Deployment Toolkit. It provides functions for web
+ * pages to detect the presence of a JRE, install the latest JRE, and easily run
+ * applets or Web Start programs. Usage guide may be found at http://<TBD>/.
+ *
+ * The "live" copy of this file may be found at
+ * http://java.com/js/deployJava.js.
+ * You are encouraged to link directly to the live copy of the file.
+ *
+ * @version @(#)deployJava.js 1.11 08/07/11
+ */
+
+var deployJava = {
+ debug: null,
+
+ myInterval: null,
+ preInstallJREList: null,
+ returnPage: null,
+ brand: null,
+ locale: null,
+ installType: null,
+
+ EAInstallEnabled: false,
+ EarlyAccessURL: null,
+
+ // GetJava page
+ getJavaURL: 'http://java.sun.com/webapps/getjava/BrowserRedirect?host=java.com',
+
+ // Apple redirect page
+ appleRedirectPage: 'http://www.apple.com/support/downloads/',
+
+ // mime-type of the DeployToolkit plugin object
+ mimeType: 'application/npruntime-scriptable-plugin;DeploymentToolkit',
+
+ // location of the Java Web Start launch button graphic
+ launchButtonPNG: 'http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png',
+
+
+ /**
+ * Returns an array of currently-installed JRE version strings.
+ * Version strings are of the form #.#[.#[_#]], with the function returning
+ * as much version information as it can determine, from just family
+ * versions ("1.4.2", "1.5") through the full version ("1.5.0_06").
+ *
+ * Detection is done on a best-effort basis. Under some circumstances
+ * only the highest installed JRE version will be detected, and
+ * JREs older than 1.4.2 will not always be detected.
+ */
+ getJREs: function() {
+ var list = new Array();
+ if (deployJava.isPluginInstalled()) {
+ var plugin = deployJava.getPlugin();
+ for (var i = 0; i < plugin.jvms.getLength(); i++) {
+ list[i] = plugin.jvms.get(i).version;
+ }
+ } else {
+ var browser = deployJava.getBrowser();
+
+ if (browser == 'MSIE') {
+ if (deployJava.testUsingActiveX('1.8.0')) {
+ list[0] = '1.8.0';
+ } else if (deployJava.testUsingActiveX('1.7.0')) {
+ list[0] = '1.7.0';
+ } else if (deployJava.testUsingActiveX('1.6.0')) {
+ list[0] = '1.6.0';
+ } else if (deployJava.testUsingActiveX('1.5.0')) {
+ list[0] = '1.5.0';
+ } else if (deployJava.testUsingActiveX('1.4.2')) {
+ list[0] = '1.4.2';
+ } else if (deployJava.testForMSVM()) {
+ list[0] = '1.1';
+ }
+ }
+ else if (browser == 'Netscape Family') {
+ if (deployJava.testUsingMimeTypes('1.8')) {
+ list[0] = '1.8.0';
+ } else if (deployJava.testUsingMimeTypes('1.7')) {
+ list[0] = '1.7.0';
+ } else if (deployJava.testUsingMimeTypes('1.6')) {
+ list[0] = '1.6.0';
+ } else if (deployJava.testUsingMimeTypes('1.5')) {
+ list[0] = '1.5.0';
+ } else if (deployJava.testUsingMimeTypes('1.4.2')) {
+ list[0] = '1.4.2';
+ }
+ } else if (browser == 'Safari') {
+ if (deployJava.testUsingPluginsArray('1.8.0')) {
+ list[0] = '1.8.0';
+ } else if (deployJava.testUsingPluginsArray('1.7.0')) {
+ list[0] = '1.7.0';
+ } else if (deployJava.testUsingPluginsArray('1.6.0')) {
+ list[0] = '1.6.0';
+ } else if (deployJava.testUsingPluginsArray('1.5.0')) {
+ list[0] = '1.5.0';
+ } else if (deployJava.testUsingPluginsArray('1.4.2')) {
+ list[0] = '1.4.2';
+ }
+ }
+ }
+
+ if (deployJava.debug) {
+ for (var i = 0; i < list.length; ++i) {
+ alert('We claim to have detected Java SE ' + list[i]);
+ }
+ }
+
+ return list;
+ },
+
+ /**
+ * Triggers a JRE installation. The exact effect of triggering an
+ * installation varies based on platform, browser, and if the
+ * Deployment Toolkit plugin is installed.
+ *
+ * The requestVersion string is of the form #[.#[.#[_#]]][+|*],
+ * which includes strings such as "1.4", "1.5.0*", and "1.6.0_02+".
+ * A star (*) means "any version starting within this family" and
+ * a plus (+) means "any version greater or equal to this".
+ * "1.5.0*" * matches 1.5.0_06 but not 1.6.0_01, whereas
+ * "1.5.0+" matches both.
+ *
+ * If the Deployment Toolkit plugin is not present, this will just call
+ * deployJava.installLatestJRE().
+ */
+ installJRE: function(requestVersion) {
+ var ret = false;
+ if (deployJava.isPluginInstalled()) {
+ if (deployJava.getPlugin().installJRE(requestVersion)) {
+ deployJava.refresh();
+ if (deployJava.returnPage != null) {
+ document.location = deployJava.returnPage;
+ }
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return deployJava.installLatestJRE();
+ }
+ },
+
+
+ /**
+ * Triggers a JRE installation. The exact effect of triggering an
+ * installation varies based on platform, browser, and if the
+ * Deployment Toolkit plugin is installed.
+ *
+ * In the simplest case, the browser window will be redirected to the
+ * java.com JRE installation page, and (if possible) a redirect back to
+ * the current URL upon successful installation. The return redirect is
+ * not always possible, as the JRE installation may require the browser to
+ * be restarted.
+ *
+ * In the best case (when the Deployment Toolkit plugin is present), this
+ * function will immediately cause a progress dialog to be displayed
+ * as the JRE is downloaded and installed.
+ */
+ installLatestJRE: function() {
+ if (deployJava.isPluginInstalled()) {
+ if (deployJava.getPlugin().installLatestJRE()) {
+ deployJava.refresh();
+ if (deployJava.returnPage != null) {
+ document.location = deployJava.returnPage;
+ }
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ var browser = deployJava.getBrowser();
+ var platform = navigator.platform.toLowerCase();
+ if ((deployJava.EAInstallEnabled == 'true') &&
+ (platform.indexOf('win') != -1) &&
+ (deployJava.EarlyAccessURL != null)) {
+
+ deployJava.preInstallJREList = deployJava.getJREs();
+ if (deployJava.returnPage != null) {
+ deployJava.myInterval =
+ setInterval("deployJava.poll()", 3000);
+ }
+
+ location.href = deployJava.EarlyAccessURL;
+
+ // we have to return false although there may be an install
+ // in progress now, when complete it may go to return page
+ return false;
+ } else {
+ if (browser == 'MSIE') {
+ return deployJava.IEInstall();
+ } else if ((browser == 'Netscape Family') &&
+ (platform.indexOf('win32') != -1)) {
+ return deployJava.FFInstall();
+ } else {
+ location.href = deployJava.getJavaURL +
+ ((deployJava.returnPage != null) ?
+ ('&returnPage=' + deployJava.returnPage) : '') +
+ ((deployJava.locale != null) ?
+ ('&locale=' + deployJava.locale) : '') +
+ ((deployJava.brand != null) ?
+ ('&brand=' + deployJava.brand) : '');
+ }
+ // we have to return false although there may be an install
+ // in progress now, when complete it may go to return page
+ return false;
+ }
+ }
+ },
+
+
+ /**
+ * Ensures that an appropriate JRE is installed and then runs an applet.
+ * minimumVersion is of the form #[.#[.#[_#]]], and is the minimum
+ * JRE version necessary to run this applet. minimumVersion is optional,
+ * defaulting to the value "1.1" (which matches any JRE).
+ * If an equal or greater JRE is detected, runApplet() will call
+ * writeAppletTag(attributes, parameters) to output the applet tag,
+ * otherwise it will call installJRE(minimumVersion + '+').
+ *
+ * After installJRE() is called, the script will attempt to detect that the
+ * JRE installation has completed and begin running the applet, but there
+ * are circumstances (such as when the JRE installation requires a browser
+ * restart) when this cannot be fulfilled.
+ *
+ * As with writeAppletTag(), this function should only be called prior to
+ * the web page being completely rendered. Note that version wildcards
+ * (star (*) and plus (+)) are not supported, and including them in the
+ * minimumVersion will result in an error message.
+ */
+ runApplet: function(attributes, parameters, minimumVersion) {
+ if (minimumVersion == 'undefined' || minimumVersion == null) {
+ minimumVersion = '1.1';
+ }
+
+ var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
+
+ var matchData = minimumVersion.match(regex);
+
+ if (deployJava.returnPage == null) {
+ // if there is an install, come back here and run the applet
+ deployJava.returnPage = document.location;
+ }
+
+ if (matchData != null) {
+ var browser = deployJava.getBrowser();
+ if ((browser != '?') && (browser != 'Safari')) {
+ if (deployJava.versionCheck(minimumVersion + '+')) {
+ deployJava.writeAppletTag(attributes, parameters);
+ } else if (deployJava.installJRE(minimumVersion + '+')) {
+ // after successfull install we need to refresh page to pick
+ // pick up new plugin
+ deployJava.refresh();
+ location.href = document.location;
+ deployJava.writeAppletTag(attributes, parameters);
+ }
+ } else {
+ // for unknown or Safari - just try to show applet
+ deployJava.writeAppletTag(attributes, parameters);
+ }
+ } else {
+ if (deployJava.debug) {
+ alert('Invalid minimumVersion argument to runApplet():' +
+ minimumVersion);
+ }
+ }
+ },
+
+
+ /**
+ * Outputs an applet tag with the specified attributes and parameters, where
+ * both attributes and parameters are associative arrays. Each key/value
+ * pair in attributes becomes an attribute of the applet tag itself, while
+ * key/value pairs in parameters become <PARAM> tags. No version checking
+ * or other special behaviors are performed; the tag is simply written to
+ * the page using document.writeln().
+ *
+ * As document.writeln() is generally only safe to use while the page is
+ * being rendered, you should never call this function after the page
+ * has been completed.
+ */
+ writeAppletTag: function(attributes, parameters) {
+ var s = '<' + 'applet ';
+ for (var attribute in attributes) {
+ s += (' ' + attribute + '="' + attributes[attribute] + '"');
+ }
+ s += '>';
+ document.write(s);
+
+ if (parameters != 'undefined' && parameters != null) {
+ for (var parameter in parameters) {
+ s = '<param name="' + parameter + '" value="' +
+ parameters[parameter] + '">';
+ document.write(s);
+ }
+ }
+ document.write('<' + '/' + 'applet' + '>');
+ },
+
+
+ /**
+ * Returns true if there is a matching JRE version currently installed
+ * (among those detected by getJREs()). The versionPattern string is
+ * of the form #[.#[.#[_#]]][+|*], which includes strings such as "1.4",
+ * "1.5.0*", and "1.6.0_02+".
+ * A star (*) means "any version within this family" and a plus (+) means
+ * "any version greater or equal to the specified version". "1.5.0*"
+ * matches 1.5.0_06 but not 1.6.0_01, whereas "1.5.0+" matches both.
+ *
+ * If the versionPattern does not include all four version components
+ * but does not end with a star or plus, it will be treated as if it
+ * ended with a star. "1.5" is exactly equivalent to "1.5*", and will
+ * match any version number beginning with "1.5".
+ *
+ * If getJREs() is unable to detect the precise version number, a match
+ * could be ambiguous. For example if getJREs() detects "1.5", there is
+ * no way to know whether the JRE matches "1.5.0_06+". versionCheck()
+ * compares only as much of the version information as could be detected,
+ * so versionCheck("1.5.0_06+") would return true in in this case.
+ *
+ * Invalid versionPattern will result in a JavaScript error alert.
+ * versionPatterns which are valid but do not match any existing JRE
+ * release (e.g. "32.65+") will always return false.
+ */
+ versionCheck: function(versionPattern)
+ {
+ var index = 0;
+ var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?(\\*|\\+)?$";
+
+ var matchData = versionPattern.match(regex);
+
+ if (matchData != null) {
+ var familyMatch = true;
+
+ var patternArray = new Array();
+
+ for (var i = 1; i < matchData.length; ++i) {
+ // browser dependency here.
+ // Fx sets 'undefined', IE sets '' string for unmatched groups
+ if ((typeof matchData[i] == 'string') && (matchData[i] != '')) {
+ patternArray[index] = matchData[i];
+ index++;
+ }
+ }
+
+ if (patternArray[patternArray.length-1] == '+') {
+ familyMatch = false;
+ patternArray.length--;
+ } else {
+ if (patternArray[patternArray.length-1] == '*') {
+ patternArray.length--;
+ }
+ }
+
+ var list = deployJava.getJREs();
+ for (var i = 0; i < list.length; ++i) {
+ if (deployJava.compareVersionToPattern(list[i], patternArray,
+ familyMatch)) {
+ return true;
+ }
+ }
+
+ return false;
+ } else {
+ alert('Invalid versionPattern passed to versionCheck: ' +
+ versionPattern);
+ return false;
+ }
+ },
+
+
+ /**
+ * Returns true if an installation of Java Web Start of the specified
+ * minimumVersion can be detected. minimumVersion is optional, and
+ * if not specified, '1.4.2' will be used.
+ * (Versions earlier than 1.4.2 may not be detected.)
+ */
+ isWebStartInstalled: function(minimumVersion) {
+
+ var browser = deployJava.getBrowser();
+ if ((browser == '?') || (browser == 'Safari')) {
+ // we really don't know - better to try to use it than reinstall
+ return true;
+ }
+
+ if (minimumVersion == 'undefined' || minimumVersion == null) {
+ minimumVersion = '1.4.2';
+ }
+
+ var retval = false;
+ var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
+ var matchData = minimumVersion.match(regex);
+
+ if (matchData != null) {
+ retval = deployJava.versionCheck(minimumVersion + '+');
+ } else {
+ if (deployJava.debug) {
+ alert('Invalid minimumVersion argument to isWebStartInstalled(): ' + minimumVersion);
+ }
+ retval = deployJava.versionCheck('1.4.2+');
+ }
+ return retval;
+ },
+
+
+ /**
+ * Outputs a launch button for the specified JNLP URL. When clicked, the
+ * button will ensure that an appropriate JRE is installed and then launch
+ * the JNLP application. minimumVersion is of the form #[.#[.#[_#]]], and
+ * is the minimum JRE version necessary to run this JNLP application.
+ * minimumVersion is optional, and if it is not specified, '1.4.2'
+ * will be used.
+ * If an appropriate JRE or Web Start installation is detected,
+ * the JNLP application will be launched, otherwise installLatestJRE()
+ * will be called.
+ *
+ * After installLatestJRE() is called, the script will attempt to detect
+ * that the JRE installation has completed and launch the JNLP application,
+ * but there are circumstances (such as when the JRE installation
+ * requires a browser restart) when this cannot be fulfilled.
+ */
+ createWebStartLaunchButton: function(jnlp, minimumVersion) {
+
+ if (deployJava.returnPage == null) {
+ // if there is an install, come back and run the jnlp file
+ deployJava.returnPage = jnlp;
+ }
+
+ var url = 'javascript:' +
+ 'if (!deployJava.isWebStartInstalled(&quot;' +
+ minimumVersion + '&quot;)) {' +
+ 'if (deployJava.installLatestJRE()) {' +
+ 'if (deployJava.launch(&quot;' + jnlp + '&quot;)) {}' +
+ '}' +
+ '} else {' +
+ 'if (deployJava.launch(&quot;' + jnlp + '&quot;)) {}' +
+ '}';
+
+ document.write('<' + 'a href="' + url +
+ '" onMouseOver="window.status=\'\'; ' +
+ 'return true;"><' + 'img ' +
+ 'src="' + deployJava.launchButtonPNG + '" ' +
+ 'border="0" /><' + '/' + 'a' + '>');
+ },
+
+
+ /**
+ * Launch a JNLP application, (using the plugin if available)
+ */
+ launch: function(jnlp) {
+ if (deployJava.isPluginInstalled()) {
+ return deployJava.getPlugin().launch(jnlp);
+ } else {
+ document.location=jnlp;
+ return true;
+ }
+ },
+
+
+ /*
+ * returns true if the ActiveX or XPI plugin is installed
+ */
+ isPluginInstalled: function() {
+ var plugin = deployJava.getPlugin();
+ if (plugin && plugin.jvms) {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /*
+ * returns true if the plugin is installed and AutoUpdate is enabled
+ */
+ isAutoUpdateEnabled: function() {
+ if (deployJava.isPluginInstalled()) {
+ return deployJava.getPlugin().isAutoUpdateEnabled();
+ }
+ return false;
+ },
+
+ /*
+ * sets AutoUpdate on if plugin is installed
+ */
+ setAutoUpdateEnabled: function() {
+ if (deployJava.isPluginInstalled()) {
+ return deployJava.getPlugin().setAutoUpdateEnabled();
+ }
+ return false;
+ },
+
+ /*
+ * sets the preferred install type : null, online, kernel
+ */
+ setInstallerType: function(type) {
+ deployJava.installType = type;
+ if (deployJava.isPluginInstalled()) {
+ return deployJava.getPlugin().setInstallerType(type);
+ }
+ return false;
+ },
+
+ /*
+ * sets additional package list - to be used by kernel installer
+ */
+ setAdditionalPackages: function(packageList) {
+ if (deployJava.isPluginInstalled()) {
+ return deployJava.getPlugin().setAdditionalPackages(
+ packageList);
+ }
+ return false;
+ },
+
+ /*
+ * sets preference to install Early Access versions if available
+ */
+ setEarlyAccess: function(enabled) {
+ deployJava.EAInstallEnabled = enabled;
+ },
+
+ /*
+ * Determines if the next generation plugin (Plugin II) is default
+ */
+ isPlugin2: function() {
+ if (deployJava.isPluginInstalled()) {
+ try {
+ return deployJava.getPlugin().isPlugin2();
+ } catch (err) {
+ // older plugin w/o isPlugin2() function - just fall through
+ }
+ }
+ return false;
+ },
+
+
+ getPlugin: function() {
+ deployJava.refresh();
+ var ret = document.getElementById('deployJavaPlugin');
+ return ret;
+ },
+
+ compareVersionToPattern: function(version, patternArray, familyMatch) {
+ var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
+ var matchData = version.match(regex);
+
+ if (matchData != null) {
+ var index = 0;
+ var result = new Array();
+
+ for (var i = 1; i < matchData.length; ++i) {
+ if ((typeof matchData[i] == 'string') && (matchData[i] != ''))
+ {
+ result[index] = matchData[i];
+ index++;
+ }
+ }
+
+ var l = Math.min(result.length, patternArray.length);
+
+ if (familyMatch) {
+ for (var i = 0; i < l; ++i) {
+ if (result[i] != patternArray[i]) return false;
+ }
+
+ return true;
+ } else {
+ for (var i = 0; i < l; ++i) {
+ if (result[i] < patternArray[i]) {
+ return false;
+ } else if (result[i] > patternArray[i]) {
+ return true;
+ }
+ }
+
+ return true;
+ }
+ } else {
+ return false;
+ }
+ },
+
+
+ getBrowser: function() {
+ var browser = navigator.userAgent.toLowerCase();
+
+ if (deployJava.debug) {
+ alert('userAgent -> ' + browser);
+ }
+
+ if ((navigator.vendor) &&
+ (navigator.vendor.toLowerCase().indexOf('apple') != -1) &&
+ (browser.indexOf('safari') != -1)) {
+ if (deployJava.debug) {
+ alert('We claim to have detected "Safari".');
+ }
+ return 'Safari';
+ } else if (browser.indexOf('msie') != -1) {
+ if (deployJava.debug) {
+ alert('We claim to have detected "IE".');
+ }
+ return 'MSIE';
+ } else if ((browser.indexOf('mozilla') != -1) ||
+ (browser.indexOf('firefox') != -1)) {
+ if (deployJava.debug) {
+ alert('We claim to have detected a Netscape family browser.');
+ }
+ return 'Netscape Family';
+ } else {
+ if (deployJava.debug) {
+ alert('We claim to have failed to detect a browser.');
+ }
+ return '?';
+ }
+ },
+
+
+ testUsingActiveX: function(version) {
+ var objectName = 'JavaWebStart.isInstalled.' + version + '.0';
+
+ if (!ActiveXObject) {
+ if (deployJava.debug) {
+ alert ('Browser claims to be IE, but no ActiveXObject object?');
+ }
+ return false;
+ }
+
+ try {
+ return (new ActiveXObject(objectName) != null);
+ } catch (exception) {
+ return false;
+ }
+ },
+
+
+ testForMSVM: function() {
+ var clsid = '{08B0E5C0-4FCB-11CF-AAA5-00401C608500}';
+
+ if (typeof oClientCaps != 'undefined') {
+ var v = oClientCaps.getComponentVersion(clsid, "ComponentID");
+ if ((v == '') || (v == '5,0,5000,0')) {
+ return false;
+ } else {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ },
+
+
+ testUsingMimeTypes: function(version) {
+ if (!navigator.mimeTypes) {
+ if (deployJava.debug) {
+ alert ('Browser claims to be Netscape family, but no mimeTypes[] array?');
+ }
+ return false;
+ }
+
+ for (var i = 0; i < navigator.mimeTypes.length; ++i) {
+ s = navigator.mimeTypes[i].type;
+ var m = s.match(/^application\/x-java-applet\x3Bversion=(1\.8|1\.7|1\.6|1\.5|1\.4\.2)$/);
+ if (m != null) {
+ if (deployJava.compareVersions(m[1], version)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ },
+
+
+ testUsingPluginsArray: function(version) {
+ if ((!navigator.plugins) || (!navigator.plugins.length)) {
+ if (deployJava.debug) {
+ alert ('Browser claims to be Safari, but no plugins[] array?');
+ }
+ return false;
+ }
+
+ for (var i = 0; i < navigator.plugins.length; ++i) {
+ s = navigator.plugins[i].description;
+
+ if (s.search(/^Java Switchable Plug-in/) != -1) {
+ return true;
+ }
+
+ m = s.match(/^Java (1\.4\.2|1\.5|1\.6|1\.7).* Plug-in/);
+ if (m != null) {
+ if (deployJava.compareVersions(m[1], version)) return true;
+ }
+ }
+ return false;
+ },
+
+ IEInstall: function() {
+
+ location.href = deployJava.getJavaURL +
+ ((deployJava.returnPage != null) ?
+ ('&returnPage=' + deployJava.returnPage) : '') +
+ ((deployJava.locale != null) ?
+ ('&locale=' + deployJava.locale) : '') +
+ ((deployJava.brand != null) ? ('&brand=' + deployJava.brand) : '') +
+ ((deployJava.installType != null) ?
+ ('&type=' + deployJava.installType) : '');
+
+ // should not actually get here
+ return false;
+ },
+
+ done: function (name, result) {
+ },
+
+ FFInstall: function() {
+
+ location.href = deployJava.getJavaURL +
+ ((deployJava.returnPage != null) ?
+ ('&returnPage=' + deployJava.returnPage) : '') +
+ ((deployJava.locale != null) ?
+ ('&locale=' + deployJava.locale) : '') +
+ ((deployJava.brand != null) ? ('&brand=' + deployJava.brand) : '') +
+ ((deployJava.installType != null) ?
+ ('&type=' + deployJava.installType) : '');
+
+ // should not actually get here
+ return false;
+ },
+
+ // return true if 'installed' (considered as a JRE version string) is
+ // greater than or equal to 'required' (again, a JRE version string).
+ compareVersions: function(installed, required) {
+
+ var a = installed.split('.');
+ var b = required.split('.');
+
+ for (var i = 0; i < a.length; ++i) {
+ a[i] = Number(a[i]);
+ }
+ for (var i = 0; i < b.length; ++i) {
+ b[i] = Number(b[i]);
+ }
+ if (a.length == 2) {
+ a[2] = 0;
+ }
+
+ if (a[0] > b[0]) return true;
+ if (a[0] < b[0]) return false;
+
+ if (a[1] > b[1]) return true;
+ if (a[1] < b[1]) return false;
+
+ if (a[2] > b[2]) return true;
+ if (a[2] < b[2]) return false;
+
+ return true;
+ },
+
+
+ enableAlerts: function() {
+ deployJava.debug = true;
+ },
+
+ poll: function() {
+
+ deployJava.refresh();
+ var postInstallJREList = deployJava.getJREs();
+
+ if ((deployJava.preInstallJREList.length == 0) &&
+ (postInstallJREList.length != 0)) {
+ clearInterval(deployJava.myInterval);
+ if (deployJava.returnPage != null) {
+ location.href = deployJava.returnPage;
+ };
+ }
+
+ if ((deployJava.preInstallJREList.length != 0) &&
+ (postInstallJREList.length != 0) &&
+ (deployJava.preInstallJREList[0] != postInstallJREList[0])) {
+ clearInterval(deployJava.myInterval);
+ if (deployJava.returnPage != null) {
+ location.href = deployJava.returnPage;
+ }
+ }
+
+ },
+
+ writePluginTag: function() {
+ var browser = deployJava.getBrowser();
+ if (browser == 'MSIE') {
+ document.write('<' +
+ 'object classid="clsid:CAFEEFAC-DEC7-0000-0000-ABCDEFFEDCBA" ' +
+ 'id="deployJavaPlugin" width="0" height="0">' +
+ '<' + '/' + 'object' + '>');
+ } else if (browser == 'Netscape Family') {
+ if (navigator.mimeTypes != null) for (var i=0;
+ i < navigator.mimeTypes.length; i++) {
+ if (navigator.mimeTypes[i].type == deployJava.mimeType) {
+ if (navigator.mimeTypes[i].enabledPlugin) {
+ document.write('<' +
+ 'embed id="deployJavaPlugin" type="' +
+ deployJava.mimeType + '" hidden="true" />');
+ }
+ }
+ }
+ }
+ },
+
+ refresh: function() {
+ navigator.plugins.refresh(false);
+
+ var browser = deployJava.getBrowser();
+ if (browser == 'Netscape Family') {
+ var plugin = document.getElementById('deployJavaPlugin');
+ // only do this again if no plugin
+ if (plugin == null) {
+ if (navigator.mimeTypes != null) for (var i=0;
+ i < navigator.mimeTypes.length; i++) {
+ if (navigator.mimeTypes[i].type == deployJava.mimeType) {
+ if (navigator.mimeTypes[i].enabledPlugin) {
+ document.write('<' +
+ 'embed id="deployJavaPlugin" type="' +
+ deployJava.mimeType + '" hidden="true" />');
+ }
+ }
+ }
+ }
+ }
+ },
+
+ do_initialize: function() {
+ deployJava.writePluginTag();
+ if (deployJava.locale == null) {
+ var loc = null;
+
+ if (loc == null) try {
+ loc = navigator.userLanguage;
+ } catch (err) { }
+
+ if (loc == null) try {
+ loc = navigator.systemLanguage;
+ } catch (err) { }
+
+ if (loc == null) try {
+ loc = navigator.language;
+ } catch (err) { }
+
+ if (loc != null) {
+ loc.replace("-","_")
+ deployJava.locale = loc;
+ }
+ }
+ }
+
+};
+deployJava.do_initialize();
+
diff --git a/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java b/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java
new file mode 100644
index 00000000..cd321c71
--- /dev/null
+++ b/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java
@@ -0,0 +1,362 @@
+/*
+* 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.
+*/
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package at.gv.egiz.stal.service;
+
+import at.gv.egiz.stal.service.impl.STALRequestBrokerImpl;
+import at.gv.egiz.stal.service.impl.RequestBrokerSTALFactory;
+import at.gv.egiz.stal.service.impl.STALRequestBroker;
+import at.gv.egiz.stal.ErrorResponse;
+import at.gv.egiz.stal.HashDataInputCallback;
+import at.gv.egiz.stal.InfoboxReadRequest;
+import at.gv.egiz.stal.InfoboxReadResponse;
+import at.gv.egiz.stal.QuitRequest;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.SignResponse;
+import at.gv.egiz.stal.SignRequest;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author clemens
+ */
+public class STALRequestBrokerTest {
+
+ private static final Log log = LogFactory.getLog(STALRequestBrokerTest.class);
+ protected static STALRequestBroker stal;
+
+ @BeforeClass
+ public static void setUp() {
+ RequestBrokerSTALFactory fac = new RequestBrokerSTALFactory();
+ stal = (STALRequestBrokerImpl) fac.createSTAL();
+ log.debug("Created STAL " + stal.getClass().getName());
+ }
+
+ @Ignore
+ public void testInfoboxRead() {
+// try {
+
+ log.debug("*************** test ReadInfoboxRequest for two infoboxes");
+ List<STALRequest> requests = new ArrayList<STALRequest>();
+ InfoboxReadRequest r1 = new InfoboxReadRequest();
+ r1.setInfoboxIdentifier("infobox1");
+ requests.add(r1);
+ InfoboxReadRequest r2 = new InfoboxReadRequest();
+ r2.setInfoboxIdentifier("infobox2");
+ requests.add(r2);
+
+ BindingProcessorSimulator bp = new BindingProcessorSimulator();
+ bp.setRequests(Collections.singletonList(requests));
+
+ new Thread(bp, "BindingProcessor").start();
+ new Thread(new ServiceSimulator(), "STALService").start();
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ log.error("interrupted: " + ex.getMessage());
+ }
+ }
+
+ @Ignore
+ public void testSign() {
+ log.debug("**************** test SignRequest");
+ List<STALRequest> requests = new ArrayList<STALRequest>();
+ SignRequest r1 = new SignRequest();
+ r1.setKeyIdentifier("keybox1");
+ r1.setSignedInfo("1234".getBytes());
+ r1.setHashDataInput(new HashDataInputCallback() {
+
+ @Override
+ public InputStream getHashDataInput(String referenceId) {
+ return new ByteArrayInputStream("hashdatainput1234".getBytes());
+ }
+ });
+ requests.add(r1);
+
+ BindingProcessorSimulator bp = new BindingProcessorSimulator();
+ bp.setRequests(Collections.singletonList(requests));
+
+ new Thread(bp, "BindingProcessor").start();
+// new Thread(bp2, "BindingProcessor2").start();
+ new Thread(new ServiceSimulator(), "STALService").start();
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ log.error("interrupted: " + ex.getMessage());
+ }
+ }
+
+ @Ignore
+ public void testResponseTimeout() {
+ log.debug("**************** test SignRequest with responses timeout");
+ List<STALRequest> requests = new ArrayList<STALRequest>();
+ SignRequest r1 = new SignRequest();
+ r1.setKeyIdentifier("keybox1");
+ r1.setSignedInfo("1234".getBytes());
+ r1.setHashDataInput(new HashDataInputCallback() {
+
+ @Override
+ public InputStream getHashDataInput(String referenceId) {
+ return new ByteArrayInputStream("hashdatainput1234".getBytes());
+ }
+ });
+ requests.add(r1);
+
+ BindingProcessorSimulator bp = new BindingProcessorSimulator();
+ bp.setRequests(Collections.singletonList(requests));
+
+ new Thread(bp, "BindingProcessor").start();
+ new Thread(new TimeoutServiceSimulator(), "STALService").start();
+
+ try {
+ Thread.sleep(STALRequestBroker.TIMEOUT_MS + 1);
+ } catch (InterruptedException ex) {
+ log.error("interrupted: " + ex.getMessage());
+ }
+ }
+
+ @Ignore
+ public void testRequestTimeout() {
+ log.debug("**************** test requests timeout");
+ TimeoutBindingProcessorSimulator bp = new TimeoutBindingProcessorSimulator();
+
+ new Thread(bp, "BindingProcessor").start();
+ new Thread(new ServiceSimulator(), "STALService").start();
+
+ try {
+ Thread.sleep(STALRequestBroker.TIMEOUT_MS + 1);
+ } catch (InterruptedException ex) {
+ log.error("interrupted: " + ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testMultipleServices() {
+ log.debug("**************** test multiple SignRequests");
+ List<STALRequest> requests = new ArrayList<STALRequest>();
+ SignRequest r1 = new SignRequest();
+ r1.setKeyIdentifier("keybox1");
+ r1.setSignedInfo("1234".getBytes());
+ r1.setHashDataInput(new HashDataInputCallback() {
+
+ @Override
+ public InputStream getHashDataInput(String referenceId) {
+ return new ByteArrayInputStream("hashdatainput1234".getBytes());
+ }
+ });
+ requests.add(r1);
+
+ List<STALRequest> requests2 = new ArrayList<STALRequest>();
+ SignRequest r2 = new SignRequest();
+ r2.setKeyIdentifier("keybox2");
+ r2.setSignedInfo("6789".getBytes());
+ r2.setHashDataInput(new HashDataInputCallback() {
+
+ @Override
+ public InputStream getHashDataInput(String referenceId) {
+ return new ByteArrayInputStream("hashdatainput6789".getBytes());
+ }
+ });
+ requests2.add(r2);
+
+ BindingProcessorSimulator bp = new BindingProcessorSimulator();
+ List<List<STALRequest>> requestList = new ArrayList<List<STALRequest>>();
+ requestList.add(requests);
+ requestList.add(requests2);
+ bp.setRequests(requestList);
+
+ new Thread(bp, "BindingProcessor").start();
+// new Thread(bp2, "BindingProcessor2").start();
+ new Thread(new ServiceSimulator(), "STALService1").start();
+ new Thread(new ServiceSimulator(), "STALService2").start();
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ log.error("interrupted: " + ex.getMessage());
+ }
+ }
+
+ class ServiceSimulator implements Runnable {
+
+ @Override
+ public void run() {
+ try {
+ // first call w/ empty response list
+ log.debug("calling stal.nextRequest");
+ List<STALRequest> requests = stal.nextRequest(null); //new ArrayList<ResponseType>());
+ log.debug("got " + requests.size() + " requests. processing...");
+ Thread.sleep(1);
+ List<STALResponse> responses = new ArrayList<STALResponse>();
+ for (STALRequest request : requests) {
+ if (request instanceof InfoboxReadRequest) {
+ InfoboxReadResponse r = new InfoboxReadResponse();
+ r.setInfoboxValue("dummyInfobox".getBytes());
+ responses.add(r);
+ } else if (request instanceof SignRequest) {
+
+ log.debug("calling stal.getCurrentHashDataInputCallback");
+ HashDataInputCallback cb = stal.getHashDataInput();
+ assertNotNull(cb);
+ InputStream hd = cb.getHashDataInput("1234");
+ byte[] data = new byte[hd.available()];
+ hd.read(data);
+ log.debug("got HashDataInput " + new String(data));
+
+
+ SignResponse r = new SignResponse();
+ r.setSignatureValue("dummySignature".getBytes());
+ responses.add(r);
+ } else if (request instanceof QuitRequest) {
+ log.debug("received UNEXPECTED QUIT request");
+ return;
+ }
+ }
+
+// if (requests.size() > 0) {
+// log.debug("calling stal.setResponse with " + requests.size() + " responses");
+// stal.setResponse(responses);
+// }
+ log.debug("calling stal.nextRequest with " + responses.size() + " responses");
+ requests = stal.nextRequest(responses);
+ for (STALRequest request : requests) {
+ if (request instanceof QuitRequest) {
+ log.debug("got QUIT request");
+ } else {
+ log.debug("expected QUIT request, got " + request.getClass().getName());
+ }
+ }
+ } catch (IOException ex) {
+ log.error(ex.getMessage());
+ } catch (InterruptedException ex) {
+ log.error(ex.getMessage());
+ }
+ }
+ }
+
+ class TimeoutServiceSimulator implements Runnable {
+
+ @Override
+ public void run() {
+ try {
+ // first call w/ empty response list
+ log.debug("calling stal.nextRequest");
+ List<STALRequest> requests = stal.nextRequest(null); //new ArrayList<ResponseType>());
+ log.debug("got " + requests.size() + " requests. processing...");
+ Thread.sleep(1);
+ for (STALRequest request : requests) {
+// if (request instanceof InfoboxReadRequest) {
+ if (request instanceof SignRequest) {
+ log.debug("calling stal.getCurrentHashDataInputCallback");
+ HashDataInputCallback cb = stal.getHashDataInput();
+ assertNotNull(cb);
+ InputStream hd = cb.getHashDataInput("1234");
+ byte[] data = new byte[hd.available()];
+ hd.read(data);
+ log.debug("got HashDataInput " + new String(data));
+ } else if (request instanceof QuitRequest) {
+ log.debug("received UNEXPECTED QUIT requests");
+ return;
+ }
+ }
+ log.debug("simulating timeout ...");
+ } catch (IOException ex) {
+ log.error(ex.getMessage());
+ } catch (InterruptedException ex) {
+ log.error(ex.getMessage());
+ }
+ }
+ }
+
+ class BindingProcessorSimulator implements Runnable {
+
+ List<List<STALRequest>> requestsLists;
+
+ public void setRequests(List<List<STALRequest>> requests) {
+ this.requestsLists = requests;
+ }
+
+ @Override
+ public void run() {
+
+ //simulate SLCommand execution
+ for (List<STALRequest> requests : requestsLists) {
+ execSLCommand(requests);
+
+ log.debug("SLCommand finished, calling stal.handleReqeusts(QUIT)");
+ stal.handleRequest(Collections.singletonList((STALRequest) new QuitRequest()));
+ log.debug("QUIT returned (waiting for applet reload)");
+ }
+
+ }
+
+ public void execSLCommand(List<STALRequest> requests) {
+ int numReq = requests.size();
+ log.debug("SLCommand calling stal.handleRequests " + numReq + " requests");
+ List<STALResponse> responses = stal.handleRequest(requests);
+ assertEquals(numReq, responses.size());
+ for (int i = 0; i < numReq; i++) {
+ STALRequest request = requests.get(i);
+ STALResponse response = responses.get(i);
+
+ if (response instanceof ErrorResponse) {
+ log.warn("SLCommand received unexpected error response from STAL: " + ((ErrorResponse) response).getErrorCode());
+ } else if (request instanceof InfoboxReadRequest) {
+ assertTrue(response instanceof InfoboxReadResponse);
+ String infobox = new String(((InfoboxReadResponse) response).getInfoboxValue());
+ log.debug("SLCommand received expected InfoboxReadResponse from STAL: " + infobox);
+ } else if (request instanceof SignRequest) {
+ assertTrue(response instanceof SignResponse);
+ String signVal = new String(((SignResponse) response).getSignatureValue());
+ log.debug("SLCommand received expected SignResponse from STAL: " + signVal);
+ } else {
+ log.error("***** RequestType: " + request.getClass() + " TODO");
+ }
+ //TODO
+ }
+
+ }
+ }
+
+ class TimeoutBindingProcessorSimulator implements Runnable {
+
+ @Override
+ public void run() {
+
+ //simulate SLCommand execution
+ log.debug("simulating timeout ...");
+ }
+ }
+}