Search in sources :

Example 6 with SecurityModules

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);
    }
}
Also used : IOModule(co.cask.cdap.common.guice.IOModule) ZKClientModule(co.cask.cdap.common.guice.ZKClientModule) ZKClientService(org.apache.twill.zookeeper.ZKClientService) ExternalAuthenticationServer(co.cask.cdap.security.server.ExternalAuthenticationServer) Injector(com.google.inject.Injector) ConfigModule(co.cask.cdap.common.guice.ConfigModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) CConfiguration(co.cask.cdap.common.conf.CConfiguration) SecurityModules(co.cask.cdap.security.guice.SecurityModules)

Example 7 with SecurityModules

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());
}
Also used : IOModule(co.cask.cdap.common.guice.IOModule) ZKClientModule(co.cask.cdap.common.guice.ZKClientModule) HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) ConfigModule(co.cask.cdap.common.guice.ConfigModule) CConfiguration(co.cask.cdap.common.conf.CConfiguration) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) SecurityModules(co.cask.cdap.security.guice.SecurityModules) BeforeClass(org.junit.BeforeClass)

Example 8 with SecurityModules

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);
}
Also used : IOModule(co.cask.cdap.common.guice.IOModule) ImmutablePair(co.cask.cdap.common.utils.ImmutablePair) Injector(com.google.inject.Injector) ConfigModule(co.cask.cdap.common.guice.ConfigModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) SecurityModules(co.cask.cdap.security.guice.SecurityModules)

Example 9 with SecurityModules

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);
}
Also used : IOModule(co.cask.cdap.common.guice.IOModule) DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) AccessTokenCodec(co.cask.cdap.security.auth.AccessTokenCodec) Injector(com.google.inject.Injector) ConfigModule(co.cask.cdap.common.guice.ConfigModule) Module(com.google.inject.Module) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) ConfigModule(co.cask.cdap.common.guice.ConfigModule) IOModule(co.cask.cdap.common.guice.IOModule) AbstractModule(com.google.inject.AbstractModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) SecurityModules(co.cask.cdap.security.guice.SecurityModules) AbstractModule(com.google.inject.AbstractModule)

Aggregations

SecurityModules (co.cask.cdap.security.guice.SecurityModules)9 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)7 CConfiguration (co.cask.cdap.common.conf.CConfiguration)6 ConfigModule (co.cask.cdap.common.guice.ConfigModule)6 IOModule (co.cask.cdap.common.guice.IOModule)6 Injector (com.google.inject.Injector)5 ZKClientModule (co.cask.cdap.common.guice.ZKClientModule)3 DiscoveryServiceClient (org.apache.twill.discovery.DiscoveryServiceClient)3 ProgramRunnerRuntimeModule (co.cask.cdap.app.guice.ProgramRunnerRuntimeModule)2 SConfiguration (co.cask.cdap.common.conf.SConfiguration)2 LocationRuntimeModule (co.cask.cdap.common.guice.LocationRuntimeModule)2 DataSetServiceModules (co.cask.cdap.data.runtime.DataSetServiceModules)2 StreamServiceRuntimeModule (co.cask.cdap.data.stream.service.StreamServiceRuntimeModule)2 AppFabricTestModule (co.cask.cdap.internal.guice.AppFabricTestModule)2 NotificationServiceRuntimeModule (co.cask.cdap.notifications.guice.NotificationServiceRuntimeModule)2 RouteStore (co.cask.cdap.route.store.RouteStore)2 AccessTokenTransformer (co.cask.cdap.security.auth.AccessTokenTransformer)2 AbstractModule (com.google.inject.AbstractModule)2 BeforeClass (org.junit.BeforeClass)2 DatasetModule (co.cask.cdap.api.dataset.module.DatasetModule)1