Search in sources :

Example 1 with KrbPkinitClient

use of org.apache.kerby.kerberos.kerb.client.KrbPkinitClient in project testcases by coheigea.

the class AnonymousPKInitTest method unitTest.

@org.junit.Test
public void unitTest() throws Exception {
    KrbPkinitClient client = new KrbPkinitClient();
    client.setKdcHost("localhost");
    client.setKdcTcpPort(kerbyServer.getKdcPort());
    client.setAllowUdp(false);
    // client.setKdcUdpPort(Integer.parseInt(KDC_UDP_PORT));
    client.setKdcRealm(kerbyServer.getKdcSetting().getKdcRealm());
    // client.getKrbConfig().setString(KrbConfigKey.PKINIT_ANCHORS, "myclient.cer");
    String pkinitAnchors = AnonymousPKInitTest.class.getResource("/cacerttest.pem").getPath();
    client.getKrbConfig().setString(KrbConfigKey.PKINIT_ANCHORS, pkinitAnchors);
    client.init();
    try {
        TgtTicket tgt = client.requestTgt();
        assertTrue(tgt != null);
        SgtTicket tkt = client.requestSgt(tgt, "bob/service.ws.apache.org@service.ws.apache.org");
        assertTrue(tkt != null);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }
}
Also used : TgtTicket(org.apache.kerby.kerberos.kerb.type.ticket.TgtTicket) SgtTicket(org.apache.kerby.kerberos.kerb.type.ticket.SgtTicket) KrbPkinitClient(org.apache.kerby.kerberos.kerb.client.KrbPkinitClient) KrbException(org.apache.kerby.kerberos.kerb.KrbException)

Aggregations

KrbException (org.apache.kerby.kerberos.kerb.KrbException)1 KrbPkinitClient (org.apache.kerby.kerberos.kerb.client.KrbPkinitClient)1 SgtTicket (org.apache.kerby.kerberos.kerb.type.ticket.SgtTicket)1 TgtTicket (org.apache.kerby.kerberos.kerb.type.ticket.TgtTicket)1