Search in sources :

Example 1 with DynamicConfiguration

use of org.apache.flink.runtime.security.DynamicConfiguration in project flink by apache.

the class JaasModule method install.

@Override
public void install(SecurityUtils.SecurityConfiguration securityConfig) throws SecurityInstallException {
    // ensure that a config file is always defined, for compatibility with
    // ZK and Kafka which check for the system property and existence of the file
    priorConfigFile = System.getProperty(JAVA_SECURITY_AUTH_LOGIN_CONFIG, null);
    if (priorConfigFile == null) {
        File configFile = generateDefaultConfigFile();
        System.setProperty(JAVA_SECURITY_AUTH_LOGIN_CONFIG, configFile.getAbsolutePath());
    }
    // read the JAAS configuration file
    priorConfig = javax.security.auth.login.Configuration.getConfiguration();
    // construct a dynamic JAAS configuration
    currentConfig = new DynamicConfiguration(priorConfig);
    // wire up the configured JAAS login contexts to use the krb5 entries
    AppConfigurationEntry[] krb5Entries = getAppConfigurationEntries(securityConfig);
    if (krb5Entries != null) {
        for (String app : securityConfig.getLoginContextNames()) {
            currentConfig.addAppConfigurationEntry(app, krb5Entries);
        }
    }
    javax.security.auth.login.Configuration.setConfiguration(currentConfig);
}
Also used : AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) DynamicConfiguration(org.apache.flink.runtime.security.DynamicConfiguration) File(java.io.File)

Example 2 with DynamicConfiguration

use of org.apache.flink.runtime.security.DynamicConfiguration in project flink by apache.

the class TestingSecurityContext method install.

public static void install(SecurityUtils.SecurityConfiguration config, Map<String, ClientSecurityConfiguration> clientSecurityConfigurationMap) throws Exception {
    SecurityUtils.install(config);
    // install dynamic JAAS entries
    checkArgument(config.getSecurityModules().contains(JaasModule.class));
    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);
    }
}
Also used : JaasModule(org.apache.flink.runtime.security.modules.JaasModule) AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) DynamicConfiguration(org.apache.flink.runtime.security.DynamicConfiguration) Map(java.util.Map)

Aggregations

AppConfigurationEntry (javax.security.auth.login.AppConfigurationEntry)2 DynamicConfiguration (org.apache.flink.runtime.security.DynamicConfiguration)2 File (java.io.File)1 Map (java.util.Map)1 JaasModule (org.apache.flink.runtime.security.modules.JaasModule)1