Search in sources :

Example 6 with SConfiguration

use of co.cask.cdap.common.conf.SConfiguration in project cdap by caskdata.

the class ExternalLDAPAuthenticationServerSSLTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    URL certUrl = ExternalLDAPAuthenticationServerSSLTest.class.getClassLoader().getResource("cert.jks");
    Assert.assertNotNull(certUrl);
    String authHandlerConfigBase = Constants.Security.AUTH_HANDLER_CONFIG_BASE;
    CConfiguration cConf = CConfiguration.create();
    SConfiguration sConf = SConfiguration.create();
    cConf.set(Constants.Security.AUTH_SERVER_BIND_ADDRESS, "127.0.0.1");
    cConf.set(Constants.Security.SSL.EXTERNAL_ENABLED, "true");
    cConf.set(Constants.Security.AuthenticationServer.SSL_PORT, "0");
    cConf.set(authHandlerConfigBase.concat("useLdaps"), "true");
    cConf.set(authHandlerConfigBase.concat("ldapsVerifyCertificate"), "false");
    sConf.set(Constants.Security.AuthenticationServer.SSL_KEYSTORE_PATH, certUrl.getPath());
    configuration = cConf;
    sConfiguration = sConf;
    String keystorePassword = sConf.get(Constants.Security.AuthenticationServer.SSL_KEYSTORE_PASSWORD);
    KeyStoreKeyManager keyManager = new KeyStoreKeyManager(certUrl.getFile(), keystorePassword.toCharArray());
    SSLUtil sslUtil = new SSLUtil(keyManager, new TrustAllTrustManager());
    ldapListenerConfig = InMemoryListenerConfig.createLDAPSConfig("LDAP", InetAddress.getByName("127.0.0.1"), ldapPort, sslUtil.createSSLServerSocketFactory(), sslUtil.createSSLSocketFactory());
    testServer = new ExternalLDAPAuthenticationServerSSLTest();
    testServer.setup();
}
Also used : KeyStoreKeyManager(com.unboundid.util.ssl.KeyStoreKeyManager) SSLUtil(com.unboundid.util.ssl.SSLUtil) SConfiguration(co.cask.cdap.common.conf.SConfiguration) TrustAllTrustManager(com.unboundid.util.ssl.TrustAllTrustManager) CConfiguration(co.cask.cdap.common.conf.CConfiguration) URL(java.net.URL) BeforeClass(org.junit.BeforeClass)

Example 7 with SConfiguration

use of co.cask.cdap.common.conf.SConfiguration in project cdap by caskdata.

the class ExternalMTLSAuthenticationServerTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    URL serverTrustoreURL = ExternalMTLSAuthenticationServerTest.class.getClassLoader().getResource("server-trust.jks");
    URL serverKeystoreURL = ExternalMTLSAuthenticationServerTest.class.getClassLoader().getResource("server-key.jks");
    URL realmURL = ExternalMTLSAuthenticationServerTest.class.getClassLoader().getResource("realm.properties");
    Assert.assertNotNull(serverTrustoreURL);
    Assert.assertNotNull(serverKeystoreURL);
    Assert.assertNotNull(realmURL);
    CConfiguration cConf = CConfiguration.create();
    SConfiguration sConf = SConfiguration.create();
    cConf.set(Constants.Security.AUTH_SERVER_BIND_ADDRESS, "127.0.0.1");
    // enables SSL
    cConf.set(Constants.Security.SSL.EXTERNAL_ENABLED, "true");
    cConf.set(Constants.Security.AuthenticationServer.SSL_PORT, "0");
    // set up port for non-ssl endpoints
    cConf.set(Constants.Security.AUTH_SERVER_BIND_PORT, "1");
    // Configure the Custom Handler
    cConf.set(AUTH_HANDLER_CONFIG_BASE.concat("ClassName"), "co.cask.cdap.security.server" + ".CertificateAuthenticationHandler");
    // setup the realm file for Identity
    cConf.set(AUTH_HANDLER_CONFIG_BASE.concat("realmfile"), realmURL.getPath());
    cConf.set(Constants.Security.AuthenticationServer.SSL_TRUSTSTORE_PATH, serverTrustoreURL.getPath());
    cConf.set(Constants.Security.AuthenticationServer.SSL_TRUSTSTORE_PASSWORD, "secret");
    cConf.set(Constants.Security.AuthenticationServer.SSL_TRUSTSTORE_TYPE, "JKS");
    // Setup the Server's Key Store
    cConf.set(Constants.Security.AuthenticationServer.SSL_KEYSTORE_PATH, serverKeystoreURL.getPath());
    sConf.set(Constants.Security.AuthenticationServer.SSL_KEYSTORE_PATH, serverKeystoreURL.getPath());
    sConf.set(Constants.Security.AuthenticationServer.SSL_KEYSTORE_PASSWORD, "secret");
    sConf.set(Constants.Security.AuthenticationServer.SSL_KEYPASSWORD, "secret");
    sConf.set(Constants.Security.AuthenticationServer.SSL_KEYSTORE_TYPE, "JKS");
    configuration = cConf;
    sConfiguration = sConf;
    testServer = new ExternalMTLSAuthenticationServerTest();
    testServer.setup();
}
Also used : SConfiguration(co.cask.cdap.common.conf.SConfiguration) CConfiguration(co.cask.cdap.common.conf.CConfiguration) URL(java.net.URL) BeforeClass(org.junit.BeforeClass)

Example 8 with SConfiguration

