Search in sources :

Example 1 with MiniKdc

use of org.apache.hadoop.minikdc.MiniKdc in project hadoop by apache.

the class TestRMWebServicesHttpStaticUserPermissions method setUp.

@BeforeClass
public static void setUp() {
    try {
        testMiniKDC = new MiniKdc(MiniKdc.createConf(), testRootDir);
        setupKDC();
        setupAndStartRM();
    } catch (Exception e) {
        fail("Couldn't create MiniKDC");
    }
}
Also used : MiniKdc(org.apache.hadoop.minikdc.MiniKdc) IOException(java.io.IOException) BeforeClass(org.junit.BeforeClass)

Example 2 with MiniKdc

use of org.apache.hadoop.minikdc.MiniKdc in project hadoop by apache.

the class TestRMWebServicesDelegationTokenAuthentication method setUp.

@BeforeClass
public static void setUp() {
    try {
        testMiniKDC = new MiniKdc(MiniKdc.createConf(), testRootDir);
        setupKDC();
        setupAndStartRM();
    } catch (Exception e) {
        assertTrue("Couldn't create MiniKDC", false);
    }
}
Also used : MiniKdc(org.apache.hadoop.minikdc.MiniKdc) IOException(java.io.IOException) BeforeClass(org.junit.BeforeClass)

Example 3 with MiniKdc

use of org.apache.hadoop.minikdc.MiniKdc in project hadoop by apache.

the class TestRMWebServicesDelegationTokens method setupKDC.

@BeforeClass
public static void setupKDC() throws Exception {
    testRootDir = new File("target", TestRMWebServicesDelegationTokens.class.getName() + "-root");
    testMiniKDC = new MiniKdc(MiniKdc.createConf(), testRootDir);
    testMiniKDC.start();
    testMiniKDC.createPrincipal(httpSpnegoKeytabFile, "HTTP/localhost", "client", "client2", "client3");
}
Also used : MiniKdc(org.apache.hadoop.minikdc.MiniKdc) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 4 with MiniKdc

use of org.apache.hadoop.minikdc.MiniKdc in project hadoop by apache.

the class AbstractSecureRegistryTest method setupKDCAndPrincipals.

/**
   * Sets up the KDC and a set of principals in the JAAS file
   *
   * @throws Exception
   */
public static void setupKDCAndPrincipals() throws Exception {
    // set up the KDC
    File target = new File(System.getProperty("test.dir", "target"));
    kdcWorkDir = new File(target, "kdc");
    kdcWorkDir.mkdirs();
    if (!kdcWorkDir.mkdirs()) {
        assertTrue(kdcWorkDir.isDirectory());
    }
    kdcConf = MiniKdc.createConf();
    kdcConf.setProperty(MiniKdc.DEBUG, "true");
    kdc = new MiniKdc(kdcConf, kdcWorkDir);
    kdc.start();
    keytab_zk = createKeytab(ZOOKEEPER, "zookeeper.keytab");
    keytab_alice = createKeytab(ALICE, "alice.keytab");
    keytab_bob = createKeytab(BOB, "bob.keytab");
    zkServerPrincipal = Shell.WINDOWS ? ZOOKEEPER_1270001 : ZOOKEEPER_LOCALHOST;
    StringBuilder jaas = new StringBuilder(1024);
    jaas.append(registrySecurity.createJAASEntry(ZOOKEEPER_CLIENT_CONTEXT, ZOOKEEPER, keytab_zk));
    jaas.append(registrySecurity.createJAASEntry(ZOOKEEPER_SERVER_CONTEXT, zkServerPrincipal, keytab_zk));
    jaas.append(registrySecurity.createJAASEntry(ALICE_CLIENT_CONTEXT, ALICE_LOCALHOST, keytab_alice));
    jaas.append(registrySecurity.createJAASEntry(BOB_CLIENT_CONTEXT, BOB_LOCALHOST, keytab_bob));
    jaasFile = new File(kdcWorkDir, "jaas.txt");
    FileUtils.write(jaasFile, jaas.toString());
    LOG.info("\n" + jaas);
    RegistrySecurity.bindJVMtoJAASFile(jaasFile);
}
Also used : MiniKdc(org.apache.hadoop.minikdc.MiniKdc) File(java.io.File)

