Search in sources :

Example 21 with SimpleKdcServer

use of org.apache.kerby.kerberos.kerb.server.SimpleKdcServer in project drill by axbaretto.

the class KerberosHelper method setupKdc.

public void setupKdc(File workspace) throws Exception {
    this.workspace = workspace;
    kdc = new SimpleKdcServer();
    kdcDir = new File(workspace, testName);
    if (!kdcDir.mkdirs()) {
        throw new Exception(String.format("Failed to create the kdc directory %s", kdcDir.getName()));
    }
    kdc.setWorkDir(kdcDir);
    kdc.setKdcHost(HOSTNAME);
    kdcPort = getFreePort();
    kdc.setAllowTcp(true);
    kdc.setAllowUdp(false);
    kdc.setKdcTcpPort(kdcPort);
    logger.debug("Starting KDC server at {}:{}", HOSTNAME, kdcPort);
    kdc.init();
    kdc.start();
    kdcStarted = true;
    keytabDir = new File(workspace, testName + "_keytabs");
    if (!keytabDir.mkdirs()) {
        throw new Exception(String.format("Failed to create the keytab directory %s", keytabDir.getName()));
    }
    setupUsers(keytabDir);
    // Kerby sets "java.security.krb5.conf" for us!
    System.clearProperty("java.security.auth.login.config");
    System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
// Uncomment the following lines for debugging.
// System.setProperty("sun.security.spnego.debug", "true");
// System.setProperty("sun.security.krb5.debug", "true");
}
Also used : File(java.io.File) IOException(java.io.IOException) KrbException(org.apache.kerby.kerberos.kerb.KrbException) SimpleKdcServer(org.apache.kerby.kerberos.kerb.server.SimpleKdcServer)

Example 22 with SimpleKdcServer

use of org.apache.kerby.kerberos.kerb.server.SimpleKdcServer in project testcases by coheigea.

the class KafkaAuthorizerSASLGSSTest method configureKerby.

private static void configureKerby(String baseDir) throws Exception {
    // System.setProperty("sun.security.krb5.debug", "true");
    System.setProperty("java.security.krb5.conf", baseDir + "/target/krb5.conf");
    kerbyServer = new SimpleKdcServer();
    kerbyServer.setKdcRealm("kafka.apache.org");
    kerbyServer.setAllowUdp(false);
    kerbyServer.setWorkDir(new File(baseDir + "/target"));
    kerbyServer.init();
    // Create principals
    String zookeeper = "zookeeper/127.0.0.1@kafka.apache.org";
    String kafka = "kafka/localhost@kafka.apache.org";
    String client = "client@kafka.apache.org";
    kerbyServer.createPrincipal(zookeeper, "zookeeper");
    File keytabFile = new File(baseDir + "/target/zookeeper.keytab");
    kerbyServer.exportPrincipal(zookeeper, keytabFile);
    kerbyServer.createPrincipal(kafka, "kafka");
    keytabFile = new File(baseDir + "/target/kafka.keytab");
    kerbyServer.exportPrincipal(kafka, keytabFile);
    kerbyServer.createPrincipal(client, "client");
    keytabFile = new File(baseDir + "/target/client.keytab");
    kerbyServer.exportPrincipal(client, keytabFile);
    kerbyServer.start();
}
Also used : File(java.io.File) SimpleKdcServer(org.apache.kerby.kerberos.kerb.server.SimpleKdcServer)

Example 23 with SimpleKdcServer

use of org.apache.kerby.kerberos.kerb.server.SimpleKdcServer in project testcases by coheigea.

the class JWTJAXRSAuthenticationTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    Provider provider = new KerbyGssProvider();
    java.security.Security.insertProviderAt(provider, 1);
    WSSConfig.init();
    String basedir = System.getProperty("basedir");
    if (basedir == null) {
        basedir = new File(".").getCanonicalPath();
    }
    kerbyServer = new SimpleKdcServer();
    kerbyServer.setKdcRealm("service.ws.apache.org");
    kerbyServer.setAllowUdp(true);
    kerbyServer.setWorkDir(new File(basedir + "/target"));
    kerbyServer.setInnerKdcImpl(new NettyKdcServerImpl(kerbyServer.getKdcSetting()));
    kerbyServer.getKdcConfig().setString(KdcConfigKey.TOKEN_ISSUERS, "DoubleItSTSIssuer");
    kerbyServer.getKdcConfig().setString(KdcConfigKey.TOKEN_VERIFY_KEYS, "mysts.cer");
    kerbyServer.init();
    // Create principals
    String alice = "alice@service.ws.apache.org";
    String dave = "dave@service.ws.apache.org";
    String bob = "bob/service.ws.apache.org@service.ws.apache.org";
    kerbyServer.createPrincipal(alice, "alice");
    kerbyServer.createPrincipal(dave, "dave");
    kerbyServer.createPrincipal(bob, "bob");
    kerbyServer.start();
    // System.setProperty("sun.security.krb5.debug", "true");
    System.setProperty("java.security.auth.login.config", basedir + "/target/test-classes/kerberos/kerberos.jaas");
    System.setProperty("java.security.krb5.conf", basedir + "/target/krb5.conf");
    Assert.assertTrue("Server failed to launch", // set this to false to fork
    AbstractBusClientServerTestBase.launchServer(Server.class, true));
    Assert.assertTrue("Server failed to launch", // set this to false to fork
    AbstractBusClientServerTestBase.launchServer(STSRESTServer.class, true));
}
Also used : KerbyGssProvider(org.apache.kerby.kerberos.kerb.gss.KerbyGssProvider) SimpleKdcServer(org.apache.kerby.kerberos.kerb.server.SimpleKdcServer) NettyKdcServerImpl(org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl) File(java.io.File) Provider(java.security.Provider) KerbyGssProvider(org.apache.kerby.kerberos.kerb.gss.KerbyGssProvider) SimpleKdcServer(org.apache.kerby.kerberos.kerb.server.SimpleKdcServer) BeforeClass(org.junit.BeforeClass)

