use of co.cask.cdap.security.guice.SecurityModules in project cdap by caskdata.
the class AuthenticationServerMain method init.
@Override
public void init(String[] args) {
Injector injector = Guice.createInjector(new ConfigModule(), new IOModule(), new SecurityModules().getDistributedModules(), new DiscoveryRuntimeModule().getDistributedModules(), new ZKClientModule());
configuration = injector.getInstance(CConfiguration.class);
if (configuration.getBoolean(Constants.Security.ENABLED)) {
this.zkClientService = injector.getInstance(ZKClientService.class);
this.authServer = injector.getInstance(ExternalAuthenticationServer.class);
}
}
use of co.cask.cdap.security.guice.SecurityModules 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.set(Constants.Zookeeper.QUORUM, zkConnectString);
CConfiguration cConf2 = CConfiguration.create();
cConf2.set(Constants.Zookeeper.QUORUM, zkConnectString);
injector1 = Guice.createInjector(new ConfigModule(cConf1, testUtil.getConfiguration()), new IOModule(), new SecurityModules().getDistributedModules(), new ZKClientModule(), new DiscoveryRuntimeModule().getDistributedModules());
injector2 = Guice.createInjector(new ConfigModule(cConf2, testUtil.getConfiguration()), new IOModule(), new SecurityModules().getDistributedModules(), new ZKClientModule(), new DiscoveryRuntimeModule().getDistributedModules());
}
use of co.cask.cdap.security.guice.SecurityModules in project cdap by caskdata.
the class TestInMemoryTokenManager method getTokenManagerAndCodec.
@Override
protected ImmutablePair<TokenManager, Codec<AccessToken>> getTokenManagerAndCodec() {
Injector injector = Guice.createInjector(new IOModule(), new SecurityModules().getInMemoryModules(), new ConfigModule(), new DiscoveryRuntimeModule().getInMemoryModules());
TokenManager tokenManager = injector.getInstance(TokenManager.class);
tokenManager.startAndWait();
Codec<AccessToken> tokenCodec = injector.getInstance(AccessTokenCodec.class);
return new ImmutablePair<>(tokenManager, tokenCodec);
}
use of co.cask.cdap.security.guice.SecurityModules 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.address" and "security.auth.server.announce.address" to invalid
// values verify that they are not used by external authentication server
configuration.set(Constants.Security.AUTH_SERVER_ANNOUNCE_ADDRESS_DEPRECATED, "invalid.address");
configuration.set(Constants.Security.AUTH_SERVER_ANNOUNCE_URLS, "invalid.urls");
Module securityModule = Modules.override(new SecurityModules().getInMemoryModules()).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(), securityModule, new ConfigModule(getConfiguration(configuration), HBaseConfiguration.create(), sConfiguration), new DiscoveryRuntimeModule().getInMemoryModules());
server = injector.getInstance(ExternalAuthenticationServer.class);
tokenCodec = injector.getInstance(AccessTokenCodec.class);
discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
if (configuration.getBoolean(Constants.Security.SSL.EXTERNAL_ENABLED)) {
port = configuration.getInt(Constants.Security.AuthenticationServer.SSL_PORT);
} else {
port = configuration.getInt(Constants.Security.AUTH_SERVER_BIND_PORT);
}
startExternalAuthenticationServer();
server.startAndWait();
LOG.info("Auth server running on port {}", port);
TimeUnit.SECONDS.sleep(3);
}
Aggregations