找不到 java.security.KeyStore.load(java.io.FileInputStream, string) 的匹配 Method/Function

No matching Method/Function for java.security.KeyStore.load(java.io.FileInputStream, string) found

我正在尝试在 cfscript 中的 Coldfusion 中的 java.security.Keystore 对象上使用方法 load()。

这是我的代码(不是完整代码,但足以看出元素的层次结构):

<cfoutput>

  <cfsavecontent variable="responseOpen">

    <?xml version="1.0" encoding="UTF-8"?>

    ...

  </cfsavecontent>


  <cfxml variable="samlAssertionXML">

    ...

  </cfxml>


  <cfsavecontent variable="responseClose">

    </samlp:Response>

  </cfsavecontent>

  <cfscript>

     // 1) Injest the XML

     ...

     // 5) Keystore

     ksfile = CreateObject("Java", "java.io.File").init("Users/carl/keystore_test");

     inputStream = CreateObject("Java", "java.io.FileInputStream").init(ksfile);

     KeyStoreClass = CreateObject("Java" , "java.security.KeyStore");

     ks = KeyStoreClass.getInstance("JKS");

     ks.load(inputStream,"1221");

     ...

  </cfscript>

    ...

</cfoutput>

我收到一条错误消息:

No matching Method/Function for java.security.KeyStore.load(java.io.FileInputStream, string) found

线上ks.load(inputStream,"1221");.

我确定 inputStream 不为 null,并且 inputStream 是类型 java.security.Keystore 的对象。我还确保加载了库 java.security.Keystore。证明是代码在该行之前没有中断。代码在 .cfm 文件中。

记录 inputStream 和 ksfile,我得到了这个:

可能是什么问题?

查看 java.security.KeyStore 的文档,看起来 load() 方法在使用 InputStream 调用时实际上需要一个字符数组 (char[]),而不是字符串。我想这就是您看到 "No matching method" 错误的原因。您可以尝试将字符串转换为字符数组吗?例如:

password = "1221";
ks.load(inputStream, password.toCharArray());