diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2019-03-08 08:05:07 +0100 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2019-03-08 08:05:07 +0100 |
commit | 32376822fd108ddd820a98b93135ef798c2510b6 (patch) | |
tree | 4348431428b19846ebaef05a9d8ca764619e5c93 /src/main/java/at/gv/util/filter | |
parent | c9e8cfcb370a94e0e741356ab5b16fd4cbfed0b4 (diff) | |
download | egovutils-32376822fd108ddd820a98b93135ef798c2510b6.tar.gz egovutils-32376822fd108ddd820a98b93135ef798c2510b6.tar.bz2 egovutils-32376822fd108ddd820a98b93135ef798c2510b6.zip |
update MOA-ID SAML1 client implementation
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; } |