diff options
Diffstat (limited to 'BKUOnline/src/main/java')
3 files changed, 104 insertions, 2 deletions
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java index 20320d8e..544bbc99 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java +++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java @@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFactory; import at.gv.egiz.bku.binding.HTTPBindingProcessor; import at.gv.egiz.bku.binding.HttpUtil; +import at.gv.egiz.bku.binding.IdFactory; import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage; /** @@ -51,7 +52,8 @@ public class BKURequestHandler extends SpringBKUServlet { log.debug("Using locale: " + locale); HttpSession session = req.getSession(); if (session != null) { - session.invalidate(); + log.warn("Already a session with id: "+session.getId()+ " active, deleting this one"); + getBindingProcessorManager().removeBindingProcessor(IdFactory.getInstance().createId(session.getId())); } String id = req.getSession(true).getId(); log.debug("Using session id: " + id); diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java new file mode 100644 index 00000000..59766586 --- /dev/null +++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java @@ -0,0 +1,96 @@ +package at.gv.egiz.bku.online.webapp;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.List;
+
+import javax.servlet.ServletException;
+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.BindingProcessor;
+import at.gv.egiz.bku.binding.Id;
+import at.gv.egiz.bku.binding.IdFactory;
+import at.gv.egiz.bku.slexceptions.SLRuntimeException;
+import at.gv.egiz.bku.utils.StreamUtil;
+import at.gv.egiz.stal.HashDataInput;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.service.impl.STALRequestBroker;
+import at.gv.egiz.stal.service.impl.STALRequestBrokerImpl;
+import at.gv.egiz.stal.service.impl.STALServiceImpl;
+
+public class HashDataInputServlet extends SpringBKUServlet {
+
+ private static Log log = LogFactory.getLog(HashDataInputServlet.class);
+
+ public HashDataInputServlet() {
+ }
+
+ private STALRequestBroker getSTAL(Id id) {
+ BindingProcessor bp = getBindingProcessorManager().getBindingProcessor(id);
+ if (bp == null) {
+ return null;
+ }
+ STAL stal = bp.getSTAL();
+ if (stal instanceof STALRequestBroker) {
+ return (STALRequestBroker) stal;
+ } else {
+ throw new SLRuntimeException("Unexpected STAL type");
+ }
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ if ((req.getSession() == null) && (req.getSession().getId() != null)) {
+ log.warn("Got request for hashdatainput without session info");
+ resp.sendRedirect("expired.html");
+ return;
+ }
+ Id sessionId = IdFactory.getInstance().createId(req.getSession().getId());
+ log.debug("Got request for hashdata for session " + sessionId);
+ STALRequestBroker rb = getSTAL(sessionId);
+ if (rb == null) {
+ log.info("STAL instance not found for session: " + sessionId);
+ resp.sendRedirect("expired.html");
+ return;
+ }
+ List<HashDataInput> hdi = rb.getHashDataInput();
+ log.debug("Got hashdata list with " + hdi.size() + " entries");
+ String param = req.getParameter("number");
+ int num = 0;
+ if (param != null) {
+ log.debug("Got request for hashdata#" + num);
+ num = Integer.parseInt(param);
+ }
+ if ((hdi.size() <= num) || (num < 0)){
+ log.warn("Requested hashdatainput exceeds listsize");
+ resp.sendError(-1);
+ return;
+ }
+ resp.setCharacterEncoding(req.getCharacterEncoding());
+ resp.setContentType(hdi.get(num).getMimeType());
+ String charSet = req.getCharacterEncoding();
+ if (charSet == null) {
+ charSet = "UTF-8";
+ }
+ Reader r = new InputStreamReader(hdi.get(num).getHashDataInput(), charSet);
+ Writer w = new OutputStreamWriter(resp.getOutputStream(), charSet);
+ StreamUtil.copyStream(r, w);
+ w.close();
+ return;
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doGet(req, resp);
+ }
+
+}
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 index 4aa5130a..074aff2d 100644 --- 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 @@ -32,6 +32,7 @@ import at.gv.egiz.stal.service.types.QuitRequestType; import at.gv.egiz.stal.service.types.RequestType; import at.gv.egiz.stal.service.types.ResponseType; import at.gv.egiz.stal.service.types.SignRequestType; +import at.gv.egiz.stal.util.HashDataInputProxy; import at.gv.egiz.stal.util.STALTranslator; import java.util.ArrayList; import java.util.Collections; @@ -108,7 +109,10 @@ public class STALRequestBrokerImpl implements STALRequestBroker { req.setKeyIdentifier(((SignRequest) stalRequest).getKeyIdentifier()); req.setSignedInfo(((SignRequest) stalRequest).getSignedInfo()); requests.add(req); - hashDataInputs.addAll(((SignRequest) stalRequest).getHashDataInput()); + for (HashDataInput hdi : ((SignRequest) stalRequest).getHashDataInput()) { + hashDataInputs.add(new HashDataInputProxy(hdi)); + } + //hashDataInputs.addAll(((SignRequest) stalRequest).getHashDataInput()); break; } else if (stalRequest instanceof InfoboxReadRequest) { log.trace("Received InfoboxReadRequest"); |