<div dir="ltr">Hi Bill,<div><br></div><div><br></div><div>I added the <b>org.keycloak.KeycloakPrincipal</b> definition in order to get the token: </div><div><br></div><div><br></div><div>KeycloakPrincipal kcPrincipal = (KeycloakPrincipal) srvl.getUserPrincipal();</div><div>String token = kcPrincipal.getKeycloakSecurityContext().getTokenString();<br></div><div><br></div><div>but cannot deploy the project to the Wildfly server:</div><div><br></div><div>10:23:31,250 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-2) Deploying javax.ws.rs.core.Application: class si.liis.apitime.service.ApiTimeApplication</div><div>10:23:31,282 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./apitime-rest: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./apitime-rest: Failed to start service</div><div><span class="" style="white-space:pre">        </span>at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]</div><div><span class="" style="white-space:pre">        </span>at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_85]</div><div><span class="" style="white-space:pre">        </span>at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_85]</div><div><span class="" style="white-space:pre">        </span>at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_85]</div><div>Caused by: java.lang.NoClassDefFoundError: com/google/zxing/WriterException</div><div><span class="" style="white-space:pre">        </span>at java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.7.0_85]</div><div><span class="" style="white-space:pre">        </span>at java.lang.Class.privateGetDeclaredMethods(Class.java:2625) [rt.jar:1.7.0_85]</div><div><span class="" style="white-space:pre">        </span>at java.lang.Class.privateGetPublicMethods(Class.java:2743) [rt.jar:1.7.0_85]</div><div><span class="" style="white-space:pre">        </span>at java.lang.Class.getMethods(Class.java:1480) [rt.jar:1.7.0_85]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.resteasy.spi.metadata.ResourceBuilder.fromAnnotations(ResourceBuilder.java:747)</div><div><span class="" style="white-space:pre">        </span>at org.jboss.resteasy.spi.metadata.ResourceBuilder.rootResourceFromAnnotations(ResourceBuilder.java:700)</div><div><span class="" style="white-space:pre">        </span>at org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.&lt;init&gt;(POJOResourceFactory.java:29)</div><div><span class="" style="white-space:pre">        </span>at org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:75)</div><div><span class="" style="white-space:pre">        </span>at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:400)</div><div><span class="" style="white-space:pre">        </span>at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:241)</div><div><span class="" style="white-space:pre">        </span>at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:112)</div><div><span class="" style="white-space:pre">        </span>at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)</div><div><span class="" style="white-space:pre">        </span>at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)</div><div><span class="" style="white-space:pre">        </span>at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:79)</div><div><span class="" style="white-space:pre">        </span>at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)</div><div><span class="" style="white-space:pre">        </span>at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:220)</div><div><span class="" style="white-space:pre">        </span>at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:125)</div><div><span class="" style="white-space:pre">        </span>at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:508)</div><div><span class="" style="white-space:pre">        </span>at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:88)</div><div><span class="" style="white-space:pre">        </span>at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)</div><div><span class="" style="white-space:pre">        </span>at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]</div><div><span class="" style="white-space:pre">        </span>... 3 more</div><div><br></div><div>10:23:31,285 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 1) JBAS014613: Operation (&quot;redeploy&quot;) failed - address: ([(&quot;deployment&quot; =&gt; &quot;apitime-rest.war&quot;)]) - failure description: {&quot;JBAS014671: Failed services&quot; =&gt; {&quot;jboss.undertow.deployment.default-server.default-host./apitime-rest&quot; =&gt; &quot;org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./apitime-rest: Failed to start service</div><div>    Caused by: java.lang.NoClassDefFoundError: com/google/zxing/WriterException&quot;}}</div><div>10:23:31,285 ERROR [org.jboss.as.server] (management-handler-thread - 1) JBAS015860: Redeploy of deployment &quot;apitime-rest.war&quot; was rolled back with the following failure message: </div><div>{&quot;JBAS014671: Failed services&quot; =&gt; {&quot;jboss.undertow.deployment.default-server.default-host./apitime-rest&quot; =&gt; &quot;org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./apitime-rest: Failed to start service</div><div>    Caused by: java.lang.NoClassDefFoundError: com/google/zxing/WriterException&quot;}}</div><div> </div><div><br></div><div><br></div><div>I am using Wildfly 8.2.0 with Keycloak adapter 1.3.1.</div><div>Any solution?</div><div>Thanks.</div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div style="font-family:arial;font-size:small"><div dir="ltr"><font color="#888888">Regards,<br>Pavel Maslov, MS</font></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Mon, Dec 7, 2015 at 3:53 AM, Bill Burke <span dir="ltr">&lt;<a href="mailto:bburke@redhat.com" target="_blank">bburke@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">For Java HttpServletRequest.isUserInRole() works.  If you typecast the<br>
principal to KeycloakPrincipal you can obtain the AccessToken.<br>
<span class=""><br>
On 12/6/2015 5:39 PM, Pavel Maslov wrote:<br>
&gt; Hi everyone,<br>
&gt;<br>
&gt;<br>
&gt; Do Keycloak adapters support user authorization? I mean, of course they<br>
&gt; do :) For example, the API I have secured with Keycloak receives a<br>
&gt; Keycloak access token from the client. How can I validate the token<br>
&gt; (check user roles) in my code? I am interested in the Java (wildfly) and<br>
&gt; Javascript adapters.<br>
&gt;<br>
</span>&gt; Manually I am using <a href="http://jwt.io" rel="noreferrer" target="_blank">jwt.io</a> &lt;<a href="http://jwt.io" rel="noreferrer" target="_blank">http://jwt.io</a>&gt; to check the token. I am just<br>
<span class="">&gt; curious if the Keycloak adapters support smth similar out of the box.<br>
&gt;<br>
&gt; Thank you for your answers.<br>
&gt;<br>
&gt;<br>
&gt; Regards,<br>
&gt; Pavel Maslov, MS<br>
&gt;<br>
&gt;<br>
</span>&gt; _______________________________________________<br>
&gt; keycloak-user mailing list<br>
&gt; <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
&gt;<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Bill Burke<br>
JBoss, a division of Red Hat<br>
<a href="http://bill.burkecentral.com" rel="noreferrer" target="_blank">http://bill.burkecentral.com</a><br>
_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
</font></span></blockquote></div><br></div>