From adc58a6ecb2d3d5bb0dc17f0e4a7a0e7803ebbb1 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 19 Jun 2020 10:28:58 +0200 Subject: activates HSM-Facade, if HSM-Facade-Provider is an already loaded Java Security-Provider --- .../test/credentials/EaafKeyStoreFactoryTest.java | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'eaaf_core_utils/src/test/java/at') diff --git a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/credentials/EaafKeyStoreFactoryTest.java b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/credentials/EaafKeyStoreFactoryTest.java index fc945fdd..6a24f6b4 100644 --- a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/credentials/EaafKeyStoreFactoryTest.java +++ b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/credentials/EaafKeyStoreFactoryTest.java @@ -4,6 +4,7 @@ import java.security.Key; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.Provider; +import java.security.Security; import java.security.cert.X509Certificate; import java.util.List; @@ -27,6 +28,7 @@ import com.google.common.base.Predicates; import com.google.common.base.Throwables; import com.google.common.collect.FluentIterable; +import at.asitplus.hsmfacade.provider.HsmFacadeProvider; import at.gv.egiz.eaaf.core.exception.EaafKeyAccessException; import at.gv.egiz.eaaf.core.exceptions.EaafConfigurationException; import at.gv.egiz.eaaf.core.exceptions.EaafException; @@ -73,7 +75,8 @@ public class EaafKeyStoreFactoryTest { @Before public void testSetup() { mapConfig.clearAllConfig(); - + Security.removeProvider(HsmFacadeProvider.getInstance().getName()); + } @Test @@ -434,6 +437,14 @@ public class EaafKeyStoreFactoryTest { Assert.assertNull("Provider is not null", key.getSecond()); } + + @Test + @DirtiesContext + public void hsmFacadeNoHostConfig() { + context.getBean(EaafKeyStoreFactory.class); + + } + @Test @DirtiesContext @@ -598,6 +609,17 @@ public class EaafKeyStoreFactoryTest { } + @Test + @DirtiesContext + public void hsmFacadeAlreadLoaded() { + HsmFacadeProvider provider = HsmFacadeProvider.getInstance(); + Security.addProvider(provider); + + final EaafKeyStoreFactory keyStoreFactory = context.getBean(EaafKeyStoreFactory.class); + Assert.assertTrue("HSM Facade state wrong", keyStoreFactory.isHsmFacadeInitialized()); + + } + @Test @DirtiesContext public void hsmFacadeKeyStoreNoKeyStoreName() { -- cgit v1.2.3