That problem was fixed in version 2.0.0.

Paulo 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Khurram Saleem
> Sent: Tuesday, September 25, 2007 9:58 AM
> To: [email protected]
> Cc: [EMAIL PROTECTED]; 'Yasir Khan'
> Subject: [iText-questions] URGENT: Exception occurred during 
> verificartionof signature created in Adobe Acrobat 8.
> 
> Hi iText Team,
> 
>  
> 
> I'm having a problem in verification of signature signed 
> through Adobe Acrobat 8.0.
> 
> My development environment is JDK1.5.0_08, iText2.0 and IAIK 
> JCE Provider 3.13.
> 
>  
> 
> Please help in me in this regard and guide me if I'm doing 
> anything wrong. This code is working fine with the older 
> versions of Adobe e.g. 7.x and 6.x.
> 
> I have also attached the PDF signed through Adobe 8.0.
> 
>  
> 
> Following is the exception which is occurring during verification:
> 
>  
> 
> EXCEPTION
> 
> ==========
> 
> ExceptionConverter: java.security.NoSuchAlgorithmException: 
> SHA1with1.2.840.113549.1.1.5 Signature not available
> 
>           at java.security.Signature.getInstance(Signature.java:208)
> 
>           at com.lowagie.text.pdf.PdfPKCS7.<init>(PdfPKCS7.java:326)
> 
>           at 
> com.lowagie.text.pdf.AcroFields.verifySignature(AcroFields.java:1739)
> 
>           at 
> com.lowagie.text.pdf.AcroFields.verifySignature(AcroFields.java:1695)
> 
>           at 
> itextpdfsigning.ASC_VerifyPKCS7.verifyPDF(ASC_VerifyPKCS7.java:269)
> 
>           at 
> itextpdfsigning.ASC_VerifyPKCS7.main(ASC_VerifyPKCS7.java:67)
> 
>  
> 
> SAMPLE CODE
> 
> ===========
> 
>   //Member Variables
> 
>   PdfPKCS7 m_objPdfPKCS7 = null;
> 
>   PdfDictionary m_objPdfDictionary = null;
> 
>   boolean m_bSignatureCoversWholeDocument = false;
> 
>   int m_iRevision = 0;
> 
>   byte [] m_btRevision = null;
> 
>   X509Certificate m_objSignerCertificate = null;
> 
>   InputStream m_objPKCS7Stream = null; // Contains the PDF 
> associated with a revision
> 
>   PdfReader reader = null;
> 
>   PdfWriter writer = null;
> 
>   byte[] m_baPassword;
> 
>   AcroFields m_objAcroFields=null;
> 
>   ContentInfo contentInfo = null;
> 
>   SignedData signedData = null;
> 
>   SignerInfo[] signerInfo = null;
> 
>  
> 
> /*******************STARTS >> MAIN BUSINESS LOGIC 
> METHOD*******************************/
> 
>  
> 
>   public void verifyPDF(){
> 
>     String str_fieldName = null;
> 
>     try {
> 
>       System.out.println("Verifying PDF ..: " + m_strFileToVerify);
> 
>       m_objPKCS7Stream = new FileInputStream(new 
> File(m_strFileToVerify));
> 
>       reader = new PdfReader(m_objPKCS7Stream, null);
> 
>       m_objAcroFields = reader.getAcroFields();
> 
>       ArrayList obj_Names = m_objAcroFields.getSignatureNames();
> 
>       str_fieldName = (String)obj_Names.get(0);
> 
>       System.out.println("Signature Name..: " + str_fieldName);
> 
>       m_objPdfPKCS7 = 
> m_objAcroFields.verifySignature(str_fieldName); //Exception 
> is occurring at the following line
> 
>       float [] ft_fieldPosition = 
> m_objAcroFields.getFieldPositions(str_fieldName);
> 
>       System.out.println("Signature Position..: " + 
> ft_fieldPosition[0] + " : " + ft_fieldPosition[1] + " : " + 
> ft_fieldPosition[2] + " : " + ft_fieldPosition[3]);
> 
>       m_bSignatureCoversWholeDocument = 
> m_objAcroFields.signatureCoversWholeDocument(str_fieldName);
> 
>       m_objPdfDictionary = 
> m_objAcroFields.getSignatureDictionary(str_fieldName);
> 
>       m_iRevision = m_objAcroFields.getRevision(str_fieldName);
> 
>       m_btRevision = getEncodedPKCS7(); //Method No.1
> 
>       setContents(new File("demo.pkcs7"), m_btRevision);
> 
>       if(verifySignature()){ // Method No.2
> 
>         verifyPKCS7(m_btRevision); // Method No.3
> 
>         System.out.println("Signature...: " + str_fieldName + 
> " verified..!!");
> 
>       }
> 
>       else{
> 
>         System.out.println("Signature...: " + str_fieldName + 
> " not verified..!!");
> 
>       }
> 
>     }
> 
>     catch (Exception ex) {
> 
>       System.out.println("Signature...: " + str_fieldName + " 
> not verified..!!");
> 
>       ex.printStackTrace();
> 
>     }
> 
>   }
> 
>  
> 
> /*******************ENDS >> MAIN BUSINESS LOGIC 
> METHOD*******************************/
> 
>  
> 
>  
> 
> /*******************FYI >> BUSINESS LOGIC 
> METHODS*******************************/
> 
>  
> 
> /***************************************************************/
> 
> //Method No.1
> 
> public byte[] getEncodedPKCS7(){
> 
>     return m_objPdfDictionary.get(PdfName.CONTENTS).getBytes();
> 
>   }
> 
>  
> 
> /**************************************************************/
> 
> //Method No.2
> 
> public boolean verifySignature(){
> 
>     boolean b_Verify = false;
> 
>     try {
> 
>       setIAIKSecurityProviderPosition(1);
> 
>       b_Verify = m_objPdfPKCS7.verify();
> 
>       setIAIKSecurityProviderPosition(3);
> 
>     }
> 
>     catch (Exception ex) {
> 
>       ex.printStackTrace() ;
> 
>     }
> 
>     return b_Verify;
> 
>   }
> 
>  
> 
> /**************************************************************/
> 
> //Method No.3
> 
> private void verifyPKCS7(byte[] a_btPKCS7) throws Exception{
> 
>     ASN1Object obj = null;
> 
>     signedData = null;
> 
>     boolean b_hasContntentInfo = false;
> 
>     try{
> 
>       obj = DerCoder.decode(a_btPKCS7);
> 
>       ContentInfo contentInfo = new ContentInfo(obj);
> 
>       signedData = (SignedData)contentInfo.getContent();
> 
>       b_hasContntentInfo = true;
> 
>     }catch(Exception a_ex){
> 
>       System.out.println("No Content info found");
> 
>       throw new Exception(a_ex.getMessage());
> 
>     }
> 
>     if(b_hasContntentInfo == false)
> 
>       signedData = new SignedData(obj);
> 
>  
> 
>     // Shows Signer Information
> 
>     verifySigners(signedData); //Method No.4
> 
>   }
> 
>  
> 
> /**************************************************************/
> 
> //Method No.4
> 
> private void verifySigners(SignedData a_objSignedData) throws 
> Exception{
> 
>     signerInfo = a_objSignedData.getSignerInfos();
> 
>     // after verifying signature, extract signer info and 
> populate objects
> 
>     for (int i = 0; i < signerInfo.length; i++) {
> 
>       X509Certificate obj_OnlySignerCert = a_objSignedData.verify(i);
> 
>       System.out.println("Signer : " + 
> obj_OnlySignerCert.getSubjectDN());
> 
>       showSignerAttributes(signerInfo[i]);
> 
>     }
> 
>   }
> 
> /**************************************************************/
> 
> /*******************FYI >> BUSINESS LOGIC 
> METHODS*******************************/
> 
>  
> 
>  
> 
> 


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to