aboutsummaryrefslogtreecommitdiff
path: root/id.server/src/at/gv/egovernment/moa/id/auth/servlet
diff options
context:
space:
mode:
authorrudolf <rudolf@d688527b-c9ab-4aba-bd8d-4036d912da1d>2003-12-19 09:00:07 +0000
committerrudolf <rudolf@d688527b-c9ab-4aba-bd8d-4036d912da1d>2003-12-19 09:00:07 +0000
commitb6e8e0a8f45c10d9a0cd77807db7107430752981 (patch)
treeff2bf15ff279f07166e472dbc2d29b5dcd013d73 /id.server/src/at/gv/egovernment/moa/id/auth/servlet
parentb2e2e48ad320dce63f471481cba305b1c95cd619 (diff)
downloadmoa-id-spss-b6e8e0a8f45c10d9a0cd77807db7107430752981.tar.gz
moa-id-spss-b6e8e0a8f45c10d9a0cd77807db7107430752981.tar.bz2
moa-id-spss-b6e8e0a8f45c10d9a0cd77807db7107430752981.zip
MOA-ID 1.1.1D01
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@81 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'id.server/src/at/gv/egovernment/moa/id/auth/servlet')
-rw-r--r--id.server/src/at/gv/egovernment/moa/id/auth/servlet/AuthServlet.java55
-rw-r--r--id.server/src/at/gv/egovernment/moa/id/auth/servlet/ConfigurationServlet.java8
-rw-r--r--id.server/src/at/gv/egovernment/moa/id/auth/servlet/SelectBKUServlet.java5
-rw-r--r--id.server/src/at/gv/egovernment/moa/id/auth/servlet/StartAuthenticationServlet.java3
-rw-r--r--id.server/src/at/gv/egovernment/moa/id/auth/servlet/VerifyAuthenticationBlockServlet.java11
-rw-r--r--id.server/src/at/gv/egovernment/moa/id/auth/servlet/VerifyIdentityLinkServlet.java10
6 files changed, 68 insertions, 24 deletions
diff --git a/id.server/src/at/gv/egovernment/moa/id/auth/servlet/AuthServlet.java b/id.server/src/at/gv/egovernment/moa/id/auth/servlet/AuthServlet.java
index 3a1cab4be..6ff52bc4a 100644
--- a/id.server/src/at/gv/egovernment/moa/id/auth/servlet/AuthServlet.java
+++ b/id.server/src/at/gv/egovernment/moa/id/auth/servlet/AuthServlet.java
@@ -7,6 +7,10 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -43,13 +47,29 @@ public class AuthServlet extends HttpServlet implements MOAIDAuthConstants {
protected void handleError(
String errorMessage, Throwable exceptionThrown, HttpServletRequest req, HttpServletResponse resp) {
- if (exceptionThrown != null)
- Logger.error(errorMessage, exceptionThrown);
- else
+
+ if(null != errorMessage) {
Logger.error(errorMessage);
- req.setAttribute("ErrorMessage", errorMessage);
- req.setAttribute("ExceptionThrown", exceptionThrown);
- resp.setStatus(500);
+ req.setAttribute("ErrorMessage", errorMessage );
+ }
+
+ if (null != exceptionThrown) {
+ if(null == errorMessage) errorMessage = exceptionThrown.getMessage();
+ Logger.error(errorMessage, exceptionThrown);
+ req.setAttribute("ExceptionThrown", exceptionThrown);
+ }
+
+ //forward this to errorpage.jsp wher the HTML error page is generated
+ ServletContext context = getServletContext();
+ RequestDispatcher dispatcher = context.getRequestDispatcher("/errorpage.jsp");
+ try {
+ dispatcher.forward(req, resp);
+ } catch (ServletException e) {
+ Logger.error(e);
+ } catch (IOException e) {
+ Logger.error(e);
+ }
+
}
/**
* Handles a <code>WrongParametersException</code>.
@@ -58,8 +78,18 @@ public class AuthServlet extends HttpServlet implements MOAIDAuthConstants {
*/
protected void handleWrongParameters(WrongParametersException ex, HttpServletRequest req, HttpServletResponse resp) {
Logger.error(ex.toString());
- req.setAttribute("WrongParameters", "true");
- resp.setStatus(500);
+ req.setAttribute("WrongParameters", ex.getMessage());
+
+ // forward this to errorpage.jsp where the HTML error page is generated
+ ServletContext context = getServletContext();
+ RequestDispatcher dispatcher = context.getRequestDispatcher("/errorpage.jsp");
+ try {
+ dispatcher.forward(req, resp);
+ } catch (ServletException e) {
+ Logger.error(e);
+ } catch (IOException e) {
+ Logger.error(e);
+ }
}
/**
@@ -114,4 +144,13 @@ public class AuthServlet extends HttpServlet implements MOAIDAuthConstants {
}
return bout.toString();
}
+
+ /**
+ * Calls the web application initializer.
+ *
+ * @see javax.servlet.Servlet#init(ServletConfig)
+ */
+ public void init(ServletConfig servletConfig) throws ServletException {
+ super.init(servletConfig);
+ }
}
diff --git a/id.server/src/at/gv/egovernment/moa/id/auth/servlet/ConfigurationServlet.java b/id.server/src/at/gv/egovernment/moa/id/auth/servlet/ConfigurationServlet.java
index 554819f73..1dc1897b2 100644
--- a/id.server/src/at/gv/egovernment/moa/id/auth/servlet/ConfigurationServlet.java
+++ b/id.server/src/at/gv/egovernment/moa/id/auth/servlet/ConfigurationServlet.java
@@ -2,6 +2,9 @@ package at.gv.egovernment.moa.id.auth.servlet;
import java.io.IOException;
import java.io.PrintWriter;
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -43,8 +46,11 @@ public class ConfigurationServlet extends HttpServlet {
try {
MOAIDAuthInitializer.initialized=false;
MOAIDAuthInitializer.initialize();
- String message = msg.getMessage("config.00", null);
+ String message = msg.getMessage("config.00", new Object[]
+ { DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.GERMAN).format(new Date())} );
+
Logger.info(message);
+ //TODO low-priority: change to ErrorPage
out.println("<p><b>");
out.println(message);
out.println("</b></p>");
diff --git a/id.server/src/at/gv/egovernment/moa/id/auth/servlet/SelectBKUServlet.java b/id.server/src/at/gv/egovernment/moa/id/auth/servlet/SelectBKUServlet.java
index 50ca21c69..422ddf0a3 100644
--- a/id.server/src/at/gv/egovernment/moa/id/auth/servlet/SelectBKUServlet.java
+++ b/id.server/src/at/gv/egovernment/moa/id/auth/servlet/SelectBKUServlet.java
@@ -35,6 +35,7 @@ public class SelectBKUServlet extends AuthServlet {
*/
public void init(ServletConfig servletConfig) throws ServletException {
try {
+ super.init(servletConfig);
MOAIDAuthInitializer.initialize();
Logger.info(MOAIDMessageProvider.getInstance().getMessage("init.00", null));
}
@@ -71,9 +72,9 @@ public class SelectBKUServlet extends AuthServlet {
String bkuSelectionType = AuthConfigurationProvider.getInstance().getBKUSelectionType();
if (bkuSelectionType.equals(AuthConfigurationProvider.BKU_SELECTION_TYPE_HTMLCOMPLETE)) {
// bkuSelectionType==HTMLComplete
- String redirectURL = returnValue;
+ String redirectURL = returnValue;
resp.sendRedirect(redirectURL);
- Logger.debug("REDIRECT TO: " + redirectURL);
+ Logger.info("REDIRECT TO: " + redirectURL);
}
else {
// bkuSelectionType==HTMLSelect
diff --git a/id.server/src/at/gv/egovernment/moa/id/auth/servlet/StartAuthenticationServlet.java b/id.server/src/at/gv/egovernment/moa/id/auth/servlet/StartAuthenticationServlet.java
index 2ea43935b..6308742bf 100644
--- a/id.server/src/at/gv/egovernment/moa/id/auth/servlet/StartAuthenticationServlet.java
+++ b/id.server/src/at/gv/egovernment/moa/id/auth/servlet/StartAuthenticationServlet.java
@@ -90,6 +90,7 @@ public class StartAuthenticationServlet extends AuthServlet {
*/
public void init(ServletConfig servletConfig) throws ServletException {
try {
+ super.init(servletConfig);
MOAIDAuthInitializer.initialize();
Logger.info(MOAIDMessageProvider.getInstance().getMessage("init.00", null));
}
@@ -97,6 +98,6 @@ public class StartAuthenticationServlet extends AuthServlet {
Logger.fatal(MOAIDMessageProvider.getInstance().getMessage("init.02", null), ex);
throw new ServletException(ex);
}
- }
+ }
}
diff --git a/id.server/src/at/gv/egovernment/moa/id/auth/servlet/VerifyAuthenticationBlockServlet.java b/id.server/src/at/gv/egovernment/moa/id/auth/servlet/VerifyAuthenticationBlockServlet.java
index 8d16f73dd..eda0c6726 100644
--- a/id.server/src/at/gv/egovernment/moa/id/auth/servlet/VerifyAuthenticationBlockServlet.java
+++ b/id.server/src/at/gv/egovernment/moa/id/auth/servlet/VerifyAuthenticationBlockServlet.java
@@ -10,7 +10,6 @@ import javax.servlet.http.HttpServletResponse;
import at.gv.egovernment.moa.id.MOAIDException;
import at.gv.egovernment.moa.id.auth.AuthenticationServer;
-import at.gv.egovernment.moa.id.auth.WrongParametersException;
import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;
import at.gv.egovernment.moa.logging.Logger;
@@ -70,8 +69,10 @@ public class VerifyAuthenticationBlockServlet extends AuthServlet {
Map parameters = getParameters(req);
String sessionID = req.getParameter(PARAM_SESSIONID);
String createXMLSignatureResponse = (String)parameters.get(PARAM_XMLRESPONSE);
- // debug output
- AuthenticationServer.debugOutputXMLFile("CreateXMLSignatureResponse.xml", createXMLSignatureResponse);
+
+ // debug XMLSignatureResponse from BKU
+ if(null != createXMLSignatureResponse)
+ AuthenticationServer.debugOutputXMLFile("CreateXMLSignatureResponse.xml", createXMLSignatureResponse);
try {
AuthenticationSession session = AuthenticationServer.getSession(sessionID);
String samlArtifactBase64 =
@@ -84,9 +85,7 @@ public class VerifyAuthenticationBlockServlet extends AuthServlet {
resp.addHeader("Location", redirectURL);
Logger.debug("REDIRECT TO: " + redirectURL);
}
- catch (WrongParametersException ex) {
- handleWrongParameters(ex, req, resp);
- }
+
catch (MOAIDException ex) {
handleError(null, ex, req, resp);
}
diff --git a/id.server/src/at/gv/egovernment/moa/id/auth/servlet/VerifyIdentityLinkServlet.java b/id.server/src/at/gv/egovernment/moa/id/auth/servlet/VerifyIdentityLinkServlet.java
index d3a28c7d4..55bce7af3 100644
--- a/id.server/src/at/gv/egovernment/moa/id/auth/servlet/VerifyIdentityLinkServlet.java
+++ b/id.server/src/at/gv/egovernment/moa/id/auth/servlet/VerifyIdentityLinkServlet.java
@@ -10,7 +10,6 @@ import javax.servlet.http.HttpServletResponse;
import at.gv.egovernment.moa.id.MOAIDException;
import at.gv.egovernment.moa.id.auth.AuthenticationServer;
-import at.gv.egovernment.moa.id.auth.WrongParametersException;
import at.gv.egovernment.moa.id.auth.builder.DataURLBuilder;
import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;
import at.gv.egovernment.moa.logging.Logger;
@@ -68,7 +67,8 @@ public class VerifyIdentityLinkServlet extends AuthServlet {
String sessionID = req.getParameter(PARAM_SESSIONID);
String infoboxReadResponse = (String)parameters.get(PARAM_XMLRESPONSE);
// debug output
- AuthenticationServer.debugOutputXMLFile("InfoboxReadResponse.xml", infoboxReadResponse);
+ if(null != infoboxReadResponse)
+ AuthenticationServer.debugOutputXMLFile("InfoboxReadResponse.xml", infoboxReadResponse);
try {
String createXMLSignatureRequest =
AuthenticationServer.getInstance().verifyIdentityLink(sessionID, infoboxReadResponse);
@@ -79,16 +79,14 @@ public class VerifyIdentityLinkServlet extends AuthServlet {
resp.addHeader("Location", dataURL);
resp.setContentType("text/xml");
// debug output
- AuthenticationServer.debugOutputXMLFile("CreateXMLSignatureRequest.xml", createXMLSignatureRequest);
+ if(null != createXMLSignatureRequest)
+ AuthenticationServer.debugOutputXMLFile("CreateXMLSignatureRequest.xml", createXMLSignatureRequest);
OutputStream out = resp.getOutputStream();
out.write(createXMLSignatureRequest.getBytes("UTF-8"));
out.flush();
out.close();
Logger.debug("Finished POST VerifyIdentityLink");
}
- catch (WrongParametersException ex) {
- handleWrongParameters(ex, req, resp);
- }
catch (MOAIDException ex) {
handleError(null, ex, req, resp);
}