Search in sources :

Example 1 with NettyKdcServerImpl

use of org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl in project testcases by coheigea.

the class AnonymousPKInitTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    WSSConfig.init();
    String basedir = System.getProperty("basedir");
    if (basedir == null) {
        basedir = new File(".").getCanonicalPath();
    }
    System.setProperty("sun.security.krb5.debug", "true");
    System.setProperty("java.security.auth.login.config", basedir + "/target/test-classes/kerberos/kerberos.jaas");
    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.PKINIT_IDENTITY, "myclient.cer");
    String pkinitIdentity = AnonymousPKInitTest.class.getResource("/kdccerttest.pem").getPath();
    // TODO private key should be required?+ AnonymousPKInitTest.class.getResource("/kdckey.pem").getPath();
    kerbyServer.getKdcConfig().setString(KdcConfigKey.PKINIT_IDENTITY, pkinitIdentity);
    kerbyServer.getKdcConfig().setBoolean(KdcConfigKey.PREAUTH_REQUIRED, Boolean.TRUE);
    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.createPrincipal(KrbConstant.ANONYMOUS_PRINCIPAL + "@service.ws.apache.org");
    kerbyServer.start();
    System.setProperty("java.security.krb5.conf", basedir + "/target/krb5.conf");
}
Also used : 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 2 with NettyKdcServerImpl

use of org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl in project testcases by coheigea.

the class TokenPreAuthTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    WSSConfig.init();
    String basedir = System.getProperty("basedir");
    if (basedir == null) {
        basedir = new File(".").getCanonicalPath();
    }
    System.setProperty("sun.security.krb5.debug", "true");
    System.setProperty("java.security.auth.login.config", basedir + "/target/test-classes/kerberos/kerberos.jaas");
    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("java.security.krb5.conf", basedir + "/target/krb5.conf");
}
Also used : JwtTokenProvider(org.apache.kerby.kerberos.provider.token.JwtTokenProvider) 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 3 with NettyKdcServerImpl

use of org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl in project pac4j by pac4j.

the class KerberosClientsKerbyTests method setupKerbyServer.

private static void setupKerbyServer() throws KrbException, IOException {
    kerbyServer = new SimpleKdcServer();
    kerbyServer.setKdcHost("localhost");
    kerbyServer.setKdcRealm("MYREALM.LT");
    kerbyServer.setAllowUdp(true);
    // kerbyServer.setWorkDir(new File(basedir + "/target"));
    kerbyServer.setInnerKdcImpl(new NettyKdcServerImpl(kerbyServer.getKdcSetting()));
    kerbyServer.init();
    // Create principals
    kerbyServer.createPrincipal(clientPrincipal, clientPassword);
    kerbyServer.createPrincipal(servicePrincipal, "servicePrincipal");
    kerbyServer.getKadmin().exportKeytab(serviceKeytabFile, servicePrincipal);
    // System.out.println(new String(Files.readAllBytes(serviceKeytabFile.toPath())));
    kerbyServer.start();
}
Also used : NettyKdcServerImpl(org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl) SimpleKdcServer(org.apache.kerby.kerberos.kerb.server.SimpleKdcServer)

Example 4 with NettyKdcServerImpl

use of org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl 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 5 with NettyKdcServerImpl

use of org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl 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)

Aggregations

NettyKdcServerImpl (org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl)6 SimpleKdcServer (org.apache.kerby.kerberos.kerb.server.SimpleKdcServer)6 File (java.io.File)5 BeforeClass (org.junit.BeforeClass)5 JwtTokenProvider (org.apache.kerby.kerberos.provider.token.JwtTokenProvider)2 Provider (java.security.Provider)1 KerbyGssProvider (org.apache.kerby.kerberos.kerb.gss.KerbyGssProvider)1