AggCat Java Framework无法读取证书文件

时间:2013-03-12 02:42:39

标签: oauth intuit-partner-platform intuit customer-account-data-api

我正在将AggCat Java API集成到我的网络服务器中。不幸的是,当我在Tomcat(或GlassFish)Web服务器上运行它时,AggCat 1.0 Java框架无法正确读取我的Java密钥库(.jks)文件。

我通过一个独立的Java程序(它完美地运行)运行以下相同的代码来验证这一点,然后尝试用Tomcat Servlet的方法调用它:

public static void main(String[] args){
     AggCatTester aggcat = new AggCatTester();
     aggcat.testAggcat();
}

public void testAggcat() {
    Config.setProperty(Config.KEY_STORE_FILE, "./keystore.jks");
    Config.setProperty(Config.KEY_STORE_PASSWORD, "XXXXXXXX");
    Config.setProperty(Config.OAUTH_URL,
            "https://oauth.intuit.com/oauth/v1/get_access_token_by_saml");
    Config.setProperty(Config.CERT_ALIAS, "XXX");
    Config.setProperty(Config.KEY_PASSWORD, "XXXXXXXXX");

    OAuthAuthorizer oauth = new OAuthAuthorizer(consumerKey,
            consumerSecret, samlProviderId, userId);
    er.service = new AggCatService(new com.intuit.ipp.aggcat.core.Context(oauth));


    InstitutionDetail details = er.service.getInstitutionDetails(455);
    System.out.println(details.getInstitutionName());
}

当我从一个独立的命令行java程序调用testAggcat()方法时,它没有问题,并打印由ID 455定义的Institution。当我从servlet调用testAggCat()方法时,我得到一个“UnrecoverableKeyException”表示我的密钥库密码对以下stacktrace无效:

    SEVERE: com.intuit.ipp.aggcat.exception.OAuthException: com.intuit.ipp.aggcat.exception.AggCatException: Exception while reading the certificate file
    at com.intuit.ipp.aggcat.util.OAuthUtil.getOAuthTokens(OAuthUtil.java:82)
    at com.intuit.ipp.aggcat.util.OAuthUtil.getOAuthTokens(OAuthUtil.java:57)
    at com.intuit.ipp.aggcat.core.OAuthAuthorizer.<init>(OAuthAuthorizer.java:85)
    at com.astar.zloty.webservice.rest.impl.EmployeeResource.initialize(EmployeeResource.java:97)
    at com.astar.zloty.webservice.rest.impl.EmployeeResource.testApi(EmployeeResource.java:72)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:680)
    Caused by: com.intuit.ipp.aggcat.exception.SamlAssertionException: com.intuit.ipp.aggcat.exception.AggCatException: Exception while reading the certificate file
    at com.intuit.ipp.aggcat.util.SamlUtil.createSignedSAMLPayload(SamlUtil.java:159)
    at com.intuit.ipp.aggcat.util.OAuthUtil.getOAuthTokens(OAuthUtil.java:72)
    ... 48 more
    Caused by: com.intuit.ipp.aggcat.exception.AggCatException: Exception while reading the certificate file
    at com.intuit.ipp.aggcat.util.SAMLCredentials.<init>(SAMLCredentials.java:60)
    at com.intuit.ipp.aggcat.util.SamlUtil.createSignedSAMLPayload(SamlUtil.java:155)
    ... 49 more
    Caused by: com.intuit.ipp.aggcat.exception.AggCatException: Exception when loading the cert.
    at com.intuit.ipp.aggcat.util.SAMLCredentials.loadCredential(SAMLCredentials.java:118)
    at com.intuit.ipp.aggcat.util.SAMLCredentials.<init>(SAMLCredentials.java:58)
    ... 50 more
    Caused by: java.io.IOException: Keystore was tampered with, or password was incorrect
    at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:771)
    at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:38)
    at java.security.KeyStore.load(KeyStore.java:1185)
    at com.intuit.ipp.aggcat.util.SAMLCredentials.loadCredential(SAMLCredentials.java:94)
    ... 51 more
    Caused by: java.security.UnrecoverableKeyException: Password verification failed
    at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:769)
    ... 54 more

2 个答案:

答案 0 :(得分:1)

您是否可以使用war文件提交支持服务单(http://developer.intuit.com/Support.html),以便验证应用程序的结构和配置内容?

答案 1 :(得分:0)

我正面临着这个问题。通过将keystore.jks文件直接放在类路径的根目录而不是将其放在类路径的某个文件夹中,我的问题就消失了。

keystore.jks