0
votes

I am running wso2is Version 5.7 and tried to implement a TokenGenerator based on msf4j JWTAccessTokenBuilder.

My identity.xml includes

<IdentityOAuthTokenGenerator>com.wso2.jwt.token.builder.JWTAccessTokenBuilder</IdentityOAuthTokenGenerator> <AccessTokenValueGenerator>org.wso2.carbon.identity.oauth.tokenvaluegenerator.SHA256Generator</AccessTokenValueGenerator>

When I login an exception is thrown

[2019-05-16 18:27:18,163] ERROR {org.apache.catalina.core.StandardWrapperValve} - Servlet.service() for servlet [OAuth2Endpoints] in context with path [/oauth2] threw exception java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: com/nimbusds/jwt/ReadOnlyJWTClaimsSet at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:116)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:336)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:249)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:248)
...
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.cxf.interceptor.Fault:
com/nimbusds/jwt/ReadOnlyJWTClaimsSet
at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:170)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:136)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:204)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:101)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
... 49 more Caused by: java.lang.NoClassDefFoundError: com/nimbusds/jwt/ReadOnlyJWTClaimsSet
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
...
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:188)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:104)
... 54 more Caused by: java.lang.ClassNotFoundException: com.nimbusds.jwt.ReadOnlyJWTClaimsSet cannot be found by JWTAccessTokenBuilder_2.7.4.SNAPSHOT

Can anybody give me a hint?

2

2 Answers

0
votes

As per the error com.nimbusds.jwt.ReadOnlyJWTClaimsSet cannot be found by JWTAccessTokenBuilder_2.7.4.SNAPSHOT, it is due to the OSGi class binding. In the maven-bundle-plugin configuration Import-Package of the pom, make sure you have the com.nimbusds.jwt with the correct version range.

Or the quick fix is to add <DynamicImport-Package>*</DynamicImport-Package>

0
votes

I found the problem: I used an old version of org.wso2.carbon.identity.inbound.auth.oauth2 I updated the pom.xml to

<dependency>
      <groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
      <artifactId>org.wso2.carbon.identity.oauth</artifactId>
      <version>6.0.172</version>
      <scope>provided</scope>
 </dependency>

from https://mvnrepository.com and had to update the code to use the version of com.nimbusds.jwt used by wso2is. And finally in the service provider settings you must select the Token Issuer.