Hy everyone!
We are trying to secure an embedded restfull Jetty-Application with Keycloak. We have
managed to redirect to the Keycloak server when a secured area on our webservice is called as also our service is called/redirected to, after login.
However after successfull login, we get an NullPointerException (below).
What we have debugged so far: Stateless is required, therefore we are using cookie-tokenstore. The informations are set correctly to the cookie. However it seams this informations are not assigned to/by the adapter during the redirect request.
Did anyone run into the same error? Any help/hint would be appreciated! Thanks
[WARN ] 2016-02-15 16:29:55.884 [pool-2-thread-18] HttpChannel - /
java.lang.NullPointerException
at org.keycloak.adapters.jetty.core.AbstractKeycloakJettyAuthenticator.createIdentity(AbstractKeycloakJettyAuthenticator.java:110) ~[keycloak-jetty-core-1.8.1.Final.jar:1.8.1.Final]
at org.keycloak.adapters.jetty.core.AbstractKeycloakJettyAuthenticator.register(AbstractKeycloakJettyAuthenticator.java:289) ~[keycloak-jetty-core-1.8.1.Final.jar:1.8.1.Final]
at org.keycloak.adapters.jetty.core.AbstractKeycloakJettyAuthenticator.validateRequest(AbstractKeycloakJettyAuthenticator.java:257) ~[keycloak-jetty-core-1.8.1.Final.jar:1.8.1.Final]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:512) ~[jetty-security-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.Server.handle(Server.java:497) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [jetty-io-9.2.10.v20150310.jar:9.2.10.v20150310]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_72]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_72]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_72]
Our adapterconfiguration looks like this:
KeycloakJettyAuthenticator keycloakAuthenticator = new KeycloakJettyAuthenticator();
AdapterConfig keycloakAdapterConfig = new AdapterConfig();
keycloakAdapterConfig.setRealm("myRealm");
keycloakAdapterConfig.setRealmKey("MIIBIjANB ... RsvQIDAQAB");
keycloakAdapterConfig.setSslRequired("external");
keycloakAdapterConfig.setResource("myRealmClient");
keycloakAdapterConfig.setPublicClient(true);
keycloakAdapterConfig.setUseResourceRoleMappings(true);
keycloakAdapterConfig.setTokenStore("cookie");
And to the pom.xml we added following dependecies:
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-jetty92-adapter</artifactId>
<version>1.8.1.Final</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<version>1.8.1.Final</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-services</artifactId>
<version>1.8.1.Final</version>
</dependency>