Search in sources :

Example 16 with OptionsParameter

use of org.nhindirect.stagent.options.OptionsParameter in project nhin-d by DirectProject.

the class CRLRevocationManager_initCRLCacheLocationTest method testInitCRLCacheLocation_locExistsAndNotADirectory.

public void testInitCRLCacheLocation_locExistsAndNotADirectory() throws Exception {
    String crlLocation = UUID.randomUUID().toString();
    File createFile = new File("target/" + crlLocation);
    createFile.createNewFile();
    OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.CRL_CACHE_LOCATION, "target/" + crlLocation));
    CRLRevocationManager.initCRLCacheLocation();
    assertNull(CRLRevocationManager.crlCacheLocation);
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter) File(java.io.File)

Example 17 with OptionsParameter

use of org.nhindirect.stagent.options.OptionsParameter in project nhin-d by DirectProject.

the class CRLRevocationManager_initCRLCacheLocationTest method tearDown.

@Override
public void tearDown() {
    CRLRevocationManager.getInstance().flush();
    OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.CRL_CACHE_LOCATION, ""));
    CRLRevocationManager.initCRLCacheLocation();
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter)

Example 18 with OptionsParameter

use of org.nhindirect.stagent.options.OptionsParameter in project nhin-d by DirectProject.

the class CryptoExtensions_registerJCEProvidersTest method testRegisterJCEProviders_singleValidConfiguredProvider_providerNotAlreadyRegistered.

public void testRegisterJCEProviders_singleValidConfiguredProvider_providerNotAlreadyRegistered() {
    Security.removeProvider("BC");
    OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.JCE_PROVIDER_CLASSES, "org.bouncycastle.jce.provider.BouncyCastleProvider"));
    assertNotNull(OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER_CLASSES));
    assertEquals("org.bouncycastle.jce.provider.BouncyCastleProvider", OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER_CLASSES).getParamValue());
    assertNull(Security.getProvider("BC"));
    CryptoExtensions.registerJCEProviders();
    assertNotNull(OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER_CLASSES));
    assertEquals("org.bouncycastle.jce.provider.BouncyCastleProvider", OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER_CLASSES).getParamValue());
    assertNotNull(Security.getProvider("BC"));
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter)

Example 19 with OptionsParameter

use of org.nhindirect.stagent.options.OptionsParameter in project nhin-d by DirectProject.

the class CryptoExtensions_registerJCEProvidersTest method testRegisterJCEProviders_multipleProviders_providerNotAlreadyRegistered.

public void testRegisterJCEProviders_multipleProviders_providerNotAlreadyRegistered() {
    Security.removeProvider("BC");
    Security.removeProvider("JunitMockProvider");
    OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.JCE_PROVIDER_CLASSES, "org.bouncycastle.jce.provider.BouncyCastleProvider,org.nhindirect.stagent.MockJCEProvider"));
    assertNotNull(OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER_CLASSES));
    assertEquals("org.bouncycastle.jce.provider.BouncyCastleProvider,org.nhindirect.stagent.MockJCEProvider", OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER_CLASSES).getParamValue());
    assertNull(Security.getProvider("BC"));
    assertNull(Security.getProvider("JunitMockProvider"));
    CryptoExtensions.registerJCEProviders();
    assertNotNull(OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER_CLASSES));
    assertEquals("org.bouncycastle.jce.provider.BouncyCastleProvider,org.nhindirect.stagent.MockJCEProvider", OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER_CLASSES).getParamValue());
    assertNotNull(Security.getProvider("BC"));
    assertNotNull(Security.getProvider("JunitMockProvider"));
    Security.removeProvider("JunitMockProvider");
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter)

Example 20 with OptionsParameter

use of org.nhindirect.stagent.options.OptionsParameter in project nhin-d by DirectProject.

the class CryptoExtensions_getJCEProviderNameForTypeAndAlgorithmTest method testGetJCEProviderNameForTypeAndAlgorithm_configuredJCENames_foundProvider_assertProviderName.

public void testGetJCEProviderNameForTypeAndAlgorithm_configuredJCENames_foundProvider_assertProviderName() {
    CryptoExtensions.registerJCEProviders();
    OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.JCE_PROVIDER, "BC"));
    assertNotNull(OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER));
    assertEquals("BC", OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER).getParamValue());
    assertEquals("BC", CryptoExtensions.getJCEProviderNameForTypeAndAlgorithm("CertPathValidator", "PKIX"));
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter)

Aggregations

OptionsParameter (org.nhindirect.stagent.options.OptionsParameter)30 DefaultNHINDAgent (org.nhindirect.stagent.DefaultNHINDAgent)5 CertificateResolver (org.nhindirect.stagent.cert.CertificateResolver)4 DefaultTrustAnchorResolver (org.nhindirect.stagent.trust.DefaultTrustAnchorResolver)4 File (java.io.File)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Provider (java.security.Provider)2 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)2 Module (com.google.inject.Module)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 CertificateException (java.security.cert.CertificateException)1 CertificateParsingException (java.security.cert.CertificateParsingException)1 MessagingException (javax.mail.MessagingException)1 MimeMessage (javax.mail.internet.MimeMessage)1 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)1 KeyStoreProtectionManager (org.nhindirect.common.crypto.KeyStoreProtectionManager)1 ServiceSecurityManager (org.nhindirect.common.rest.ServiceSecurityManager)1 ServiceException (org.nhindirect.common.rest.exceptions.ServiceException)1