use of co.cask.cdap.common.conf.SConfiguration in project cdap by caskdata.

the class RouterResource method before.

@Override
protected void before() throws Throwable {
    CConfiguration cConf = CConfiguration.create();
    Injector injector = Guice.createInjector(new SecurityModules().getInMemoryModules(), new DiscoveryRuntimeModule().getInMemoryModules(), new AppFabricTestModule(cConf));
    DiscoveryServiceClient discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
    AccessTokenTransformer accessTokenTransformer = new MockAccessTokenTransfomer();
    RouteStore routeStore = injector.getInstance(RouteStore.class);
    SConfiguration sConf = injector.getInstance(SConfiguration.class);
    cConf.set(Constants.Router.ADDRESS, hostname);
    cConf.setInt(Constants.Router.ROUTER_PORT, 0);
    for (Map.Entry<String, String> entry : additionalConfig.entrySet()) {
        cConf.set(entry.getKey(), entry.getValue());
    }
    router = new NettyRouter(cConf, sConf, InetAddresses.forString(hostname), new RouterServiceLookup(cConf, (DiscoveryServiceClient) discoveryService, new RouterPathLookup(), routeStore), new MockTokenValidator("failme"), accessTokenTransformer, discoveryServiceClient);
    router.startAndWait();
    for (Map.Entry<Integer, String> entry : router.getServiceLookup().getServiceMap().entrySet()) {
        serviceMap.put(entry.getValue(), entry.getKey());
    }
}
Also used : DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) RouteStore(co.cask.cdap.route.store.RouteStore) CConfiguration(co.cask.cdap.common.conf.CConfiguration) SecurityModules(co.cask.cdap.security.guice.SecurityModules) AccessTokenTransformer(co.cask.cdap.security.auth.AccessTokenTransformer) Injector(com.google.inject.Injector) SConfiguration(co.cask.cdap.common.conf.SConfiguration) AppFabricTestModule(co.cask.cdap.internal.guice.AppFabricTestModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with SConfiguration

use of co.cask.cdap.common.conf.SConfiguration in project cdap by caskdata.

the class RoutingToDataSetsTest method before.

@BeforeClass
public static void before() throws Exception {
    CConfiguration cConf = CConfiguration.create();
    Injector injector = Guice.createInjector(new SecurityModules().getInMemoryModules(), new DiscoveryRuntimeModule().getInMemoryModules(), new AppFabricTestModule(cConf));
    // Starting router
    DiscoveryServiceClient discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
    AccessTokenTransformer accessTokenTransformer = injector.getInstance(AccessTokenTransformer.class);
    RouteStore routeStore = injector.getInstance(RouteStore.class);
    SConfiguration sConf = SConfiguration.create();
    cConf.set(Constants.Router.ADDRESS, "localhost");
    port = Networks.getRandomPort();
    cConf.setInt(Constants.Router.ROUTER_PORT, port);
    nettyRouter = new NettyRouter(cConf, sConf, InetAddresses.forString("127.0.0.1"), new RouterServiceLookup(cConf, discoveryServiceClient, new RouterPathLookup(), routeStore), new SuccessTokenValidator(), accessTokenTransformer, discoveryServiceClient);
    nettyRouter.startAndWait();
    // Starting mock DataSet service
    DiscoveryService discoveryService = injector.getInstance(DiscoveryService.class);
    mockService = new MockHttpService(discoveryService, Constants.Service.DATASET_MANAGER, new MockDatasetTypeHandler(), new MockDatasetInstanceHandler());
    mockService.startAndWait();
}
Also used : DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) RouteStore(co.cask.cdap.route.store.RouteStore) CConfiguration(co.cask.cdap.common.conf.CConfiguration) SecurityModules(co.cask.cdap.security.guice.SecurityModules) AccessTokenTransformer(co.cask.cdap.security.auth.AccessTokenTransformer) Injector(com.google.inject.Injector) SConfiguration(co.cask.cdap.common.conf.SConfiguration) AppFabricTestModule(co.cask.cdap.internal.guice.AppFabricTestModule) DiscoveryService(org.apache.twill.discovery.DiscoveryService) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) BeforeClass(org.junit.BeforeClass)

Aggregations

SConfiguration (co.cask.cdap.common.conf.SConfiguration)9 CConfiguration (co.cask.cdap.common.conf.CConfiguration)7 BeforeClass (org.junit.BeforeClass)5 Injector (com.google.inject.Injector)4 DiscoveryServiceClient (org.apache.twill.discovery.DiscoveryServiceClient)4 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)2 AppFabricTestModule (co.cask.cdap.internal.guice.AppFabricTestModule)2 RouteStore (co.cask.cdap.route.store.RouteStore)2 AccessTokenTransformer (co.cask.cdap.security.auth.AccessTokenTransformer)2 SecurityModules (co.cask.cdap.security.guice.SecurityModules)2 AbstractModule (com.google.inject.AbstractModule)2 URL (java.net.URL)2 Test (org.junit.Test)2 SecureStore (co.cask.cdap.api.security.store.SecureStore)1 SecureStoreManager (co.cask.cdap.api.security.store.SecureStoreManager)1 EndpointStrategy (co.cask.cdap.common.discovery.EndpointStrategy)1 RandomEndpointStrategy (co.cask.cdap.common.discovery.RandomEndpointStrategy)1 InMemoryNamespaceClient (co.cask.cdap.common.namespace.InMemoryNamespaceClient)1 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)1 UnauthorizedException (co.cask.cdap.security.spi.authorization.UnauthorizedException)1