WSO2 API Manager OAuth2TokenValidationService抛出空指针异常

时间:2014-05-20 03:29:27

标签: soap oauth oauth-2.0 wso2 wso2is

WSO2 API Manager OAuth2令牌验证服务抛出空指针异常

我正在从NodeJS向API Manger的OAuth2TokenValidationService服务发送验证请求。第一个验证请求正常。当我使用相同的OAuth令牌再次发送相同的验证请求时,它会给出以下异常。与CURL相同的事情发生。这里出了什么问题?

[2014-05-20 02:41:09,792]  INFO - CarbonAuthenticationUtil 'admin@carbon.super [-1234]' logged in at [2014-05-20 02:41:09,791+0000]
[2014-05-20 02:41:09,885] ERROR - RPCMessageReceiver Exception occurred while trying to invoke service method validate
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
    at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
    at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
    at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
    at org.wso2.carbon.core.transports.CarbonServlet.doPost(CarbonServlet.java:231)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:68)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.wso2.carbon.tomcat.ext.filter.CharacterSetFilter.doFilter(CharacterSetFilter.java:61)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:178)
    at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
    at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:56)
    at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
    at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:141)
    at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:156)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:52)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NullPointerException
    at org.wso2.carbon.identity.oauth.util.ClaimCacheKey.equals(ClaimCacheKey.java:44)
    at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:1024)
    at org.wso2.carbon.caching.impl.CacheImpl.containsKey(CacheImpl.java:260)
    at org.wso2.carbon.identity.oauth.cache.BaseCache.getValueFromCache(BaseCache.java:78)
    at org.wso2.carbon.identity.oauth.util.ClaimCache.getValueFromCache(ClaimCache.java:49)
    at org.wso2.carbon.identity.oauth2.authcontext.JWTTokenGenerator.generateToken(JWTTokenGenerator.java:198)
    at org.wso2.carbon.identity.oauth2.validators.TokenValidationHandler.validate(TokenValidationHandler.java:230)
    at org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService.validate(OAuth2TokenValidationService.java:46)
    ... 45 more

我将此作为SOAP请求发送,

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://org.apache.axis2/xsd"
               xmlns:tns="http://oauth2.identity.carbon.wso2.org"
               xmlns:ax2326="http://dto.oauth2.identity.carbon.wso2.org/xsd" xmlns:ns="http://org.apache.axis2/xsd"
               xmlns:ax2327="http://dto.oauth2.identity.carbon.wso2.org/xsd">
<soap:Header></soap:Header>
<soap:Body>
    <ns1:validate>
        <ns1:validationReqDTO>
            <ax2326:accessToken>
                <ax2326:identifier>c3b2558b28f90172588b569ce62f031</ax2326:identifier>
                <ax2326:tokenType>bearer</ax2326:tokenType>
            </ax2326:accessToken>
        </ns1:validationReqDTO>
    </ns1:validate>
</soap:Body>
</soap:Envelope>

我也启用了,

    <AuthorizationContextTokenGeneration>       
        <Enabled>true</Enabled>
        <TokenGeneratorImplClass>org.wso2.carbon.identity.oauth2.authcontext.JWTTokenGenerator</TokenGeneratorImplClass>
        <ClaimsRetrieverImplClass>org.wso2.carbon.identity.oauth2.authcontext.DefaultClaimsRetriever</ClaimsRetrieverImplClass>
        <ConsumerDialectURI>http://wso2.org/claims</ConsumerDialectURI>
        <SignatureAlgorithm>SHA256withRSA</SignatureAlgorithm>
        <AuthorizationContextTTL>15</AuthorizationContextTTL>
    </AuthorizationContextTokenGeneration>

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。在基于WSDL的SoapUI创建测试用例时,您将看到在accessToken节点旁边有另一个名为“context”的节点。添加节点后,问题就消失了。

在您的情况下使用:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://org.apache.axis2/xsd"
               xmlns:tns="http://oauth2.identity.carbon.wso2.org"
               xmlns:ax2326="http://dto.oauth2.identity.carbon.wso2.org/xsd" xmlns:ns="http://org.apache.axis2/xsd"
               xmlns:ax2327="http://dto.oauth2.identity.carbon.wso2.org/xsd">
<soap:Header></soap:Header>
<soap:Body>
    <ns1:validate>
        <ns1:validationReqDTO>
            <ax2326:accessToken>
                <ax2326:identifier>c3b2558b28f90172588b569ce62f031</ax2326:identifier>
                <ax2326:tokenType>bearer</ax2326:tokenType>
            </ax2326:accessToken>
<ax2326:context></ax2326:context>
        </ns1:validationReqDTO>
    </ns1:validate>
</soap:Body>
</soap:Envelope>