我有一个Java
project并用的方法,这应该从一个Groovy
脚本SoapUI
执行的测试类。要执行的方法:
@Test
public void testPkcs12() throws IOException {
try (Pkcs12SignatureToken signatureToken = new Pkcs12SignatureToken("src/test/resources/user_a_rsa.p12",
new PasswordProtection("password".toCharArray()))) {
assertNotNull(signatureToken);
List<DSSPrivateKeyEntry> keys = signatureToken.getKeys();
assertFalse(keys.isEmpty());
KSPrivateKeyEntry dssPrivateKeyEntry = (KSPrivateKeyEntry) keys.get(0);
assertNotNull(dssPrivateKeyEntry);
assertNotNull(dssPrivateKeyEntry.getAlias());
DSSPrivateKeyEntry entry = signatureToken.getKey(dssPrivateKeyEntry.getAlias(), new PasswordProtection("password".toCharArray()));
assertNotNull(entry);
assertNotNull(entry.getCertificate());
assertNotNull(entry.getCertificateChain());
assertNotNull(entry.getEncryptionAlgorithm());
ToBeSigned toBeSigned = new ToBeSigned("Hello world".getBytes("UTF-8"));
SignatureValue signValue = signatureToken.sign(toBeSigned, DigestAlgorithm.SHA256, entry);
assertNotNull(signValue);
assertNotNull(signValue.getAlgorithm());
assertNotNull(signValue.getValue());
System.out.println(DatatypeConverter.printBase64Binary(signValue.getValue()));
}
}
我生成jar
文件有以下插件。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
我把它在SoapUI
:
import eu.europa.esig.dss.token.Pkcs12SignatureTokenTest;
log.info Pkcs12SignatureTokenTest.testPkcs12();
我得到以下错误信息:
groovy.lang.MissingMethodException:方法的无签名:()值::[]可能的解决方案:testPkcs12()在线路错误:静态eu.europa.esig.dss.token.Pkcs12SignatureTokenTest.testPkcs12()为参数类型是适用3
您正在试图调用testPkcs12
就好像它是静态的,但它显然不是。你试一试:
import eu.europa.esig.dss.token.Pkcs12SignatureTokenTest
new Pkcs12SignatureTokenTest().testPkcs12()