diff options
Diffstat (limited to 'src/main/java/at/gv/util/filter')
-rw-r--r-- | src/main/java/at/gv/util/filter/moaid/AbstractGenericMOAIDAuthenticationServlet.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/at/gv/util/filter/moaid/AbstractGenericMOAIDAuthenticationServlet.java b/src/main/java/at/gv/util/filter/moaid/AbstractGenericMOAIDAuthenticationServlet.java index f9edb35..21e7d97 100644 --- a/src/main/java/at/gv/util/filter/moaid/AbstractGenericMOAIDAuthenticationServlet.java +++ b/src/main/java/at/gv/util/filter/moaid/AbstractGenericMOAIDAuthenticationServlet.java @@ -41,6 +41,7 @@ import at.gv.util.WebAppUtil; import at.gv.util.client.moaid.MOAIDClient; import at.gv.util.client.moaid.MOAIDClientException; import at.gv.util.config.EgovUtilConfiguration; +import at.gv.util.ex.EgovUtilException; import at.gv.util.xsd.saml.assertion.AssertionType; import at.gv.util.xsd.saml.protocol.ResponseType; @@ -58,6 +59,7 @@ public abstract class AbstractGenericMOAIDAuthenticationServlet extends HttpServ private HttpServletResponse response = null; private final Logger log = LoggerFactory.getLogger(AbstractGenericMOAIDAuthenticationServlet.class); + private static MOAIDClient moaclient = null; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { @@ -108,14 +110,13 @@ public abstract class AbstractGenericMOAIDAuthenticationServlet extends HttpServ log.debug("SAMLArtifact = \"" + artifact + "\"."); AssertionType assertion = null; - try { - MOAIDClient client = new MOAIDClient(this.getConfiguration()); - ResponseType moaidResponse = client.sendGetAuthenticationDataRequest(this.getAuthDataURL(), artifact); + try { + ResponseType moaidResponse = getMOAIDClient().sendGetAuthenticationDataRequest(this.getAuthDataURL(), artifact); if (!"Success".equals(moaidResponse.getStatus().getStatusCode().getValue().getLocalPart())) { throw new MOAIDClientException("Wrong MOA-ID return code: " + moaidResponse.getStatus().getStatusCode().getValue().toString()); } assertion = moaidResponse.getAssertion().get(0); - } catch (MOAIDClientException c) { + } catch (MOAIDClientException | EgovUtilException c) { String em = "Error retrieving authentication data (" + c.getMessage() + ")."; log.error(em); this.errorPage(request, response, em); @@ -211,6 +212,13 @@ public abstract class AbstractGenericMOAIDAuthenticationServlet extends HttpServ } } + private synchronized MOAIDClient getMOAIDClient() throws MOAIDClientException, EgovUtilException { + if (moaclient == null) + moaclient = new MOAIDClient(this.getConfiguration()); + + return moaclient; + } + public HttpServletRequest getRequest() { return request; } |