From 5d1c16bc384b6b16e87a90df980f2b4d12dc4fe8 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 29 Jul 2021 15:25:40 +0200 Subject: catch possible NullPointerException because AuthnRequest can be null in case of an unknown token --- .../msproxyservice/protocol/EidasProxyServiceController.java | 7 +++++++ .../src/main/resources/messages/eidasproxy_messages.properties | 1 + .../idaustria/test/protocol/EidasProxyServiceControllerTest.java | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'eidas_modules/eidas_proxy-sevice') diff --git a/eidas_modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/protocol/EidasProxyServiceController.java b/eidas_modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/protocol/EidasProxyServiceController.java index 56b34257..0316d434 100644 --- a/eidas_modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/protocol/EidasProxyServiceController.java +++ b/eidas_modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/protocol/EidasProxyServiceController.java @@ -72,6 +72,7 @@ public class EidasProxyServiceController extends AbstractController implements I private static final String ERROR_08 = "eidas.proxyservice.08"; private static final String ERROR_09 = "eidas.proxyservice.09"; private static final String ERROR_10 = "eidas.proxyservice.10"; + private static final String ERROR_11 = "eidas.proxyservice.11"; public static final String PROTOCOL_ID = "eidasProxy"; @@ -115,6 +116,12 @@ public class EidasProxyServiceController extends AbstractController implements I final ILightRequest eidasRequest = specificProxyCommunicationService.getAndRemoveRequest( tokenBase64, ImmutableSortedSet.copyOf(attrRegistry.getCoreAttributeRegistry().getAttributes())); + if (eidasRequest == null) { + log.info("Find no eIDAS Authn. Request with stated token."); + throw new EidasProxyServiceException(ERROR_11, null); + + } + log.debug("Received eIDAS auth. request from: {}, Initializing authentication environment ... ", eidasRequest.getSpCountryCode() != null ? eidasRequest.getSpCountryCode() : "'missing SP-country'"); log.trace("Received eIDAS requst: {}", eidasRequest); diff --git a/eidas_modules/eidas_proxy-sevice/src/main/resources/messages/eidasproxy_messages.properties b/eidas_modules/eidas_proxy-sevice/src/main/resources/messages/eidasproxy_messages.properties index b934ad56..3f92d58a 100644 --- a/eidas_modules/eidas_proxy-sevice/src/main/resources/messages/eidasproxy_messages.properties +++ b/eidas_modules/eidas_proxy-sevice/src/main/resources/messages/eidasproxy_messages.properties @@ -8,6 +8,7 @@ eidas.proxyservice.07=Can not determine eIDAS-Connector CountryCode. Authenticat eidas.proxyservice.08=Validation of eIDAS Authn request failed. Reason: Legal person and natural person can not be requested at once. eidas.proxyservice.09=eIDAS authentication not possible, because legal person is requested but mandates are disabled in general eidas.proxyservice.10=eIDAS authentication not possible, because legal person is requested but not mandate profiles are defined +eidas.proxyservice.11=No Authentication request with stated communication token. eidas.proxyservice.99=Internal error during eIDAS Proxy-Service authentication \ No newline at end of file diff --git a/eidas_modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/protocol/EidasProxyServiceControllerTest.java b/eidas_modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/protocol/EidasProxyServiceControllerTest.java index 24b69ef4..bea8db98 100644 --- a/eidas_modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/protocol/EidasProxyServiceControllerTest.java +++ b/eidas_modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/protocol/EidasProxyServiceControllerTest.java @@ -173,7 +173,7 @@ public class EidasProxyServiceControllerTest { //validate state EidasProxyServiceException exception = assertThrows(EidasProxyServiceException.class, () -> controller.receiveEidasAuthnRequest(httpReq, httpResp)); - Assert.assertEquals("wrong errorCode", "eidas.proxyservice.01", exception.getErrorId()); + Assert.assertEquals("wrong errorCode", "eidas.proxyservice.11", exception.getErrorId()); } -- cgit v1.2.3