diff options
Diffstat (limited to 'connector')
6 files changed, 57 insertions, 254 deletions
| diff --git a/connector/pom.xml b/connector/pom.xml index dff75c08..6f67091c 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -156,6 +156,7 @@        <groupId>at.gv.egiz.eaaf</groupId>        <artifactId>eaaf_module_pvp2_sp</artifactId>        <scope>test</scope> +      <type>test-jar</type>      </dependency>      <dependency>        <groupId>at.asitplus.eidas.ms_specific.modules</groupId> diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/AdresssucheController.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/AdresssucheController.java deleted file mode 100644 index b044e95e..00000000 --- a/connector/src/main/java/at/asitplus/eidas/specific/connector/controller/AdresssucheController.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright 2018 A-SIT Plus GmbH - * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, - * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "License"); - * You may not use this work except in compliance with the License. - * You may obtain a copy of the License at: - * https://joinup.ec.europa.eu/news/understanding-eupl-v12 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ - -package at.asitplus.eidas.specific.connector.controller; - -import at.asitplus.eidas.specific.connector.MsEidasNodeConstants; -import at.asitplus.eidas.specific.connector.gui.StaticGuiBuilderConfiguration; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrAddressSoapClient; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException; -import at.gv.bmi.namespace.zmr_su.zrm._20040201_.address.Adressdaten; -import at.gv.e_government.reference.namespace.persondata.de._20040201.PostAdresseTyp; -import at.gv.e_government.reference.namespace.persondata.de._20040201.ZustelladresseTyp; -import at.gv.egiz.eaaf.core.api.gui.ISpringMvcGuiFormBuilder; -import at.gv.egiz.eaaf.core.api.idp.IConfiguration; -import at.gv.egiz.eaaf.core.api.utils.IPendingRequestIdGenerationStrategy; -import at.gv.egiz.eaaf.core.exceptions.EaafException; -import at.gv.egiz.eaaf.core.exceptions.GuiBuildException; -import at.gv.egiz.eaaf.core.exceptions.PendingReqIdValidationException; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.builder.CompareToBuilder; -import org.jetbrains.annotations.NotNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ResourceLoader; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * Default process-engine signaling controller. - * - * @author tlenz - */ -@Controller -@Slf4j -public class AdresssucheController { - -  @Autowired -  private ISpringMvcGuiFormBuilder guiBuilder; - -  @Autowired -  private IConfiguration basicConfig; - -  @Autowired -  private ResourceLoader resourceLoader; - -  @Autowired -  private ZmrAddressSoapClient client; - -  @Autowired -  private IPendingRequestIdGenerationStrategy pendingReqGeneration; - -  /** -   * Show the "residency.html" directly. -   * TODO Remove this after testing. -   */ -  @RequestMapping(value = {"/test"}, method = {RequestMethod.GET}) -  public void test(HttpServletRequest request, HttpServletResponse response) throws GuiBuildException, EaafException { -    final StaticGuiBuilderConfiguration config = new StaticGuiBuilderConfiguration( -        basicConfig, -        "http://localhost:8080/ms_connector/", -        basicConfig.getBasicConfiguration(//TODO -            MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_TEMPLATES_RESIDENCY, -            MsEidasNodeConstants.TEMPLATE_HTML_RESIDENCY), -        MsEidasNodeConstants.ENDPOINT_RESIDENCY_INPUT, -        resourceLoader); -    config.putCustomParameter(null, "pendingid", pendingReqGeneration.generateExternalPendingRequestId()); -    guiBuilder.build(request, response, config, "Query Austrian residency"); -  } - -  /** -   * Show the "other_login_method.html" directly. -   * TODO Remove this after testing. -   */ -  @RequestMapping(value = {"/olm"}, method = {RequestMethod.GET}) -  public void otherloginmethod(HttpServletRequest request, HttpServletResponse response) throws GuiBuildException, -      EaafException { -    final StaticGuiBuilderConfiguration config = new StaticGuiBuilderConfiguration( -        basicConfig, -        "http://localhost:8080/ms_connector/", -        basicConfig.getBasicConfiguration(//TODO -            MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_TEMPLATES_OTHER_LOGIN_METHOD_SELECTION, -            MsEidasNodeConstants.TEMPLATE_HTML_OTHERLOGINMETHODS), -        MsEidasNodeConstants.ENDPOINT_OTHER_LOGIN_METHOD_SELECTION, -        resourceLoader); -    config.putCustomParameter(null, "pendingid", pendingReqGeneration.generateExternalPendingRequestId()); -    guiBuilder.build(request, response, config, "Other Login Method"); -  } - -  /** -   * Show the "country_selection.html" directly. -   * TODO Remove this after testing. -   */ -  @RequestMapping(value = {"/country"}, method = {RequestMethod.GET}) -  public void countryselection(HttpServletRequest request, HttpServletResponse response) throws GuiBuildException, -      EaafException { -    final StaticGuiBuilderConfiguration config = new StaticGuiBuilderConfiguration( -        basicConfig, -        "http://localhost:8080/ms_connector/", -        basicConfig.getBasicConfiguration(//TODO -            MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_TEMPLATES_CCSELECTION, -            MsEidasNodeConstants.TEMPLATE_HTML_COUNTRYSELECTION), -        MsEidasNodeConstants.ENDPOINT_COUNTRYSELECTION, -        resourceLoader); -    config.putCustomParameter(null, "pendingid", pendingReqGeneration.generateExternalPendingRequestId()); -    guiBuilder.build(request, response, config, "Country Selection"); -  } - -  /** -   * Performs search for addresses in ZMR. -   */ -  @RequestMapping(value = {"/residency/search"}, method = {RequestMethod.POST}) -  public ResponseEntity<AdresssucheResult> search(@RequestParam("postleitzahl") String postleitzahl, -                                                  @RequestParam("municipality") String municipality, -                                                  @RequestParam("village") String village, -                                                  @RequestParam("street") String street, -                                                  @RequestParam("number") String number, -                                                  @RequestParam("pendingid") String pendingId) { -    log.info("Search with '{}', '{}', '{}', '{}', '{}'", -        postleitzahl.replaceAll("[\r\n]", ""), -        municipality.replaceAll("[\r\n]", ""), -        village.replaceAll("[\r\n]", ""), -        street.replaceAll("[\r\n]", ""), -        number.replaceAll("[\r\n]", "")); -    try { -      pendingReqGeneration.validateAndGetPendingRequestId(pendingId); -    } catch (PendingReqIdValidationException e) { -      log.warn("Search with pendingId '{}' is not valid", pendingId.replaceAll("[\r\n]", "")); -      return ResponseEntity.badRequest().build(); -    } -    try { -      Adressdaten searchInput = buildSearchInput(postleitzahl, municipality, village, street, number); -      ZmrAddressSoapClient.AddressInfo searchOutput = client.searchAddress(searchInput); -      AdresssucheResult output = buildResponse(searchOutput); -      return ResponseEntity.ok(output); -    } catch (EidasSAuthenticationException e) { -      log.warn("Search failed", e); -      return ResponseEntity.badRequest().build(); -    } -  } - -  private AdresssucheResult buildResponse(ZmrAddressSoapClient.AddressInfo searchOutput) { -    if (searchOutput.getPersonResult().isEmpty()) { -      log.warn("No result from ZMR"); -      return new AdresssucheResult(Collections.emptyList(), 0); -    } -    log.info("Result level is {}", searchOutput.getLevel()); -    Set<AdresssucheOutput> result = searchOutput.getPersonResult().stream() -        .map(Adressdaten::getPostAdresse) -        .map(it -> new AdresssucheOutput(it.getPostleitzahl(), it.getGemeinde(), it.getOrtschaft(), -            it.getZustelladresse().getStrassenname(), it.getZustelladresse().getOrientierungsnummer())) -        .collect(Collectors.toSet()); -    // TODO Add configuration option for the limit of 30 -    List<AdresssucheOutput> sorted = result.stream().sorted().limit(30).collect(Collectors.toList()); -    return new AdresssucheResult(sorted, result.size()); -  } - -  private Adressdaten buildSearchInput(String postleitzahl, -                                       String municipality, -                                       String village, -                                       String street, -                                       String number) { -    PostAdresseTyp postAdresse = new PostAdresseTyp(); -    if (StringUtils.isNotBlank(postleitzahl)) { -      postAdresse.setPostleitzahl(postleitzahl); -    } -    if (StringUtils.isNotBlank(municipality)) { -      postAdresse.setGemeinde(municipality); -    } -    if (StringUtils.isNotBlank(village)) { -      postAdresse.setOrtschaft(village); -    } -    if (StringUtils.isNotBlank(street) || StringUtils.isNotBlank(number)) { -      ZustelladresseTyp zustelladresse = new ZustelladresseTyp(); -      if (StringUtils.isNotBlank(street)) { -        zustelladresse.setStrassenname(street); -      } -      if (StringUtils.isNotBlank(number)) { -        zustelladresse.setOrientierungsnummer(number); -      } -      postAdresse.setZustelladresse(zustelladresse); -    } -    Adressdaten searchInput = new Adressdaten(); -    searchInput.setPostAdresse(postAdresse); -    return searchInput; -  } - -  @Data -  @AllArgsConstructor -  public static class AdresssucheResult { -    private final Collection<AdresssucheOutput> results; -    private final int resultCount; -  } - -  @Data -  @AllArgsConstructor -  public static class AdresssucheOutput implements Comparable<AdresssucheOutput> { -    private final String postleitzahl; -    private final String municipality; -    private final String village; -    private final String street; -    private final String number; - -    @Override -    public int compareTo(@NotNull AdresssucheOutput o) { -      return new CompareToBuilder() -          .append(this.postleitzahl, o.postleitzahl) -          .append(this.municipality, o.municipality) -          .append(this.village, o.village) -          .append(this.street, o.street) -          .append(this.number, o.number) -          .toComparison(); -    } -  } - -} diff --git a/connector/src/main/resources/application.properties b/connector/src/main/resources/application.properties index bec125dc..0b36b103 100644 --- a/connector/src/main/resources/application.properties +++ b/connector/src/main/resources/application.properties @@ -112,6 +112,16 @@ eidas.ms.auth.eIDAS.szrclient.eidasbind.mds.inject=false  #eidas.ms.auth.eIDAS.zmrclient.req.update.reason.code=PERS_AENDERN  #eidas.ms.auth.eIDAS.zmrclient.req.update.reason.text=KITT for eIDAS Matching +# ERnP communication +#eidas.ms.auth.eIDAS.ernpclient.endpoint=http://localhost:1718/demoernp +#eidas.ms.auth.eIDAS.ernpclient.req.organisation.behoerdennr=jUnit123456 +#eidas.ms.auth.eIDAS.client.common.ssl.keyStore.type=jks +#eidas.ms.auth.eIDAS.client.common.ssl.keyStore.path=../keystore/junit_test.jks +#eidas.ms.auth.eIDAS.client.common.ssl.keyStore.password=password +#eidas.ms.auth.eIDAS.client.common.ssl.key.alias=meta +#eidas.ms.auth.eIDAS.client.common.ssl.key.password=password + +  #Raw eIDAS Id data storage diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java index 09d11a78..890d4b19 100644 --- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java +++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java @@ -97,9 +97,12 @@ import eu.eidas.auth.commons.tx.BinaryLightToken;  import eu.eidas.specificcommunication.SpecificCommunicationDefinitionBeanNames;  import eu.eidas.specificcommunication.exception.SpecificCommunicationException;  import eu.eidas.specificcommunication.protocol.SpecificCommunicationService; +import lombok.SneakyThrows;  import lombok.val;  import net.shibboleth.utilities.java.support.component.ComponentInitializationException;  import net.shibboleth.utilities.java.support.xml.XMLParserException; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer;  import szrservices.SZR;  import szrservices.SignContentEntry;  import szrservices.SignContentResponseType; @@ -136,15 +139,20 @@ public class FullStartUpAndProcessTest {    private SZR szrMock;    private ServicePort zmrClient; +  private static MockWebServer mockWebServer; +      private String cc;    private String givenName;    private String familyName;    private String dateOfBirth;    private String personalId; +  private String pseudonym;    private String vsz;    private String eidasBind; + +    /**     * jUnit class initializer.     * @throws InterruptedException In case of an error @@ -153,7 +161,8 @@ public class FullStartUpAndProcessTest {     *     */    @BeforeClass -  public static void classInitializer() throws InterruptedException, InitializationException, ComponentInitializationException { +  @SneakyThrows +  public static void classInitializer() {      final String current = new java.io.File(".").toURI().toString();      System.clearProperty("eidas.ms.configuration"); @@ -167,6 +176,10 @@ public class FullStartUpAndProcessTest {      EaafOpenSaml3xInitializer.eaafInitialize(); +    // start ERnP mockup WebServer +    mockWebServer = new MockWebServer(); +    mockWebServer.start(1718); +        }    /** @@ -175,7 +188,8 @@ public class FullStartUpAndProcessTest {     * @throws Exception In case of an error     */    @AfterClass -  public static void closeIgniteNode() throws Exception { +  @SneakyThrows +  public static void closeIgniteNode() {      System.out.println("Closiong Ignite Node ... ");      Ignition.stopAll(true); @@ -183,6 +197,9 @@ public class FullStartUpAndProcessTest {      final Field field = IgniteInstanceInitializerSpecificCommunication.class.getDeclaredField("instance");      field.setAccessible(true);      field.set(null, null); +     +    // shut-down ERnP mock-up WebServer +    mockWebServer.shutdown();    } @@ -210,7 +227,8 @@ public class FullStartUpAndProcessTest {      cc = RandomStringUtils.randomAlphabetic(2).toUpperCase(); -    personalId = cc + "/AT/" + RandomStringUtils.randomNumeric(64); +    pseudonym = RandomStringUtils.randomNumeric(64); +    personalId = cc + "/AT/" + pseudonym;      familyName = RandomStringUtils.randomAlphabetic(10);      givenName = RandomStringUtils.randomAlphabetic(10);      dateOfBirth = "2015-10-12"; @@ -357,9 +375,13 @@ public class FullStartUpAndProcessTest {      RequestContextHolder.resetRequestAttributes();      RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(eidasNodeRespReq, finalizeResp)); +    // inject ZMR, ERnP and SZR responses for matching      injectZmrResponse(); -    injectSzrResponse(); - +    injectSzrResponse();     +    mockWebServer.enqueue(new MockResponse().setResponseCode(200) +        .setBody("{}") // empty response because we simulate result from ZMR +        .setHeader("Content-Type", "application/json;charset=utf-8")); +          //excute eIDAS node response      eidasSignal.restoreEidasAuthProcess(eidasNodeRespReq, finalizeResp); @@ -454,7 +476,7 @@ public class FullStartUpAndProcessTest {      EidasIdentitaetErgebnisType eidasPersonalIdentifier = new EidasIdentitaetErgebnisType();      personInfo.getEidasIdentitaet().add(eidasPersonalIdentifier); -    eidasPersonalIdentifier.setEidasWert(personalId); +    eidasPersonalIdentifier.setEidasWert(pseudonym);      eidasPersonalIdentifier.setEidasArt(Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER);      eidasPersonalIdentifier.setStaatscode2(cc); diff --git a/connector/src/test/resources/config/junit_config_1_springboot.properties b/connector/src/test/resources/config/junit_config_1_springboot.properties index 3544c3a9..d3f0d136 100644 --- a/connector/src/test/resources/config/junit_config_1_springboot.properties +++ b/connector/src/test/resources/config/junit_config_1_springboot.properties @@ -55,6 +55,15 @@ eidas.ms.auth.eIDAS.zmrclient.ssl.trustStore.password=  eidas.ms.auth.eIDAS.zmrclient.req.organisation.behoerdennr=jUnit123456  eidas.ms.auth.eIDAS.zmrclient.req.update.reason.code=EIDAS-KITT +# ERnP communication +eidas.ms.auth.eIDAS.ernpclient.endpoint=http://localhost:1718/demoernp +eidas.ms.auth.eIDAS.ernpclient.req.organisation.behoerdennr=jUnit123456 +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.type=jks +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.path=keys/junit.jks +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.password=password +eidas.ms.auth.eIDAS.client.common.ssl.key.alias=meta +eidas.ms.auth.eIDAS.client.common.ssl.key.password=password +  ## PVP2 S-Profile end-point configuration diff --git a/connector/src/test/resources/config/junit_config_2_springboot.properties b/connector/src/test/resources/config/junit_config_2_springboot.properties index a67e387f..71a573e0 100644 --- a/connector/src/test/resources/config/junit_config_2_springboot.properties +++ b/connector/src/test/resources/config/junit_config_2_springboot.properties @@ -55,6 +55,15 @@ eidas.ms.auth.eIDAS.zmrclient.ssl.trustStore.password=  eidas.ms.auth.eIDAS.zmrclient.req.organisation.behoerdennr=jUnit123456  eidas.ms.auth.eIDAS.zmrclient.req.update.reason.code=EIDAS-KITT +# ERnP communication +eidas.ms.auth.eIDAS.ernpclient.endpoint=http://localhost:1718/demoernp +eidas.ms.auth.eIDAS.ernpclient.req.organisation.behoerdennr=jUnit123456 +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.type=jks +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.path=keys/junit.jks +eidas.ms.auth.eIDAS.client.common.ssl.keyStore.password=password +eidas.ms.auth.eIDAS.client.common.ssl.key.alias=meta +eidas.ms.auth.eIDAS.client.common.ssl.key.password=password +  ## PVP2 S-Profile end-point configuration  eidas.ms.pvp2.keystore.type=jks | 
