aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/AuthDispatcherServlet.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/AuthDispatcherServlet.java')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/AuthDispatcherServlet.java53
1 files changed, 44 insertions, 9 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/AuthDispatcherServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/AuthDispatcherServlet.java
index 262854b50..e04600b42 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/AuthDispatcherServlet.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/AuthDispatcherServlet.java
@@ -17,9 +17,11 @@ import at.gv.egovernment.moa.id.auth.MOAIDAuthInitializer;
import at.gv.egovernment.moa.id.auth.WrongParametersException;
import at.gv.egovernment.moa.id.auth.servlet.AuthServlet;
import at.gv.egovernment.moa.id.moduls.AuthenticationManager;
+import at.gv.egovernment.moa.id.moduls.IAction;
import at.gv.egovernment.moa.id.moduls.IModulInfo;
import at.gv.egovernment.moa.id.moduls.IRequest;
import at.gv.egovernment.moa.id.moduls.ModulStorage;
+import at.gv.egovernment.moa.id.moduls.NoPassivAuthenticationException;
import at.gv.egovernment.moa.id.moduls.ServletInfo;
import at.gv.egovernment.moa.id.moduls.ServletType;
import at.gv.egovernment.moa.id.util.MOAIDMessageProvider;
@@ -34,7 +36,7 @@ public class AuthDispatcherServlet extends AuthServlet {
public static final String PARAM_TARGET_PATH = "mod";
public static final String PARAM_TARGET_PROTOCOL = "action";
- public static final String PARAM_DISPATCHER_TARGETS = "DispatcherTargets";
+/* public static final String PARAM_DISPATCHER_TARGETS = "DispatcherTargets";
public static final String PARAM_DISPATCHER_TYPE = "DispatcherType";
public static final String PARAM_DISPATCHER_TYPE_UNAUTH = "UNAUTH";
public static final String PARAM_DISPATCHER_TYPE_AUTH = "AUTH";
@@ -103,7 +105,7 @@ public class AuthDispatcherServlet extends AuthServlet {
+ modulInfo.getClass().getName() + " FAILED!!", e);
}
}
-
+*/
@Override
public void init(ServletConfig config) throws ServletException {
try {
@@ -118,7 +120,7 @@ public class AuthDispatcherServlet extends AuthServlet {
throw new ServletException(ex);
}
Logger.info("Auth dispatcher Servlet initialization");
-
+/*
List<IModulInfo> modules = ModulStorage.getAllModules();
Iterator<IModulInfo> it = modules.iterator();
while (it.hasNext()) {
@@ -130,7 +132,7 @@ public class AuthDispatcherServlet extends AuthServlet {
Logger.error("Registering Class " + targetClass + " FAILED!!",
e);
}
- }
+ }*/
}
protected void processRequest(HttpServletRequest req,
@@ -160,23 +162,49 @@ public class AuthDispatcherServlet extends AuthServlet {
}
Logger.debug("dispatching to " + path + " protocol " + protocol);
-
+/*
if (path != null && protocol != null
&& endpointMap.containsKey(path)) {
+
IModulInfo info = ModulStorage.getModuleByPath(path);
+
if (info == null) {
resp.sendError(HttpServletResponse.SC_NOT_FOUND);
Logger.error("Path " + path + " has no module registered");
return;
}
-
+
+ IAction action = info.getAction(protocol);
+
+ if (action == null) {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ Logger.error("Action " + protocol + " is not available!");
+ return;
+ }
+
+
+
+ try {
IRequest configuration = info.preProcess(req, resp, protocol);
+ if(configuration.forceAuth()) {
+ session.setAttribute(PARAM_TARGET_PATH, path);
+ session.setAttribute(PARAM_TARGET_PROTOCOL, protocol);
+
+ AuthenticationManager.doAuthentication(req, resp,
+ configuration);
+ return;
+ }
+
if (!AuthenticationManager.isAuthenticated(req, resp)) {
session.setAttribute(PARAM_TARGET_PATH, path);
session.setAttribute(PARAM_TARGET_PROTOCOL, protocol);
+ if(configuration.isPassiv()) {
+ throw new NoPassivAuthenticationException();
+ }
+
AuthenticationManager.doAuthentication(req, resp,
configuration);
return;
@@ -201,13 +229,20 @@ public class AuthDispatcherServlet extends AuthServlet {
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
- }
+ }
+ catch (Throwable e) {
+ // Try handle module specific, if not possible rethrow
+ if(!info.generateErrorMessage(e, req, resp)) {
+ throw e;
+ }
+ }
+ }*/
resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- } catch (WrongParametersException ex) {
+ }/* catch (WrongParametersException ex) {
handleWrongParameters(ex, req, resp);
} catch (MOAIDException ex) {
handleError(null, ex, req, resp);
- } catch (Throwable e) {
+ } */catch (Throwable e) {
e.printStackTrace();
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}