Search in sources :

Example 1 with UserIdentityExtractor

use of io.cdap.cdap.security.auth.UserIdentityExtractor in project cdap by caskdata.

the class RouterResource method before.

@Override
protected void before() {
    CConfiguration cConf = CConfiguration.create();
    Injector injector = Guice.createInjector(new CoreSecurityRuntimeModule().getStandaloneModules(), new ExternalAuthenticationModule(), new InMemoryDiscoveryModule(), new AppFabricTestModule(cConf));
    DiscoveryServiceClient discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
    TokenValidator mockValidator = new MockTokenValidator("failme");
    UserIdentityExtractor extractor = new MockAccessTokenIdentityExtractor(mockValidator);
    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()), mockValidator, extractor, discoveryServiceClient);
    router.startAndWait();
}
Also used : InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) ExternalAuthenticationModule(io.cdap.cdap.security.guice.ExternalAuthenticationModule) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) TokenValidator(io.cdap.cdap.security.auth.TokenValidator) CoreSecurityRuntimeModule(io.cdap.cdap.security.guice.CoreSecurityRuntimeModule) Injector(com.google.inject.Injector) SConfiguration(io.cdap.cdap.common.conf.SConfiguration) AppFabricTestModule(io.cdap.cdap.internal.guice.AppFabricTestModule) UserIdentityExtractor(io.cdap.cdap.security.auth.UserIdentityExtractor) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with UserIdentityExtractor

use of io.cdap.cdap.security.auth.UserIdentityExtractor 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 CoreSecurityRuntimeModule().getInMemoryModules(), new ExternalAuthenticationModule(), new InMemoryDiscoveryModule(), new AppFabricTestModule(cConf));
    // Starting router
    DiscoveryServiceClient discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
    UserIdentityExtractor userIdentityExtractor = injector.getInstance(UserIdentityExtractor.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()), new SuccessTokenValidator(), userIdentityExtractor, 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 : InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) ExternalAuthenticationModule(io.cdap.cdap.security.guice.ExternalAuthenticationModule) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) CoreSecurityRuntimeModule(io.cdap.cdap.security.guice.CoreSecurityRuntimeModule) Injector(com.google.inject.Injector) SConfiguration(io.cdap.cdap.common.conf.SConfiguration) AppFabricTestModule(io.cdap.cdap.internal.guice.AppFabricTestModule) UserIdentityExtractor(io.cdap.cdap.security.auth.UserIdentityExtractor) DiscoveryService(org.apache.twill.discovery.DiscoveryService) BeforeClass(org.junit.BeforeClass)

Aggregations

Injector (com.google.inject.Injector)2 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)2 SConfiguration (io.cdap.cdap.common.conf.SConfiguration)2 InMemoryDiscoveryModule (io.cdap.cdap.common.guice.InMemoryDiscoveryModule)2 AppFabricTestModule (io.cdap.cdap.internal.guice.AppFabricTestModule)2 UserIdentityExtractor (io.cdap.cdap.security.auth.UserIdentityExtractor)2 CoreSecurityRuntimeModule (io.cdap.cdap.security.guice.CoreSecurityRuntimeModule)2 ExternalAuthenticationModule (io.cdap.cdap.security.guice.ExternalAuthenticationModule)2 DiscoveryServiceClient (org.apache.twill.discovery.DiscoveryServiceClient)2 TokenValidator (io.cdap.cdap.security.auth.TokenValidator)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DiscoveryService (org.apache.twill.discovery.DiscoveryService)1 BeforeClass (org.junit.BeforeClass)1