有关TPtCC()签名的更多信息

时间:2012-09-03 15:37:47

标签: xades4j

我正在使用“SignerTestBase”处理SignerTTest.java:

    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");


}

我有类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 !!!!!!!!!!!!");
    }
}

在我的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();

在我的控制台中,我得到了:

> ============================================================================
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)

在我搜索期间,您可以就此问题向我提出建议吗?

感谢,

威尔

1 个答案:

答案 0 :(得分:1)

该测试是为了使用葡萄牙公民卡PKCS#11提供商而编写的。如异常消息所述,您没有安装提供程序。如果需要使用PKCS#11提供程序测试lib,请更改配置以使用其本机lib。

P.S。:lib文档和示例非常清楚..请更好看。另外,请在这里投票给答案。