summaryrefslogtreecommitdiff
path: root/BKULocal/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'BKULocal/src/main/java/at/gv/egiz')
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSecureViewer.java21
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java25
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java61
3 files changed, 62 insertions, 45 deletions
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSecureViewer.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSecureViewer.java
index cbe5af7a..8f04d733 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSecureViewer.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSecureViewer.java
@@ -1,4 +1,19 @@
-
+/*
+ * 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.local.stal;
import at.gv.egiz.bku.slcommands.impl.DataObjectHashDataInput;
@@ -19,6 +34,10 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
public class LocalSecureViewer implements SecureViewer {
private static final Log log = LogFactory.getLog(LocalSignRequestHandler.class);
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
index 492b8a05..9ae1d9b9 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
@@ -16,39 +16,27 @@
*/
package at.gv.egiz.bku.local.stal;
-import at.gv.egiz.bku.smccstal.SecureViewer;
-import java.util.Collections;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import at.gv.egiz.bku.smccstal.SignRequestHandler;
-import at.gv.egiz.stal.HashDataInput;
+import at.gv.egiz.stal.ErrorResponse;
import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
import at.gv.egiz.stal.SignRequest;
-import at.gv.egiz.stal.impl.ByteArrayHashDataInput;
-import at.gv.egiz.stal.signedinfo.ReferenceType;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
/**
*
- * @author clemens
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
*/
public class LocalSignRequestHandler extends SignRequestHandler {
-// implements SecureViewer {
private static final Log log = LogFactory.getLog(LocalSignRequestHandler.class);
- protected LocalSecureViewer secureViewer;
-
public LocalSignRequestHandler(LocalSecureViewer secureViewer) {
super(secureViewer);
}
-
/**
* If the request is a SIGN request, it contains a list of DataObjectHashDataInput
* providing the pre-digested input stream (that can be obtained repeatedly) if
@@ -63,8 +51,13 @@ public class LocalSignRequestHandler extends SignRequestHandler {
if (request instanceof SignRequest) {
SignRequest signReq = (SignRequest) request;
- secureViewer.setDataToBeSigned(signReq.getHashDataInput());
+ ((LocalSecureViewer) secureViewer).setDataToBeSigned(signReq.getHashDataInput());
+ return super.handleRequest(request);
+ } else {
+ log.fatal("Got unexpected STAL request: " + request);
+ return new ErrorResponse(1000);
}
- return super.handleRequest(request);
+
+
}
}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java
index b39b4d02..be37488b 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java
@@ -23,14 +23,12 @@ import java.util.Locale;
import java.util.Map;
import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.HTTPBindingProcessor;
import at.gv.egiz.bku.binding.HttpUtil;
import at.gv.egiz.bku.conf.Configurator;
@@ -44,25 +42,32 @@ public class BKURequestHandler extends SpringBKUServlet {
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);
- HTTPBindingProcessor bindingProcessor;
- bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
- .createBindingProcessor(req.getRequestURL().toString(), null, 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));
- }
- }
- headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, req.getContentType() + ";"
- + req.getCharacterEncoding());
- bindingProcessor.setHTTPHeaders(headerMap);
- bindingProcessor.consumeRequestStream(req.getInputStream());
+
+ log.debug("Received SecurityLayer request");
+
+ String acceptLanguage = req.getHeader("Accept-Language");
+ Locale locale = AcceptLanguage.getLocale(acceptLanguage);
+ log.debug("Accept-Language locale: " + locale);
+
+ HTTPBindingProcessor bindingProcessor;
+ bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
+ .createBindingProcessor(req.getRequestURL().toString(), null, 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());
// fixxme just for testing
bindingProcessor.run();
@@ -84,13 +89,13 @@ public class BKURequestHandler extends SpringBKUServlet {
log.debug("Do not set siglayout header");
}
- if (configurator.getProperty(Configurator.USERAGENT_CONFIG_P) != null) {
- resp.setHeader(HttpUtil.HTTP_HEADER_SERVER, configurator
- .getProperty(Configurator.USERAGENT_CONFIG_P));
- } else {
- resp.setHeader(HttpUtil.HTTP_HEADER_SERVER,
- Configurator.USERAGENT_DEFAULT);
- }
+ if (configurator.getProperty(Configurator.USERAGENT_CONFIG_P) != null) {
+ resp.setHeader(HttpUtil.HTTP_HEADER_SERVER, configurator
+ .getProperty(Configurator.USERAGENT_CONFIG_P));
+ } else {
+ resp.setHeader(HttpUtil.HTTP_HEADER_SERVER,
+ Configurator.USERAGENT_DEFAULT);
+ }
resp.setContentType(bindingProcessor.getResultContentType());
resp.setCharacterEncoding(ENCODING);