use of io.cdap.cdap.common.guice.IOModule in project cdap by caskdata.
the class ExternalAuthenticationServerTestBase method setup.
protected void setup() throws Exception {
Assert.assertNotNull("CConfiguration needs to be set by derived classes", configuration);
// Intentionally set "security.auth.server.announce.urls" to invalid
// values verify that they are not used by external authentication server
configuration.set(Constants.Security.AUTH_SERVER_ANNOUNCE_URLS, "invalid.urls");
Module externalAuthenticationModule = Modules.override(new ExternalAuthenticationModule()).with(new AbstractModule() {
@Override
protected void configure() {
bind(AuditLogHandler.class).annotatedWith(Names.named(ExternalAuthenticationServer.NAMED_EXTERNAL_AUTH)).toInstance(new AuditLogHandler(TEST_AUDIT_LOGGER));
}
});
Injector injector = Guice.createInjector(new IOModule(), externalAuthenticationModule, new CoreSecurityRuntimeModule().getInMemoryModules(), new ConfigModule(getConfiguration(configuration), HBaseConfiguration.create(), sConfiguration), new InMemoryDiscoveryModule());
server = injector.getInstance(ExternalAuthenticationServer.class);
tokenCodec = injector.getInstance(AccessTokenCodec.class);
discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
startExternalAuthenticationServer();
server.startAndWait();
LOG.info("Auth server running on address {}", server.getSocketAddress());
TimeUnit.SECONDS.sleep(3);
}
use of io.cdap.cdap.common.guice.IOModule in project cdap by caskdata.
the class FileBasedTokenManagerTest method getTokenManagerAndCodec.
@Override
protected ImmutablePair<TokenManager, Codec<AccessToken>> getTokenManagerAndCodec() throws IOException {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
Injector injector = Guice.createInjector(new IOModule(), new ConfigModule(cConf), new FileBasedCoreSecurityModule(), new InMemoryDiscoveryModule());
TokenManager tokenManager = injector.getInstance(TokenManager.class);
tokenManager.startAndWait();
Codec<AccessToken> tokenCodec = injector.getInstance(AccessTokenCodec.class);
return new ImmutablePair<>(tokenManager, tokenCodec);
}
use of io.cdap.cdap.common.guice.IOModule in project cdap by caskdata.
the class TestInMemoryTokenManager method getTokenManagerAndCodec.
@Override
protected ImmutablePair<TokenManager, Codec<AccessToken>> getTokenManagerAndCodec() {
Injector injector = Guice.createInjector(new IOModule(), new CoreSecurityRuntimeModule().getStandaloneModules(), new ConfigModule(), new InMemoryDiscoveryModule());
TokenManager tokenManager = injector.getInstance(TokenManager.class);
tokenManager.startAndWait();
Codec<AccessToken> tokenCodec = injector.getInstance(AccessTokenCodec.class);
return new ImmutablePair<>(tokenManager, tokenCodec);
}
use of io.cdap.cdap.common.guice.IOModule in project cdap by caskdata.
the class DistributedKeyManagerTest method setup.
@BeforeClass
public static void setup() throws Exception {
HBaseTestingUtility testUtil = new HBaseTestingUtility();
zkCluster = testUtil.startMiniZKCluster();
String zkConnectString = testUtil.getConfiguration().get(HConstants.ZOOKEEPER_QUORUM) + ":" + zkCluster.getClientPort();
LOG.info("Running ZK cluster at " + zkConnectString);
CConfiguration cConf1 = CConfiguration.create();
cConf1.setBoolean(Constants.Security.ENABLED, true);
cConf1.set(Constants.Zookeeper.QUORUM, zkConnectString);
CConfiguration cConf2 = CConfiguration.create();
cConf2.setBoolean(Constants.Security.ENABLED, true);
cConf2.set(Constants.Zookeeper.QUORUM, zkConnectString);
List<Module> modules = new ArrayList<>();
modules.add(new ConfigModule(cConf1, testUtil.getConfiguration()));
modules.add(new IOModule());
CoreSecurityModule coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf1);
modules.add(coreSecurityModule);
if (coreSecurityModule.requiresZKClient()) {
modules.add(new ZKClientModule());
modules.add(new ZKDiscoveryModule());
}
injector1 = Guice.createInjector(modules);
modules.clear();
modules.add(new ConfigModule(cConf2, testUtil.getConfiguration()));
modules.add(new IOModule());
coreSecurityModule = CoreSecurityRuntimeModule.getDistributedModule(cConf2);
modules.add(coreSecurityModule);
if (coreSecurityModule.requiresZKClient()) {
modules.add(new ZKClientModule());
modules.add(new ZKDiscoveryModule());
}
injector2 = Guice.createInjector(modules);
}
use of io.cdap.cdap.common.guice.IOModule in project cdap by caskdata.
the class JobQueueDebugger method createInjector.
private static Injector createInjector() throws Exception {
CConfiguration cConf = CConfiguration.create();
if (cConf.getBoolean(Constants.Security.Authorization.ENABLED)) {
System.out.println(String.format("Disabling authorization for %s.", JobQueueDebugger.class.getSimpleName()));
cConf.setBoolean(Constants.Security.Authorization.ENABLED, false);
}
// Note: login has to happen before any objects that need Kerberos credentials are instantiated.
SecurityUtil.loginForMasterService(cConf);
return Guice.createInjector(new ConfigModule(cConf, HBaseConfiguration.create()), RemoteAuthenticatorModules.getDefaultModule(), new IOModule(), new ZKClientModule(), new ZKDiscoveryModule(), new DFSLocationModule(), new TwillModule(), new ExploreClientModule(), new DataFabricModules().getDistributedModules(), new DataSetsModules().getDistributedModules(), new AppFabricServiceRuntimeModule(cConf).getDistributedModules(), new ProgramRunnerRuntimeModule().getDistributedModules(), new SystemDatasetRuntimeModule().getDistributedModules(), new KafkaLogAppenderModule(), new MetricsClientRuntimeModule().getDistributedModules(), new MetricsStoreModule(), new KafkaClientModule(), CoreSecurityRuntimeModule.getDistributedModule(cConf), new AuthenticationContextModules().getMasterModule(), new AuthorizationModule(), new AuthorizationEnforcementModule().getMasterModule(), new SecureStoreServerModule(), new MessagingClientModule(), new AbstractModule() {
@Override
protected void configure() {
bind(Store.class).annotatedWith(Names.named("defaultStore")).to(DefaultStore.class).in(Singleton.class);
// This is needed because the LocalApplicationManager
// expects a dsframework injection named datasetMDS
bind(DatasetFramework.class).annotatedWith(Names.named("datasetMDS")).to(DatasetFramework.class).in(Singleton.class);
// TODO (CDAP-14677): find a better way to inject metadata publisher
bind(MetadataServiceClient.class).to(NoOpMetadataServiceClient.class);
}
});
}
Aggregations