Search in sources :

Example 1 with SecurityModuleFactory

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;
}
Also used : SecurityModuleFactory(org.apache.flink.runtime.security.modules.SecurityModuleFactory) ArrayList(java.util.ArrayList) SecurityModule(org.apache.flink.runtime.security.modules.SecurityModule)

Example 2 with SecurityModuleFactory

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;
        }
    }
}
Also used : AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) SecurityModuleFactory(org.apache.flink.runtime.security.modules.SecurityModuleFactory) DynamicConfiguration(org.apache.flink.runtime.security.DynamicConfiguration) JaasModuleFactory(org.apache.flink.runtime.security.modules.JaasModuleFactory) Map(java.util.Map)

Aggregations

SecurityModuleFactory (org.apache.flink.runtime.security.modules.SecurityModuleFactory)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 AppConfigurationEntry (javax.security.auth.login.AppConfigurationEntry)1 DynamicConfiguration (org.apache.flink.runtime.security.DynamicConfiguration)1 JaasModuleFactory (org.apache.flink.runtime.security.modules.JaasModuleFactory)1 SecurityModule (org.apache.flink.runtime.security.modules.SecurityModule)1