Search in sources :

Example 1 with JwtTokenProvider

use of org.apache.kerby.kerberos.provider.token.JwtTokenProvider 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 2 with JwtTokenProvider

use of org.apache.kerby.kerberos.provider.token.JwtTokenProvider in project testcases by coheigea.

the class KerbyHttpAuthSupplier method decorateSubject.

@Override
protected void decorateSubject(Subject subject) {
    KrbRuntime.setTokenProvider(new JwtTokenProvider());
    try {
        JWT jwt = JWTParser.parse(jwtToken);
        AuthToken authToken = new JwtAuthToken(jwt.getJWTClaimsSet());
        KrbToken krbToken = new KrbToken(authToken, TokenFormat.JWT);
        krbToken.setTokenValue(jwtToken.getBytes());
        subject.getPrivateCredentials().add(krbToken);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : JwtTokenProvider(org.apache.kerby.kerberos.provider.token.JwtTokenProvider) JwtAuthToken(org.apache.kerby.kerberos.provider.token.JwtAuthToken) KrbToken(org.apache.kerby.kerberos.kerb.type.base.KrbToken) JWT(com.nimbusds.jwt.JWT) AuthToken(org.apache.kerby.kerberos.kerb.type.base.AuthToken) JwtAuthToken(org.apache.kerby.kerberos.provider.token.JwtAuthToken) ParseException(java.text.ParseException)

Example 3 with JwtTokenProvider

use of org.apache.kerby.kerberos.provider.token.JwtTokenProvider 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

JwtTokenProvider (org.apache.kerby.kerberos.provider.token.JwtTokenProvider)3 File (java.io.File)2 NettyKdcServerImpl (org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl)2 SimpleKdcServer (org.apache.kerby.kerberos.kerb.server.SimpleKdcServer)2 BeforeClass (org.junit.BeforeClass)2 JWT (com.nimbusds.jwt.JWT)1 ParseException (java.text.ParseException)1 AuthToken (org.apache.kerby.kerberos.kerb.type.base.AuthToken)1 KrbToken (org.apache.kerby.kerberos.kerb.type.base.KrbToken)1 JwtAuthToken (org.apache.kerby.kerberos.provider.token.JwtAuthToken)1