I am working on SignerTTest.java with "SignerTestBase" :
public class SignerTestBase extends SignatureServicesTestBase
{
/**/
static protected KeyingDataProvider keyingProviderMy;
static protected KeyingDataProvider keyingProviderNist;
static
{
try
{
keyingProviderMy = createFileSystemKeyingDataProvider("pkcs12", "my/LG.pfx", "mykeypass", true);
keyingProviderNist = createFileSystemKeyingDataProvider("pkcs12", "csrc.nist/test4.p12", "password", false);
} catch (KeyStoreException e)
{
throw new NullPointerException("SignerTestBase init failed: " + e.getMessage());
}
}
public static Document getTestDocument() throws Exception
{
//return getDocument("document.xml");
//==that I changed=====================================================================
return getDocument("fv.xml");
}
I have the class SignerTTest.java
@Test
public void testSignTPtCC() throws Exception
{
System.out.println("signTPtCitizenCard");
if (!onWindowsPlatform())
fail("Test written for the Windows platform");
Document doc = getTestDocument();
Element elemToSign = doc.getDocumentElement();
try
{
PKCS11KeyStoreKeyingDataProvider ptccKeyingDataProv = new PKCS11KeyStoreKeyingDataProvider(
//"C:\\Windows\\System32\\pteidpkcs11.dll", "PT_CC",
"C:\\Windows\\system32\\pteidpkcs11.dll", "PT_CC",
new FirstCertificateSelector(), null, null, false);
SignerT signer = (SignerT)new XadesTSigningProfile(ptccKeyingDataProv).withAlgorithmsProvider(PtCcAlgorithmsProvider.class).newSigner();
new xades4j.production.Enveloped(signer).sign(elemToSign);
outputDocument(doc, "document.signed.t.bes.ptcc.xml");
} catch (ProviderException ex)
{
fail(" !!!!!!!PT CC PKCS#11 provider not configured !!!!!!!!!!!!");
}
}
And in my main.class :
System.out.println("============================================================================");
System.out.println("XADESTEST : T SIGNATURE");
System.out.println("============================================================================");
System.out.println();
SignerTTest signerTTest = new SignerTTest();
System.out.println("signerTTest : " + signerTTest.toString());
/**
* ==== NOT OK =====
*/
signerTTest.testSignTPtCC();
And in my console I get :
> ============================================================================
XADESTEST : T SIGNATURE
============================================================================
signerTTest : xadestest.SignerTTest@1304043
signTPtCitizenCard
Exception in thread "main" java.lang.AssertionError: !!!!!!!PT CC PKCS#11 provider not configured !!!!!!!!!!!!
at org.junit.Assert.fail(Assert.java:58)
at xadestest.SignerTTest.testSignTPtCC(SignerTTest.java:119)
at xadestest.XadesTest.main(XadesTest.java:117)
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)
Please may you advice me on the problem during I am searching ?
thanks,
Will.
That test is written to use the Portuguese Citizen Card PKCS#11 provider. As the exception message states, you don't have the provider installed. If you need to test the lib with a PKCS#11 provider, change the configuration to use its native lib instead.
P.S.: the lib docs and examples are pretty clear on this..please take a better look. also, please vote the answers here.