From e165ef27812874bee7062a4e7ecc8bec99ced328 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Wed, 29 May 2019 09:49:02 +0200 Subject: Integrate MoaSig Verification into SignatureVerifier - Verify signature via ISignatureVerificationService. - Override System Property moa.spss.server.configuration via spring's environment (Reason: can configure path to moa SPSS config file via application.yaml & moa SPSS needs this parameter to find the config file) - Setup test configuration directory for moaspss in src/main/resources/moa-spss - Readme: Explain how to install moaspss' dependencies into local repository. --- pom.xml | 3 +- readme.md | 16 +++++ .../java/at/gv/egiz/moazs/config/MoaSigConfig.java | 29 +++++++++ .../at/gv/egiz/moazs/msg/SignatureVerifier.java | 31 ++++++++- src/main/resources/application.yaml | 5 ++ .../resources/moa-spss/MOASPSSConfiguration.xml | 73 ++++++++++++++++++++++ .../truststores/test-truststores/MZS_ROOT_CA.pem | 35 +++++++++++ 7 files changed, 188 insertions(+), 4 deletions(-) create mode 100644 src/main/java/at/gv/egiz/moazs/config/MoaSigConfig.java create mode 100644 src/main/resources/moa-spss/MOASPSSConfiguration.xml create mode 100644 src/main/resources/moa-spss/truststores/test-truststores/MZS_ROOT_CA.pem diff --git a/pom.xml b/pom.xml index ee3f5de..9d2d9c0 100644 --- a/pom.xml +++ b/pom.xml @@ -122,8 +122,7 @@ egovutils ${egovutils.version} - + at.gv.egiz.eaaf eaaf_module_moa-sig diff --git a/readme.md b/readme.md index 3bcb3d0..497088e 100644 --- a/readme.md +++ b/readme.md @@ -6,6 +6,22 @@ Some dependencies are not in the mvn central repo. You need to install those dependencies to your local maven repository with `mvn install`. Check `pom.xml` and follow the instructions. +## How to install `eaaf_module_moa-sig` + +``` +export EAAF_COMPONENTS_VERSION=1.0.7 +cd /path/to/working/dir +git clone https://gitlab.iaik.tugraz.at/egiz/eaaf_components/ +cd eaaf_components +git checkout $EAAF_COMPONENTS_VERSION +mvn package javadoc:jar sources:jar +mvn install:install-file -DgroupId=at.gv.egiz.eaaf -DartifactId=eaaf_module_moa-sig \ + -Dversion=$EAAF_COMPONENTS_VERSION -Dpackaging=jar \ + -Dfile=eaaf_modules/eaaf_module_moa-sig/target/eaaf_module_moa-sig-$EAAF_COMPONENTS_VERSION.jar \ + -Djavadoc=eaaf_modules/eaaf_module_moa-sig/target/eaaf_module_moa-sig-$EAAF_COMPONENTS_VERSION-javadoc.jar \ + -Dsources=eaaf_modules/eaaf_module_moa-sig/target/eaaf_module_moa-sig-$EAAF_COMPONENTS_VERSION-sources.jar +``` + ## Compile & Test ``` diff --git a/src/main/java/at/gv/egiz/moazs/config/MoaSigConfig.java b/src/main/java/at/gv/egiz/moazs/config/MoaSigConfig.java new file mode 100644 index 0000000..e96d851 --- /dev/null +++ b/src/main/java/at/gv/egiz/moazs/config/MoaSigConfig.java @@ -0,0 +1,29 @@ +package at.gv.egiz.moazs.config; + +import at.gv.egiz.eid.authhandler.modules.sigverify.moasig.api.ISignatureVerificationService; +import at.gv.egiz.eid.authhandler.modules.sigverify.moasig.impl.SignatureVerificationService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MoaSigConfig { + + private final String defaultTrustProfile; + + public MoaSigConfig(@Value("${moa.spss.server.default-trustprofile}") String defaultTrustProfile, + @Value("${moa.spss.server.configuration}") String serverConfigUrl) { + this.defaultTrustProfile = defaultTrustProfile; + System.getProperties().setProperty("moa.spss.server.configuration", serverConfigUrl); + } + + @Bean + public String moaSPSSServerDefaultTrustProfile() { + return defaultTrustProfile; + } + + @Bean + public ISignatureVerificationService moaSigVerifyService() { + return new SignatureVerificationService(); + } +} diff --git a/src/main/java/at/gv/egiz/moazs/msg/SignatureVerifier.java b/src/main/java/at/gv/egiz/moazs/msg/SignatureVerifier.java index 12b1ccb..d6311c4 100644 --- a/src/main/java/at/gv/egiz/moazs/msg/SignatureVerifier.java +++ b/src/main/java/at/gv/egiz/moazs/msg/SignatureVerifier.java @@ -1,13 +1,40 @@ package at.gv.egiz.moazs.msg; +import at.gv.egiz.eid.authhandler.modules.sigverify.moasig.api.ISignatureVerificationService; +import at.gv.egiz.eid.authhandler.modules.sigverify.moasig.exceptions.MOASigServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @Component public class SignatureVerifier { - public boolean verify(byte[] signedXMLdocument) { - return true; + private static final Logger log = LoggerFactory.getLogger(SignatureVerifier.class); + + @Autowired + @Qualifier("moaSigVerifyService") + private final ISignatureVerificationService service; + + @Autowired + @Qualifier("moaSPSSServerDefaultTrustProfile") + private final String trustProfile; + public SignatureVerifier(ISignatureVerificationService service, + String trustProfile) { + this.service = service; + this.trustProfile = trustProfile; + } + + public boolean verify(byte[] signedXMLdocument) { + try { + var response = service.verifyXMLSignature(signedXMLdocument, trustProfile); + return response != null; + } catch (MOASigServiceException e) { + log.error("Could not verify the XML signature.", e); + return false; + } } } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 1a432c2..61c7dba 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -70,3 +70,8 @@ logging: root: WARN org.springframework: WARN at.gv.egiz.moazs: INFO + +### moa spss config +moa.spss.server: + configuration: file:./moa-spss/MOASPSSConfiguration.xml + default-trustprofile: test-trustprofile diff --git a/src/main/resources/moa-spss/MOASPSSConfiguration.xml b/src/main/resources/moa-spss/MOASPSSConfiguration.xml new file mode 100644 index 0000000..edaaf8a --- /dev/null +++ b/src/main/resources/moa-spss/MOASPSSConfiguration.xml @@ -0,0 +1,73 @@ + + + + + + + 192.168 + + + + + + + + true + true + + + certstore + + + + + + pkix + + + CN=A-Trust-nQual-0,OU=A-Trust-nQual-0,O=A-Trust,C=AT + 536 + + chaining + + + + C=AT,O=Hauptverband österr. Sozialvers.,CN=Root-CA 1 + 376503867878755617282523408360935024869 + + chaining + + + + + test-trustprofile + truststores/test-truststore + + + + + false + 0 + + CRL + OCSP + + + false + 365 + + + jdbc:url + fully.qualified.classname + + + + + + + + SL20Authblock_v1.0 + profiles/SL20_authblock_v1.0.xml + + + diff --git a/src/main/resources/moa-spss/truststores/test-truststores/MZS_ROOT_CA.pem b/src/main/resources/moa-spss/truststores/test-truststores/MZS_ROOT_CA.pem new file mode 100644 index 0000000..57963bd --- /dev/null +++ b/src/main/resources/moa-spss/truststores/test-truststores/MZS_ROOT_CA.pem @@ -0,0 +1,35 @@ +-----BEGIN CERTIFICATE----- +MIIGGTCCBAGgAwIBAgIUEzQUFWuzrC0F4mODQYgPZ/Lhq04wDQYJKoZIhvcNAQEL +BQAwgZMxCzAJBgNVBAYTAkFUMRAwDgYDVQQIDAdBdXN0cmlhMQ0wCwYDVQQKDARJ +QUlLMQ0wCwYDVQQLDARFR0laMSMwIQYDVQQDDBpFR0laIENSQUJFTlNURUlORVIg +Uk9PVCBDQTEvMC0GCSqGSIb3DQEJARYgY2hyaXN0b2YucmFiZW5zdGVpbmVyQGVn +aXouZ3YuYXQwHhcNMTkwNDIzMTQwNTU2WhcNMzkwNDE4MTQwNTU2WjCBkzELMAkG +A1UEBhMCQVQxEDAOBgNVBAgMB0F1c3RyaWExDTALBgNVBAoMBElBSUsxDTALBgNV +BAsMBEVHSVoxIzAhBgNVBAMMGkVHSVogQ1JBQkVOU1RFSU5FUiBST09UIENBMS8w +LQYJKoZIhvcNAQkBFiBjaHJpc3RvZi5yYWJlbnN0ZWluZXJAZWdpei5ndi5hdDCC +AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMclj0pHf7LxLXEvtz+P7mxI +5U5Lx0xDiEY4XeLn75jis3IQotv3zmUz8Mvv9rkAT7y9JMJyJPBUPo2iWCO/dtm+ +qYlCy4fNPGvGPyjE05TM+JhG8bijpgO2EEZmKv48by+UUzioX8H/to5n8xNzDu8C +bibBddbGyfQ9E7PkR2VhdW8PkUrqJCxeG/xiwS0h1U2v++4ZKQpS78rj75KNEExx +t8spzZFyKV3i5mTkW2Exp5OSr07Spad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