Search in sources :

Example 1 with SSLConfig

use of org.apache.geode.internal.admin.SSLConfig in project geode by apache.

the class SSLConfigurationFactory method getSSLConfigForComponent.

public static SSLConfig getSSLConfigForComponent(SecurableCommunicationChannel sslEnabledComponent) {
    SSLConfig sslConfig = getInstance().getRegisteredSSLConfigForComponent(sslEnabledComponent);
    if (sslConfig == null) {
        sslConfig = getInstance().createSSLConfigForComponent(sslEnabledComponent);
        getInstance().registeredSSLConfigForComponent(sslEnabledComponent, sslConfig);
    }
    return sslConfig;
}
Also used : SSLConfig(org.apache.geode.internal.admin.SSLConfig)

Example 2 with SSLConfig

use of org.apache.geode.internal.admin.SSLConfig in project geode by apache.

the class SSLConfigurationFactory method createSSLConfigForComponent.

private SSLConfig createSSLConfigForComponent(final SecurableCommunicationChannel sslEnabledComponent) {
    SSLConfig sslConfig = createSSLConfig(sslEnabledComponent);
    SecurableCommunicationChannel[] sslEnabledComponents = getDistributionConfig().getSecurableCommunicationChannels();
    if (sslEnabledComponents.length == 0) {
        sslConfig = configureLegacyClusterSSL(sslConfig);
    }
    sslConfig.setSecurableCommunicationChannel(sslEnabledComponent);
    switch(sslEnabledComponent) {
        case ALL:
            {
                // Create a SSLConfig separate for HTTP Service. As the require-authentication might differ
                createSSLConfigForComponent(SecurableCommunicationChannel.WEB);
                break;
            }
        case CLUSTER:
            {
                if (sslEnabledComponents.length > 0) {
                    sslConfig = setAliasForComponent(sslConfig, getDistributionConfig().getClusterSSLAlias());
                } else {
                    sslConfig = configureLegacyClusterSSL(sslConfig);
                }
                break;
            }
        case LOCATOR:
            {
                if (sslEnabledComponents.length > 0) {
                    sslConfig = setAliasForComponent(sslConfig, getDistributionConfig().getLocatorSSLAlias());
                }
                break;
            }
        case SERVER:
            {
                if (sslEnabledComponents.length > 0) {
                    sslConfig = setAliasForComponent(sslConfig, getDistributionConfig().getServerSSLAlias());
                } else {
                    sslConfig = configureLegacyServerSSL(sslConfig);
                }
                break;
            }
        case GATEWAY:
            {
                if (sslEnabledComponents.length > 0) {
                    sslConfig = setAliasForComponent(sslConfig, getDistributionConfig().getGatewaySSLAlias());
                } else {
                    sslConfig = configureLegacyGatewaySSL(sslConfig);
                }
                break;
            }
        case WEB:
            {
                if (sslEnabledComponents.length > 0) {
                    sslConfig = setAliasForComponent(sslConfig, getDistributionConfig().getHTTPServiceSSLAlias());
                    sslConfig.setRequireAuth(getDistributionConfig().getSSLWebRequireAuthentication());
                } else {
                    sslConfig = configureLegacyHttpServiceSSL(sslConfig);
                }
                break;
            }
        case JMX:
            {
                if (sslEnabledComponents.length > 0) {
                    sslConfig = setAliasForComponent(sslConfig, getDistributionConfig().getJMXSSLAlias());
                } else {
                    sslConfig = configureLegacyJMXSSL(sslConfig);
                }
                break;
            }
    }
    configureSSLPropertiesFromSystemProperties(sslConfig);
    return sslConfig;
}
Also used : SSLConfig(org.apache.geode.internal.admin.SSLConfig) SecurableCommunicationChannel(org.apache.geode.internal.security.SecurableCommunicationChannel)

Example 3 with SSLConfig

use of org.apache.geode.internal.admin.SSLConfig in project geode by apache.

the class JettyHelper method main.

public static void main(final String... args) throws Exception {
    if (args.length > 1) {
        System.out.printf("Temporary Directory @ ($1%s)%n", USER_DIR);
        final Server jetty = JettyHelper.initJetty(null, 8090, new SSLConfig());
        for (int index = 0; index < args.length; index += 2) {
            final String webAppContext = args[index];
            final String webAppArchivePath = args[index + 1];
            JettyHelper.addWebApplication(jetty, normalizeWebAppContext(webAppContext), normalizeWebAppArchivePath(webAppArchivePath));
        }
        JettyHelper.startJetty(jetty);
        latch.await();
    } else {
        System.out.printf("usage:%n>java org.apache.geode.management.internal.TomcatHelper <web-app-context> <war-file-path> [<web-app-context> <war-file-path>]*");
    }
}
Also used : SSLConfig(org.apache.geode.internal.admin.SSLConfig) Server(org.eclipse.jetty.server.Server)

Example 4 with SSLConfig

use of org.apache.geode.internal.admin.SSLConfig in project geode by apache.

the class SSLConfigurationFactoryJUnitTest method getSSLConfigUsingJavaProperties.

