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");
}
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();
}
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));
}
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));
}
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));
}
Aggregations