wso2 api manager - wso2:vault-lookup()无效

时间:2017-05-25 10:32:23

标签: wso2 wso2-am wso2carbon

我想配置WSO2 Api Manager在in sequence内发送基本身份验证标头。在我开始配置安全保管库以存储凭据之前,一切都运行良好。

我使用的是Api Manager(https://github.com/wso2/docker-apim/tree/v2.1.0/docker-compose/pattern-2

的dockerized版本

我已尝试在repository/conf/security/cipher-text.properties文件中添加新的保管库条目,但在运行sh bin/ciphertool.sh -Dconfigure后,我收到了例外情况:

Exception in thread "main" org.wso2.ciphertool.exception.CipherToolException: XPath value for secret alias 'ApiManager.BasicAuth.password' cannot be found.
at org.wso2.ciphertool.CipherTool.loadXpathValuesAndPasswordDetails(CipherTool.java:174)
at org.wso2.ciphertool.CipherTool.main(CipherTool.java:56)

这是否意味着我必须将xPath指定给我想在其中使用的序列文件?

除此之外,我想检查是否可以在我的序列中使用位于文件库文件(repository/conf/security/cipher-text.properties)内的任何现有密码,以便我使用了一个值:

<property name="X-SomeHeader" expression="wso2:vault-lookup('UserManager.AdminUser.Password')" scope="transport" type="STRING" description="" />

当我尝试使用此序列运行API时,我收到此异常:

api-manager_1   | [2017-05-25 10:12:04,949] ERROR - SynapseXPath Evaluation of the XPath expression wso2:vault-lookup('UserManager.AdminUser.Password') resulted in an error
api-manager_1   | org.jaxen.FunctionCallException
api-manager_1   |   at org.wso2.carbon.mediation.security.vault.xpath.VaultLookupFunction.call(VaultLookupFunction.java:85)
api-manager_1   |   at org.jaxen.expr.DefaultFunctionCallExpr.evaluate(DefaultFunctionCallExpr.java:181)
api-manager_1   |   at org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:102)
api-manager_1   |   at org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:677)
api-manager_1   |   at org.jaxen.BaseXPath.selectNodes(BaseXPath.java:216)
api-manager_1   |   at org.jaxen.BaseXPath.evaluate(BaseXPath.java:175)
api-manager_1   |   at org.apache.synapse.util.xpath.SynapseXPath.stringValueOf(SynapseXPath.java:297)
api-manager_1   |   at org.apache.synapse.mediators.builtin.PropertyMediator.getResultValue(PropertyMediator.java:346)
api-manager_1   |   at org.apache.synapse.mediators.builtin.PropertyMediator.mediate(PropertyMediator.java:108)
api-manager_1   |   at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
api-manager_1   |   at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)
api-manager_1   |   at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
api-manager_1   |   at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate(APIManagerExtensionHandler.java:67)
api-manager_1   |   at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleRequest(APIManagerExtensionHandler.java:78)
api-manager_1   |   at org.apache.synapse.rest.API.process(API.java:325)
api-manager_1   |   at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:90)
api-manager_1   |   at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:69)
api-manager_1   |   at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:304)
api-manager_1   |   at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:78)
api-manager_1   |   at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
api-manager_1   |   at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:325)
api-manager_1   |   at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:158)
api-manager_1   |   at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
api-manager_1   |   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
api-manager_1   |   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
api-manager_1   |   at java.lang.Thread.run(Thread.java:745)
api-manager_1   | Caused by: java.lang.NullPointerException
api-manager_1   |   at org.wso2.carbon.mediation.security.vault.SecureVaultLookupHandlerImpl.vaultLookup(SecureVaultLookupHandlerImpl.java:166)
api-manager_1   |   at org.wso2.carbon.mediation.security.vault.SecureVaultLookupHandlerImpl.evaluate(SecureVaultLookupHandlerImpl.java:153)
api-manager_1   |   at org.wso2.carbon.mediation.security.vault.xpath.VaultLookupFunction.call(VaultLookupFunction.java:82)
api-manager_1   |   ... 25 more

有人可以指导我做错了什么吗?提前谢谢。

1 个答案:

答案 0 :(得分:0)

Exception in thread "main" org.wso2.ciphertool.exception.CipherToolException: XPath value for secret alias 'ApiManager.BasicAuth.password' cannot be found.
at org.wso2.ciphertool.CipherTool.loadXpathValuesAndPasswordDetails(CipherTool.java:174)
at org.wso2.ciphertool.CipherTool.main(CipherTool.java:56)

表示您的cipher-tool.properties文件包含的xpath与您指定的文件中的xpath不匹配。

必须是这样的:{alias} = {path} {xpath},所以如果你采取以下措施:

SalesforcePasswords.SalesforceApi.ClientId=tmp/app-config/SalesforcePasswords.xml//SalesforceApi/ClientId
  • {alias}是SalesforcePasswords.SalesforceApi.ClientId
  • {path}是tmp / app-config / SalesforcePasswords.xml
  • {xpath}是// SalesforceApi / ClientId

不确定导致第二次异常的原因