use of org.apache.flink.runtime.security.modules.SecurityModuleFactory in project flink by apache.
the class SecurityUtils method installModules.
static void installModules(SecurityConfiguration config) throws Exception {
// install the security module factories
List<SecurityModule> modules = new ArrayList<>();
for (String moduleFactoryClass : config.getSecurityModuleFactories()) {
SecurityModuleFactory moduleFactory = null;
try {
moduleFactory = SecurityFactoryServiceLoader.findModuleFactory(moduleFactoryClass);
} catch (NoMatchSecurityFactoryException ne) {
LOG.error("Unable to instantiate security module factory {}", moduleFactoryClass);
throw new IllegalArgumentException("Unable to find module factory class", ne);
}
SecurityModule module = moduleFactory.createModule(config);
// can be null if a SecurityModule is not supported in the current environment
if (module != null) {
module.install();
modules.add(module);
}
}
installedModules = modules;
}
use of org.apache.flink.runtime.security.modules.SecurityModuleFactory in project flink by apache.
the class TestingSecurityContext method install.
public static void install(SecurityConfiguration config, Map<String, ClientSecurityConfiguration> clientSecurityConfigurationMap) throws Exception {
SecurityUtils.install(config);
// install dynamic JAAS entries
for (String factoryClassName : config.getSecurityModuleFactories()) {
SecurityModuleFactory factory = SecurityFactoryServiceLoader.findModuleFactory(factoryClassName);
if (factory instanceof JaasModuleFactory) {
DynamicConfiguration jaasConf = (DynamicConfiguration) javax.security.auth.login.Configuration.getConfiguration();
for (Map.Entry<String, ClientSecurityConfiguration> e : clientSecurityConfigurationMap.entrySet()) {
AppConfigurationEntry entry = KerberosUtils.keytabEntry(e.getValue().getKeytab(), e.getValue().getPrincipal());
jaasConf.addAppConfigurationEntry(e.getKey(), entry);
}
break;
}
}
}
Aggregations