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>
索普
:
import eu.europa.esig.dss.token.Pkcs12SignatureTokenTest;
log.info Pkcs12SignatureTokenTest.testPkcs12();
我收到以下错误消息:
eu.europa.esig.dss.token.Pkcs12SignatureTokenTest.testPkcs12()是
适用于参数类型:()值:[]可能的解决方案:
testPkcs12()在第3行出错