use of io.cdap.cdap.security.auth.TokenManager in project cdap by caskdata.
the class ArtifactLocalizerTwillRunnable method doInitialize.
private void doInitialize() throws Exception {
CConfiguration cConf = CConfiguration.create();
cConf.clear();
cConf.addResource(new File(getArgument("cConf")).toURI().toURL());
Configuration hConf = new Configuration();
hConf.clear();
hConf.addResource(new File(getArgument("hConf")).toURI().toURL());
Injector injector = createInjector(cConf, hConf);
// Initialize logging context
logAppenderInitializer = injector.getInstance(LogAppenderInitializer.class);
logAppenderInitializer.initialize();
LoggingContext loggingContext = new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(), Constants.Logging.COMPONENT_NAME, Constants.Service.ARTIFACT_LOCALIZER);
LoggingContextAccessor.setLoggingContext(loggingContext);
tokenManager = injector.getInstance(TokenManager.class);
tokenManager.startAndWait();
artifactLocalizerService = injector.getInstance(ArtifactLocalizerService.class);
}
use of io.cdap.cdap.security.auth.TokenManager in project cdap by caskdata.
the class MasterEnvironmentMain method getInternalAuthenticator.
/**
* Return {@link InternalAuthenticator} with
* {@link SystemAuthenticationContext} if cdap-secret is mounted (e.g. when only running system code / trusted code)
* or {@link WorkerAuthenticationContext} if cdap-secret is not mounted (e.g. running untrusted user provided code)
*/
private static InternalAuthenticator getInternalAuthenticator(CConfiguration cConf) {
File sConfFile = new File(cConf.get(Constants.Twill.Security.MASTER_SECRET_DISK_PATH));
Injector injector;
if (sConfFile.exists()) {
// cdap-secret is mounted and available, use system authentication context
injector = Guice.createInjector(new IOModule(), new ConfigModule(cConf), CoreSecurityRuntimeModule.getDistributedModule(cConf), new AuthenticationContextModules().getMasterModule());
if (cConf.getBoolean(Constants.Security.INTERNAL_AUTH_ENABLED)) {
tokenManager = injector.getInstance(TokenManager.class);
tokenManager.startAndWait();
}
} else {
// cdap-secret is NOT mounted, use worker authentication context
injector = Guice.createInjector(new IOModule(), new ConfigModule(cConf), CoreSecurityRuntimeModule.getDistributedModule(cConf), new AuthenticationContextModules().getMasterWorkerModule());
}
return injector.getInstance(InternalAuthenticator.class);
}
Aggregations