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();
}
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();
}
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());
}
}
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();
}
Aggregations