[keycloak-user] NPE When trying to authorise unknown user

Stian Thorgersen stian at redhat.com
Tue Jun 10 06:42:10 EDT 2014


Even better, you can also submit a PR on Github for it.

----- Original Message -----
> From: "Conrad Winchester" <conrad at mindless.com>
> To: keycloak-user at lists.jboss.org
> Sent: Monday, 9 June, 2014 6:45:35 AM
> Subject: [keycloak-user] NPE When trying to authorise unknown user
> 
> Hi Keycloak people,
> 
> First of all another really big thank you. I think this project is awesome
> and its really come on a long way from the alpha releases. Thanks for all
> the hard work.
> 
> I have encountered an issue, that might be a bug. If it is please can you
> tell me where to report it.
> 
> Basically I am doing a direct access grant like the example in Chapter 13 of
> the documents. If I send in a username that does exist in the database but
> with a wrong password then it fails to authorise me correctly, but If I send
> in a username that does not exist in the database for that realm, then
> Keycloak throws an NPE rather than not authorising.
> 
> Here is a stack trace.
> 
> 
> I hope this helps
> 
> 
> Conrad
> 
> [0m[0m06:01:34,613 INFO  [org.keycloak.adapters.RequestAuthenticator]
> (default task-56) --> authenticate()
> [0m[0m06:01:34,613 INFO  [org.keycloak.adapters.RequestAuthenticator]
> (default task-56) try bearer
> [0m[0m06:01:34,613 INFO  [org.keycloak.adapters.RequestAuthenticator]
> (default task-56) NOT_ATTEMPTED: bearer only
> [0m[31m06:01:34,629 ERROR [io.undertow.request] (default task-57) UT005023:
> Exception handling request to /auth/realms/shift/tokens/grants/access:
> org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
> 	at
> 	org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at
> 	org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at
> 	org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at
> 	org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at
> 	org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at
> 	org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at
> 	org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at
> 	org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
> 	[jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
> 	at
> 	io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	org.keycloak.services.filters.ClientConnectionFilter.doFilter(ClientConnectionFilter.java:41)
> 	[keycloak-services-1.0-beta-2.jar:]
> 	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	org.keycloak.services.filters.KeycloakSessionServletFilter.doFilter(KeycloakSessionServletFilter.java:41)
> 	[keycloak-services-1.0-beta-2.jar:]
> 	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
> 	at
> 	io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
> 	[undertow-core-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
> 	[undertow-core-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
> 	[undertow-core-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
> 	[undertow-core-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
> 	[undertow-core-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
> 	[undertow-core-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
> 	at
> 	io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
> 	[undertow-core-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
> 	[undertow-core-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
> 	[undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
> 	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
> 	[undertow-core-1.0.15.Final.jar:1.0.15.Final]
> 	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)
> 	[undertow-core-1.0.15.Final.jar:1.0.15.Final]
> 	at
> 	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> 	[rt.jar:1.8.0]
> 	at
> 	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> 	[rt.jar:1.8.0]
> 	at java.lang.Thread.run(Thread.java:744) [rt.jar:1.8.0]
> Caused by: java.lang.NullPointerException
> 	at org.keycloak.audit.Audit.user(Audit.java:54)
> 	[keycloak-audit-api-1.0-beta-2.jar:]
> 	at
> 	org.keycloak.services.resources.TokenService.grantAccessToken(TokenService.java:244)
> 	[keycloak-services-1.0-beta-2.jar:]
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	[rt.jar:1.8.0]
> 	at
> 	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	[rt.jar:1.8.0]
> 	at
> 	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	[rt.jar:1.8.0]
> 	at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0]
> 	at
> 	org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at
> 	org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at
> 	org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at
> 	org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:140)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at
> 	org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:103)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	at
> 	org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)
> 	[resteasy-jaxrs-3.0.8.Final.jar:]
> 	... 39 more
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
> 


More information about the keycloak-user mailing list