WSO2 API Manager将Surf OAuth配置为第三方KeyManager

时间:2016-04-27 18:03:19

标签: wso2 api-manager

我正在尝试使用Surf OAuth作为WSO2 API Manager的第三方密钥管理器。遵循https://docs.wso2.com/display/AM1100/Configuring+a+Third-Party+Key+Manager

的文档

我的问题是,当我在api-manager.xml中添加Surf OAuth的配置时,WSO2 API Manager会在尝试读取配置时爆炸NPE。看起来它正在炸毁一些系统属性,如CARBON_HOME和抛出NPE。

是否还有其他人遇到与WSO2 API Manager和Surf OAuth集成类似的问题?我很感兴趣,为什么即使按照一步一步的指示它也不起作用

这是我的api-manager.xml配置

    <APIKeyManager>
    <KeyManagerClientImpl>nl.surfnet.demo.SurfOAuthClient</KeyManagerClientImpl>
    <Configuration>
        <RegistrationEndpoint>http://myserver:8080/admin/resourceServer/101</RegistrationEndpoint>
        <AccessToken>4a3aa6a5-8f37-4267-8911-0e3049ccee86</AccessToken>
        <IntrospectionURL>http://myserver:8080/v1/tokeninfo</IntrospectionURL>
        <ConsumerKey>1ff100f0-3e10-43cc-af2f-129d6a638739</ConsumerKey>
        <ConsumerSecret>3a79061f-4fa9-4d4e-bb6b-3af38e6a6733</ConsumerSecret>
    </Configuration>
</APIKeyManager>

堆栈跟踪

[2016-03-22 16:07:36,381] ERROR - APIKeyMgtServiceComponent Failed to initialize key management service.
org.wso2.carbon.apimgt.api.APIManagementException: Unexpected error occurred while parsing configuration: /opt/wso2am-1.10.0/repository/conf/api-manager.xml
        at org.wso2.carbon.apimgt.impl.APIManagerConfiguration.load(APIManagerConfiguration.java:112)
        at org.wso2.carbon.apimgt.keymgt.internal.APIKeyMgtServiceComponent.activate(APIKeyMgtServiceComponent.java:88)
        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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
        at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
        at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
        at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
        at org.wso2.carbon.identity.thrift.authentication.internal.ThriftAuthenticationServiceComponent.activate(ThriftAuthenticationServiceComponent.java:110)
        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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
        at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
        at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
        at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
        at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:514)
        at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
        at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:94)
        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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
        at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
        at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
        at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
        at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
        at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
        at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
        at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5262)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5550)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        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:745)
Caused by: java.lang.NullPointerException
        at org.wso2.carbon.apimgt.impl.utils.APIUtil.replaceSystemProperty(APIUtil.java:3946)
        at org.wso2.carbon.apimgt.impl.APIManagerConfiguration.readChildElements(APIManagerConfiguration.java:160)
        at org.wso2.carbon.apimgt.impl.APIManagerConfiguration.readChildElements(APIManagerConfiguration.java:265)
        at org.wso2.carbon.apimgt.impl.APIManagerConfiguration.load(APIManagerConfiguration.java:92)
        ... 83 more

1 个答案:

答案 0 :(得分:0)

APIM最新版本(1.10.0)不支持文档中提供的Surf-oauth客户端实现。因此,您需要进行以下更改才能解决问题。

  • 更改SurfOAuthClient.java文件以导入org.wso2.carbon.apimgt.impl.AbstractKeyManager类,而不是org.wso2.carbon.apimgt.keymgt.AbstractKeyManager类。

    import org.wso2.carbon.apimgt.impl.AbstractKeyManager;

  • 更改&#34; org.wso2.carbon.apimgt&#34;的版本pom.xml文件中的组ID为5.0.3,如下所示。

    <dependency>
           <groupId>org.wso2.carbon.apimgt</groupId>
           <artifactId>org.wso2.carbon.apimgt.impl</artifactId>
           <version>5.0.3</version>
    </dependency>
    
    <dependency>
           <groupId>org.wso2.carbon.apimgt</groupId>
           <artifactId>org.wso2.carbon.apimgt.gateway</artifactId>
           <version>5.0.3</version>
    </dependency>
    
    <dependency>
           <groupId>org.wso2.carbon.apimgt</groupId>
           <artifactId>org.wso2.carbon.apimgt.keymgt</artifactId>
           <version>5.0.3</version>
    </dependency>
    
    <dependency>
           <groupId>org.wso2.carbon.apimgt</groupId>
           <artifactId>org.wso2.carbon.apimgt.hostobjects</artifactId>
           <version>5.0.3</version>
    </dependency>
    

另请参阅[1]了解固定代码。构建代码,生成war文件和jar文件。 从/ repository / components / lib和/ repository / components / dropins文件夹中删除当前的gateway.client-1.0.0.jar文件,并将生成的jar文件复制到/ repository / components / lib文件夹。

使用生成的war文件并再次进行配置。

[1] https://github.com/jaadds/surf-oauth-demo/tree/v1.10.0