Example 24 with SimpleKdcServer

use of org.apache.kerby.kerberos.kerb.server.SimpleKdcServer in project testcases by coheigea.

the class JAXRSAuthenticationTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    WSSConfig.init();
    String basedir = System.getProperty("basedir");
    if (basedir == null) {
        basedir = new File(".").getCanonicalPath();
    }
    kerbyServer = new SimpleKdcServer();
    kerbyServer.setKdcRealm("service.ws.apache.org");
    kerbyServer.setAllowUdp(true);
    kerbyServer.setWorkDir(new File(basedir + "/target"));
    kerbyServer.setInnerKdcImpl(new NettyKdcServerImpl(kerbyServer.getKdcSetting()));
    kerbyServer.init();
    // Create principals
    String alice = "alice@service.ws.apache.org";
    String bob = "bob/service.ws.apache.org@service.ws.apache.org";
    kerbyServer.createPrincipal(alice, "alice");
    kerbyServer.createPrincipal(bob, "bob");
    kerbyServer.start();
    // System.setProperty("sun.security.krb5.debug", "true");
    System.setProperty("java.security.auth.login.config", basedir + "/target/test-classes/kerberos/kerberos.jaas");
    System.setProperty("java.security.krb5.conf", basedir + "/target/krb5.conf");
    Assert.assertTrue("Server failed to launch", // set this to false to fork
    AbstractBusClientServerTestBase.launchServer(Server.class, true));
}
Also used : SimpleKdcServer(org.apache.kerby.kerberos.kerb.server.SimpleKdcServer) NettyKdcServerImpl(org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl) File(java.io.File) SimpleKdcServer(org.apache.kerby.kerberos.kerb.server.SimpleKdcServer) BeforeClass(org.junit.BeforeClass)

Example 25 with SimpleKdcServer

use of org.apache.kerby.kerberos.kerb.server.SimpleKdcServer in project testcases by coheigea.

the class AuthenticationTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    WSSConfig.init();
    String basedir = System.getProperty("basedir");
    if (basedir == null) {
        basedir = new File(".").getCanonicalPath();
    }
    KrbRuntime.setTokenProvider(new JwtTokenProvider());
    kerbyServer = new SimpleKdcServer();
    kerbyServer.setKdcRealm("service.ws.apache.org");
    kerbyServer.setAllowUdp(true);
    kerbyServer.setWorkDir(new File(basedir + "/target"));
    kerbyServer.setInnerKdcImpl(new NettyKdcServerImpl(kerbyServer.getKdcSetting()));
    kerbyServer.getKdcConfig().setString(KdcConfigKey.TOKEN_ISSUERS, "DoubleItSTSIssuer");
    kerbyServer.getKdcConfig().setString(KdcConfigKey.TOKEN_VERIFY_KEYS, "myclient.cer");
    kerbyServer.init();
    // Create principals
    String alice = "alice@service.ws.apache.org";
    String bob = "bob/service.ws.apache.org@service.ws.apache.org";
    kerbyServer.createPrincipal(alice, "alice");
    kerbyServer.createPrincipal(bob, "bob");
    kerbyServer.start();
    System.setProperty("sun.security.krb5.debug", "true");
    System.setProperty("java.security.auth.login.config", basedir + "/target/test-classes/kerberos/kerberos.jaas");
    System.setProperty("java.security.krb5.conf", basedir + "/target/krb5.conf");
    Assert.assertTrue("Server failed to launch", // set this to false to fork
    AbstractBusClientServerTestBase.launchServer(Server.class, true));
}
Also used : JwtTokenProvider(org.apache.kerby.kerberos.provider.token.JwtTokenProvider) SimpleKdcServer(org.apache.kerby.kerberos.kerb.server.SimpleKdcServer) NettyKdcServerImpl(org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl) File(java.io.File) SimpleKdcServer(org.apache.kerby.kerberos.kerb.server.SimpleKdcServer) BeforeClass(org.junit.BeforeClass)

Aggregations

SimpleKdcServer (org.apache.kerby.kerberos.kerb.server.SimpleKdcServer)25 File (java.io.File)22 BeforeClass (org.junit.BeforeClass)14 NettyKdcServerImpl (org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl)6 KrbConfig (org.apache.kerby.kerberos.kerb.client.KrbConfig)3 IOException (java.io.IOException)2 URL (java.net.URL)2 SpnegoTestUtil (org.apache.calcite.avatica.SpnegoTestUtil)2 KrbException (org.apache.kerby.kerberos.kerb.KrbException)2 JwtTokenProvider (org.apache.kerby.kerberos.provider.token.JwtTokenProvider)2 Provider (java.security.Provider)1 STSServer (org.apache.cxf.systest.kerberos.wssec.sts.STSServer)1 StaxSTSServer (org.apache.cxf.systest.kerberos.wssec.sts.StaxSTSServer)1 KerbyGssProvider (org.apache.kerby.kerberos.kerb.gss.KerbyGssProvider)1