关于如何签署EPIC的一点建议

时间:2012-09-03 14:55:40

标签: xades4j

在这一刻,我处理签名EPES,我想要一些形象;

签名,我在 SignerTestBase.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("b.xml");**


}

和:

@Test
public void testSignEPES() throws Exception
{
    System.out.println("signEPES");

    Document doc = getTestDocument();

    Element elemToSign = doc.getDocumentElement();

    SignerEPES signer = (SignerEPES)new XadesEpesSigningProfile(keyingProviderMy, policyInfoProvider).newSigner();
    new Enveloped(signer).sign(elemToSign);

    **outputDocument(doc, "document.signed.epes.xml");**
}

主要:

System.out.println("============================================================================");          
        System.out.println("XADESTEST : EPES SIGNATURE");
        System.out.println("============================================================================"); 
        System.out.println();

        SignerEPESTest signerEPESTest = new SignerEPESTest();
        System.out.println("signerEPESTest : " + signerEPESTest.toString());


        /**
         *  ==== NOT OK =====
         */

        **signerEPESTest.testSignEPES();**

当我跑步时在我的控制台中:

  

============================================================================
XADESTEST : EPES SIGNATURE
============================================================================

signerEPESTest : xadestest.SignerEPESTest@1c63e8c
signEPES
Exception in thread "main" java.lang.NullPointerException
    at xades4j.utils.XadesProfileCore.addBinding(XadesProfileCore.java:81)
    at xades4j.production.XadesSigningProfile.withBinding(XadesSigningProfile.java:131)
    at xades4j.production.XadesEpesSigningProfile.<init>(XadesEpesSigningProfile.java:51)
    at xadestest.SignerEPESTest.testSignEPES(SignerEPESTest.java:59)
    at xadestest.XadesTest.main(XadesTest.java:103)
Java Result: 1
BUILD SUCCESSFUL (total time: 16 seconds)

请在我搜索期间,有人可以帮助我吗?

威尔

1 个答案:

答案 0 :(得分:1)

似乎policyInfoProvider上的XadesEpesSigningProfile参数为空。构造函数缺少一个带有更好消息的空检查。