Example 5 with MiniKdc

use of org.apache.hadoop.minikdc.MiniKdc in project hadoop by apache.

the class TestTimelineAuthenticationFilter method setup.

@BeforeClass
public static void setup() {
    try {
        testMiniKDC = new MiniKdc(MiniKdc.createConf(), testRootDir);
        testMiniKDC.start();
        testMiniKDC.createPrincipal(httpSpnegoKeytabFile, HTTP_USER + "/localhost");
    } catch (Exception e) {
        assertTrue("Couldn't setup MiniKDC", false);
    }
    try {
        testTimelineServer = new ApplicationHistoryServer();
        conf = new Configuration(false);
        conf.setStrings(TimelineAuthenticationFilterInitializer.PREFIX + "type", "kerberos");
        conf.set(TimelineAuthenticationFilterInitializer.PREFIX + KerberosAuthenticationHandler.PRINCIPAL, httpSpnegoPrincipal);
        conf.set(TimelineAuthenticationFilterInitializer.PREFIX + KerberosAuthenticationHandler.KEYTAB, httpSpnegoKeytabFile.getAbsolutePath());
        conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
        conf.set(YarnConfiguration.TIMELINE_SERVICE_PRINCIPAL, httpSpnegoPrincipal);
        conf.set(YarnConfiguration.TIMELINE_SERVICE_KEYTAB, httpSpnegoKeytabFile.getAbsolutePath());
        conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
        conf.setClass(YarnConfiguration.TIMELINE_SERVICE_STORE, MemoryTimelineStore.class, TimelineStore.class);
        conf.set(YarnConfiguration.TIMELINE_SERVICE_ADDRESS, "localhost:10200");
        conf.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, "localhost:8188");
        conf.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_HTTPS_ADDRESS, "localhost:8190");
        conf.set("hadoop.proxyuser.HTTP.hosts", "*");
        conf.set("hadoop.proxyuser.HTTP.users", FOO_USER);
        conf.setInt(YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES, 1);
        if (withSsl) {
            conf.set(YarnConfiguration.YARN_HTTP_POLICY_KEY, HttpConfig.Policy.HTTPS_ONLY.name());
            File base = new File(BASEDIR);
            FileUtil.fullyDelete(base);
            base.mkdirs();
            keystoresDir = new File(BASEDIR).getAbsolutePath();
            sslConfDir = KeyStoreTestUtil.getClasspathDir(TestTimelineAuthenticationFilter.class);
            KeyStoreTestUtil.setupSSLConfig(keystoresDir, sslConfDir, conf, false);
        }
        UserGroupInformation.setConfiguration(conf);
        testTimelineServer.init(conf);
        testTimelineServer.start();
    } catch (Exception e) {
        assertTrue("Couldn't setup TimelineServer", false);
    }
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) MiniKdc(org.apache.hadoop.minikdc.MiniKdc) ApplicationHistoryServer(org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryServer) File(java.io.File) AuthenticationException(org.apache.hadoop.security.authentication.client.AuthenticationException) AuthorizationException(org.apache.hadoop.security.authorize.AuthorizationException) BeforeClass(org.junit.BeforeClass)

Aggregations

MiniKdc (org.apache.hadoop.minikdc.MiniKdc)41 File (java.io.File)33 Properties (java.util.Properties)18 BeforeClass (org.junit.BeforeClass)15 Configuration (org.apache.hadoop.conf.Configuration)10 FileWriter (java.io.FileWriter)5 IOException (java.io.IOException)5 Before (org.junit.Before)5 BindException (java.net.BindException)4 Closeable (java.io.Closeable)3 Writer (java.io.Writer)3 HBaseTestingUtil (org.apache.hadoop.hbase.HBaseTestingUtil)3 AuthenticationTokenIdentifier (org.apache.hadoop.hbase.security.token.AuthenticationTokenIdentifier)3 Text (org.apache.hadoop.io.Text)3 Job (org.apache.hadoop.mapreduce.Job)3 Credentials (org.apache.hadoop.security.Credentials)3 Token (org.apache.hadoop.security.token.Token)3 TokenIdentifier (org.apache.hadoop.security.token.TokenIdentifier)3 Test (org.junit.Test)3 ApplicationProperties (org.apache.atlas.ApplicationProperties)2