Search in sources :

Example 1 with KerberosHelper

use of org.apache.drill.exec.rpc.security.KerberosHelper in project drill by apache.

the class TestUserBitKerberos method setupTest.

@BeforeClass
public static void setupTest() throws Exception {
    krbHelper = new KerberosHelper(TestUserBitKerberos.class.getSimpleName());
    krbHelper.setupKdc();
    // Create a new DrillConfig which has user authentication enabled and authenticator set to
    // UserAuthenticatorTestImpl.
    final DrillConfig newConfig = new DrillConfig(DrillConfig.create(cloneDefaultTestConfigProperties()).withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.USER_AUTHENTICATOR_IMPL, ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)).withValue(BootStrapContext.SERVICE_PRINCIPAL, ConfigValueFactory.fromAnyRef(krbHelper.SERVER_PRINCIPAL)).withValue(BootStrapContext.SERVICE_KEYTAB_LOCATION, ConfigValueFactory.fromAnyRef(krbHelper.serverKeytab.toString())).withValue(ExecConstants.AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("plain", "kerberos"))), false);
    final Properties connectionProps = new Properties();
    connectionProps.setProperty(DrillProperties.USER, "anonymous");
    connectionProps.setProperty(DrillProperties.PASSWORD, "anything works!");
    // Ignore the compile time warning caused by the code below.
    // Config is statically initialized at this point. But the above configuration results in a different
    // initialization which causes the tests to fail. So the following two changes are required.
    // (1) Refresh Kerberos config.
    sun.security.krb5.Config.refresh();
    // (2) Reset the default realm.
    final Field defaultRealm = KerberosName.class.getDeclaredField("defaultRealm");
    defaultRealm.setAccessible(true);
    defaultRealm.set(null, KerberosUtil.getDefaultRealm());
    updateTestCluster(1, newConfig, connectionProps);
}
Also used : Field(java.lang.reflect.Field) DrillConfig(org.apache.drill.common.config.DrillConfig) Properties(java.util.Properties) DrillProperties(org.apache.drill.common.config.DrillProperties) KerberosHelper(org.apache.drill.exec.rpc.security.KerberosHelper) BeforeClass(org.junit.BeforeClass)

Example 2 with KerberosHelper

use of org.apache.drill.exec.rpc.security.KerberosHelper in project drill by apache.

the class TestUserBitKerberosEncryption method setupTest.

@BeforeClass
public static void setupTest() throws Exception {
    krbHelper = new KerberosHelper(TestUserBitKerberosEncryption.class.getSimpleName());
    krbHelper.setupKdc();
    // Create a new DrillConfig which has user authentication enabled and authenticator set to
    // UserAuthenticatorTestImpl.
    newConfig = new DrillConfig(DrillConfig.create(cloneDefaultTestConfigProperties()).withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.USER_AUTHENTICATOR_IMPL, ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)).withValue(BootStrapContext.SERVICE_PRINCIPAL, ConfigValueFactory.fromAnyRef(krbHelper.SERVER_PRINCIPAL)).withValue(BootStrapContext.SERVICE_KEYTAB_LOCATION, ConfigValueFactory.fromAnyRef(krbHelper.serverKeytab.toString())).withValue(ExecConstants.AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("plain", "kerberos"))).withValue(ExecConstants.USER_ENCRYPTION_SASL_ENABLED, ConfigValueFactory.fromAnyRef(true)), false);
    final Properties connectionProps = new Properties();
    connectionProps.setProperty(DrillProperties.SERVICE_PRINCIPAL, krbHelper.SERVER_PRINCIPAL);
    connectionProps.setProperty(DrillProperties.USER, krbHelper.CLIENT_PRINCIPAL);
    connectionProps.setProperty(DrillProperties.KEYTAB, krbHelper.clientKeytab.getAbsolutePath());
    // Ignore the compile time warning caused by the code below.
    // Config is statically initialized at this point. But the above configuration results in a different
    // initialization which causes the tests to fail. So the following two changes are required.
    // (1) Refresh Kerberos config.
    sun.security.krb5.Config.refresh();
    // (2) Reset the default realm.
    final Field defaultRealm = KerberosName.class.getDeclaredField("defaultRealm");
    defaultRealm.setAccessible(true);
    defaultRealm.set(null, KerberosUtil.getDefaultRealm());
    // Start a secure cluster with client using Kerberos related parameters.
    updateTestCluster(1, newConfig, connectionProps);
}
Also used : Field(java.lang.reflect.Field) DrillConfig(org.apache.drill.common.config.DrillConfig) Properties(java.util.Properties) DrillProperties(org.apache.drill.common.config.DrillProperties) KerberosHelper(org.apache.drill.exec.rpc.security.KerberosHelper) BeforeClass(org.junit.BeforeClass)

