2012-09-03 46 views
0

的小費小費在這一刻,我在簽名EPES上工作,我想要一些信息;關於如何登錄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 : [email protected] 
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

似乎對XadesEpesSigningProfilepolicyInfoProvider參數爲null。構造函數缺少一個更好的消息空檢查。