Search in sources :

Example 1 with OptionsParameter

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

the class CRLRevocationManager method initCRLCacheLocation.

/**
     * Initializes the CRL cache location option
     */
protected static void initCRLCacheLocation() {
    // get the location from the OptionsManager.... if it doesn't exist, then set a default location
    // of CrlCache off the working directory
    final OptionsParameter param = OptionsManager.getInstance().getParameter(OptionsParameter.CRL_CACHE_LOCATION);
    final String cacheLoc = (param == null || param.getParamValue() == null || param.getParamValue().isEmpty()) ? DEFAULT_CRL_CACHE_LOCATION : param.getParamValue();
    // initialize the CRL cache location
    try {
        crlCacheLocation = new File(cacheLoc);
        if (crlCacheLocation.exists()) {
            // then log a warning and disable caching
            if (!crlCacheLocation.isDirectory()) {
                LOGGER.warn("Configured CRL cache location " + cacheLoc + " already exists and is not a directory. " + "CRL file caching will be disable");
                crlCacheLocation = null;
            }
        } else {
            // force the directory to be created
            FileUtils.forceMkdir(crlCacheLocation);
        }
    } catch (Throwable t) {
        LOGGER.warn("Failed to initialize CRL cache location " + cacheLoc + " CRL file caching will be disable", t);
        crlCacheLocation = null;
    }
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter) ASN1OctetString(org.bouncycastle.asn1.ASN1OctetString) File(java.io.File)

Example 2 with OptionsParameter

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

the class CryptoExtensions_getJCEProviderNameForTypeAndAlgorithmTest method testGetJCEProviderNameForTypeAndAlgorithm_configuredJCENames_algAndTypeNotFound_assertEmptyProviderName.

public void testGetJCEProviderNameForTypeAndAlgorithm_configuredJCENames_algAndTypeNotFound_assertEmptyProviderName() {
    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("", CryptoExtensions.getJCEProviderNameForTypeAndAlgorithm("doesnt matter", "doesnt matter"));
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter)

Example 3 with OptionsParameter

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

the class CryptoExtensions_getJCEProviderNameForTypeAndAlgorithmTest method testGetJCEProviderNameForTypeAndAlgorithm_nullConfiguredJCENames_assertEmptyBCProvider.

public void testGetJCEProviderNameForTypeAndAlgorithm_nullConfiguredJCENames_assertEmptyBCProvider() {
    CryptoExtensions.registerJCEProviders();
    OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.JCE_PROVIDER, null));
    assertNotNull(OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER));
    assertNull(OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER).getParamValue());
    assertEquals("", CryptoExtensions.getJCEProviderNameForTypeAndAlgorithm("doesnt matter", "doesnt matter"));
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter)

Example 4 with OptionsParameter

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

the class CryptoExtensions_getJCEProviderNameForTypeAndAlgorithmTest method testGetJCEProviderNameForTypeAndAlgorithm_multipConfiguredJCENames_foundProvider_assertProviderName.

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

Example 5 with OptionsParameter

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

the class CryptoExtensions_getJCEProviderNameForTypeAndAlgorithmTest method testGetJCEProviderNameForTypeAndAlgorithm_configuredJCENames_unknownProvider_assertEmptyProviderName.

public void testGetJCEProviderNameForTypeAndAlgorithm_configuredJCENames_unknownProvider_assertEmptyProviderName() {
    CryptoExtensions.registerJCEProviders();
    OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.JCE_PROVIDER, "dummy"));
    assertNotNull(OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER));
    assertEquals("dummy", OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER).getParamValue());
    assertEquals("", CryptoExtensions.getJCEProviderNameForTypeAndAlgorithm("doesnt matter", "doesnt matter"));
}
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