Example 3 with KerberosHelper

use of org.apache.drill.exec.rpc.security.KerberosHelper in project drill by apache.

the class TestBitBitKerberos method setupTest.

@BeforeClass
public static void setupTest() throws Exception {
    final Config config = DrillConfig.create(cloneDefaultTestConfigProperties());
    krbHelper = new KerberosHelper(TestBitBitKerberos.class.getSimpleName());
    krbHelper.setupKdc();
    newConfig = new DrillConfig(config.withValue(ExecConstants.AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("kerberos"))).withValue(ExecConstants.BIT_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.BIT_AUTHENTICATION_MECHANISM, ConfigValueFactory.fromAnyRef("kerberos")).withValue(ExecConstants.USE_LOGIN_PRINCIPAL, ConfigValueFactory.fromAnyRef(true)).withValue(BootStrapContext.SERVICE_PRINCIPAL, ConfigValueFactory.fromAnyRef(krbHelper.SERVER_PRINCIPAL)).withValue(BootStrapContext.SERVICE_KEYTAB_LOCATION, ConfigValueFactory.fromAnyRef(krbHelper.serverKeytab.toString())), false);
    // Ignore the compile time warning caused by the code below.
    // Config is statically initialized at this point. But the above configuration results in a different
    // initialization which causes the tests to fail. So the following two changes are required.
    // (1) Refresh Kerberos config.
    sun.security.krb5.Config.refresh();
    // (2) Reset the default realm.
    final Field defaultRealm = KerberosName.class.getDeclaredField("defaultRealm");
    defaultRealm.setAccessible(true);
    defaultRealm.set(null, KerberosUtil.getDefaultRealm());
    updateTestCluster(1, newConfig);
    ScanResult result = ClassPathScanner.fromPrescan(newConfig);
    c1 = new BootStrapContext(newConfig, result);
    setupFragmentContextAndManager();
}
Also used : MaterializedField(org.apache.drill.exec.record.MaterializedField) Field(java.lang.reflect.Field) ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) DrillConfig(org.apache.drill.common.config.DrillConfig) Config(com.typesafe.config.Config) DrillConfig(org.apache.drill.common.config.DrillConfig) BootStrapContext(org.apache.drill.exec.server.BootStrapContext) KerberosHelper(org.apache.drill.exec.rpc.security.KerberosHelper) BeforeClass(org.junit.BeforeClass)

Aggregations

Field (java.lang.reflect.Field)3 DrillConfig (org.apache.drill.common.config.DrillConfig)3 KerberosHelper (org.apache.drill.exec.rpc.security.KerberosHelper)3 BeforeClass (org.junit.BeforeClass)3 Properties (java.util.Properties)2 DrillProperties (org.apache.drill.common.config.DrillProperties)2 Config (com.typesafe.config.Config)1 ScanResult (org.apache.drill.common.scanner.persistence.ScanResult)1 MaterializedField (org.apache.drill.exec.record.MaterializedField)1 BootStrapContext (org.apache.drill.exec.server.BootStrapContext)1