@Test
public void getSSLConfigUsingJavaProperties() {
    Properties properties = new Properties();
    properties.setProperty(CLUSTER_SSL_ENABLED, "true");
    properties.setProperty(MCAST_PORT, "0");
    System.setProperty(SSLConfigurationFactory.JAVAX_KEYSTORE, "keystore");
    System.setProperty(SSLConfigurationFactory.JAVAX_KEYSTORE_TYPE, "JKS");
    System.setProperty(SSLConfigurationFactory.JAVAX_KEYSTORE_PASSWORD, "keystorePassword");
    System.setProperty(SSLConfigurationFactory.JAVAX_TRUSTSTORE, "truststore");
    System.setProperty(SSLConfigurationFactory.JAVAX_TRUSTSTORE_PASSWORD, "truststorePassword");
    System.setProperty(SSLConfigurationFactory.JAVAX_TRUSTSTORE_TYPE, "JKS");
    DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
    SSLConfigurationFactory.setDistributionConfig(distributionConfig);
    SSLConfig sslConfig = SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.CLUSTER);
    assertEquals(true, sslConfig.isEnabled());
    assertEquals(System.getProperty(SSLConfigurationFactory.JAVAX_KEYSTORE), sslConfig.getKeystore());
    assertEquals(System.getProperty(SSLConfigurationFactory.JAVAX_KEYSTORE_PASSWORD), sslConfig.getKeystorePassword());
    assertEquals(System.getProperty(SSLConfigurationFactory.JAVAX_KEYSTORE_TYPE), sslConfig.getKeystoreType());
    assertEquals(System.getProperty(SSLConfigurationFactory.JAVAX_TRUSTSTORE), sslConfig.getTruststore());
    assertEquals(System.getProperty(SSLConfigurationFactory.JAVAX_TRUSTSTORE_PASSWORD), sslConfig.getTruststorePassword());
    assertEquals(System.getProperty(SSLConfigurationFactory.JAVAX_TRUSTSTORE_TYPE), sslConfig.getTruststoreType());
    assertEquals(true, sslConfig.isEnabled());
    assertEquals(System.getProperty(SSLConfigurationFactory.JAVAX_KEYSTORE), sslConfig.getKeystore());
    assertEquals(System.getProperty(SSLConfigurationFactory.JAVAX_KEYSTORE_PASSWORD), sslConfig.getKeystorePassword());
    assertEquals(System.getProperty(SSLConfigurationFactory.JAVAX_KEYSTORE_TYPE), sslConfig.getKeystoreType());
    assertEquals(System.getProperty(SSLConfigurationFactory.JAVAX_TRUSTSTORE), sslConfig.getTruststore());
    assertEquals(System.getProperty(SSLConfigurationFactory.JAVAX_TRUSTSTORE_PASSWORD), sslConfig.getTruststorePassword());
    assertEquals(System.getProperty(SSLConfigurationFactory.JAVAX_TRUSTSTORE_TYPE), sslConfig.getTruststoreType());
}
Also used : SSLConfig(org.apache.geode.internal.admin.SSLConfig) DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) Properties(java.util.Properties) RestoreSystemProperties(org.junit.contrib.java.lang.system.RestoreSystemProperties) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest)

Example 5 with SSLConfig

use of org.apache.geode.internal.admin.SSLConfig in project geode by apache.

the class SSLConfigurationFactoryJUnitTest method getSSLHTTPMutualAuthenticationOffWithDefaultConfiguration.

@Test
public void getSSLHTTPMutualAuthenticationOffWithDefaultConfiguration() {
    Properties properties = new Properties();
    properties.setProperty(CLUSTER_SSL_ENABLED, "true");
    properties.setProperty(MCAST_PORT, "0");
    DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
    SSLConfigurationFactory.setDistributionConfig(distributionConfig);
    SSLConfig sslConfig = SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.WEB);
    assertEquals(false, sslConfig.isRequireAuth());
    assertEquals(true, sslConfig.isEnabled());
    sslConfig = SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.CLUSTER);
    assertEquals(true, sslConfig.isRequireAuth());
    assertEquals(true, sslConfig.isEnabled());
    sslConfig = SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.GATEWAY);
    assertEquals(true, sslConfig.isRequireAuth());
    assertEquals(true, sslConfig.isEnabled());
    sslConfig = SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.SERVER);
    assertEquals(true, sslConfig.isRequireAuth());
    assertEquals(true, sslConfig.isEnabled());
    sslConfig = SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.JMX);
    assertEquals(true, sslConfig.isRequireAuth());
    assertEquals(true, sslConfig.isEnabled());
}
Also used : SSLConfig(org.apache.geode.internal.admin.SSLConfig) DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) Properties(java.util.Properties) RestoreSystemProperties(org.junit.contrib.java.lang.system.RestoreSystemProperties) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest)

Aggregations

SSLConfig (org.apache.geode.internal.admin.SSLConfig)8 Properties (java.util.Properties)2 DistributionConfigImpl (org.apache.geode.distributed.internal.DistributionConfigImpl)2 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)2 UnitTest (org.apache.geode.test.junit.categories.UnitTest)2 Test (org.junit.Test)2 RestoreSystemProperties (org.junit.contrib.java.lang.system.RestoreSystemProperties)2 UnknownHostException (java.net.UnknownHostException)1 DistributionConfig (org.apache.geode.distributed.internal.DistributionConfig)1 SecurableCommunicationChannel (org.apache.geode.internal.security.SecurableCommunicationChannel)1 JmxManagerProfile (org.apache.geode.management.internal.JmxManagerAdvisor.JmxManagerProfile)1 Server (org.eclipse.jetty.server.Server)1