Java Doc for PdfPKCS7.java in  » PDF » pdf-itext » com » lowagie » text » pdf » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » PDF » pdf itext » com.lowagie.text.pdf 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.lowagie.text.pdf.PdfPKCS7

PdfPKCS7
public class PdfPKCS7 (Code)
This class does all the processing related to signing and verifying a PKCS#7 signature.

It's based in code found at org.bouncycastle.


Inner Class :public static class X509Name
Inner Class :public static class X509NameTokenizer


Constructor Summary
public  PdfPKCS7(byte[] contentsKey, byte[] certsKey, String provider)
     Verifies a signature using the sub-filter adbe.x509.rsa_sha1.
public  PdfPKCS7(byte[] contentsKey, String provider)
     Verifies a signature using the sub-filter adbe.pkcs7.detached or adbe.pkcs7.sha1.
public  PdfPKCS7(PrivateKey privKey, Certificate[] certChain, CRL[] crlList, String hashAlgorithm, String provider, boolean hasRSAdata)
     Generates a signature.

Method Summary
public  byte[]getAuthenticatedAttributeBytes(byte secondDigest, Calendar signingTime)
     When using authenticatedAttributes the authentication process is different. The document digest is generated and put inside the attribute.
public  CollectiongetCRLs()
    
public  Certificate[]getCertificates()
    
public  StringgetDigestAlgorithm()
    
public  byte[]getEncodedPKCS1()
     Gets the bytes for the PKCS#1 object.
public  byte[]getEncodedPKCS7()
     Gets the bytes for the PKCS7SignedData object.
public  byte[]getEncodedPKCS7(byte secondDigest, Calendar signingTime)
     Gets the bytes for the PKCS7SignedData object.
public  StringgetHashAlgorithm()
     Returns the algorithm.
public static  X509NamegetIssuerFields(X509Certificate cert)
    
public  StringgetLocation()
     Getter for property location.
public  StringgetReason()
     Getter for property reason.
public  CalendargetSignDate()
     Getter for property signDate.
public  StringgetSignName()
     Getter for property sigName.
public  X509CertificategetSigningCertificate()
     Get the X.509 certificate actually used to sign the digest.
public  intgetSigningInfoVersion()
     Get the version of the PKCS#7 "SignerInfo" object.
public static  X509NamegetSubjectFields(X509Certificate cert)
    
public  intgetVersion()
     Get the version of the PKCS#7 object.
public static  KeyStoreloadCacertsKeyStore()
     Loads the default root certificates at <java.home>/lib/security/cacerts with the default provider.
public static  KeyStoreloadCacertsKeyStore(String provider)
     Loads the default root certificates at <java.home>/lib/security/cacerts.
public  voidsetExternalDigest(byte digest, byte RSAdata, String digestEncryptionAlgorithm)
     Sets the digest/signature to an external calculated value.
Parameters:
  digest - the digest.
public  voidsetLocation(String location)
     Setter for property location.
public  voidsetReason(String reason)
     Setter for property reason.
public  voidsetSignDate(Calendar signDate)
     Setter for property signDate.
public  voidsetSignName(String signName)
     Setter for property sigName.
public  voidupdate(byte[] buf, int off, int len)
     Update the digest with the specified bytes.
public  booleanverify()
     Verify the digest.
public static  StringverifyCertificate(X509Certificate cert, Collection crls, Calendar calendar)
     Verifies a single certificate.
public static  Object[]verifyCertificates(Certificate certs, KeyStore keystore, Collection crls, Calendar calendar)
     Verifies a certificate chain against a KeyStore.


Constructor Detail
PdfPKCS7
public PdfPKCS7(byte[] contentsKey, byte[] certsKey, String provider) throws SecurityException, InvalidKeyException, CertificateException, NoSuchProviderException, NoSuchAlgorithmException, IOException, StreamParsingException(Code)
Verifies a signature using the sub-filter adbe.x509.rsa_sha1.
Parameters:
  contentsKey - the /Contents key
Parameters:
  certsKey - the /Cert key
Parameters:
  provider - the provider or null for the default provider
throws:
  SecurityException - on error
throws:
  InvalidKeyException - on error
throws:
  CertificateException - on error
throws:
  NoSuchProviderException - on error
throws:
  NoSuchAlgorithmException - on error
throws:
  IOException - on error



PdfPKCS7
public PdfPKCS7(byte[] contentsKey, String provider) throws SecurityException, CRLException, InvalidKeyException, CertificateException, NoSuchProviderException, NoSuchAlgorithmException, StreamParsingException(Code)
Verifies a signature using the sub-filter adbe.pkcs7.detached or adbe.pkcs7.sha1.
Parameters:
  contentsKey - the /Contents key
Parameters:
  provider - the provider or null for the default provider
throws:
  SecurityException - on error
throws:
  CRLException - on error
throws:
  InvalidKeyException - on error
throws:
  CertificateException - on error
throws:
  NoSuchProviderException - on error
throws:
  NoSuchAlgorithmException - on error



PdfPKCS7
public PdfPKCS7(PrivateKey privKey, Certificate[] certChain, CRL[] crlList, String hashAlgorithm, String provider, boolean hasRSAdata) throws SecurityException, InvalidKeyException, NoSuchProviderException, NoSuchAlgorithmException(Code)
Generates a signature.
Parameters:
  privKey - the private key
Parameters:
  certChain - the certificate chain
Parameters:
  crlList - the certificate revocation list
Parameters:
  hashAlgorithm - the hash algorithm
Parameters:
  provider - the provider or null for the default provider
Parameters:
  hasRSAdata - true if the sub-filter is adbe.pkcs7.sha1
throws:
  SecurityException - on error
throws:
  InvalidKeyException - on error
throws:
  NoSuchProviderException - on error
throws:
  NoSuchAlgorithmException - on error




Method Detail
getAuthenticatedAttributeBytes
public byte[] getAuthenticatedAttributeBytes(byte secondDigest, Calendar signingTime)(Code)
When using authenticatedAttributes the authentication process is different. The document digest is generated and put inside the attribute. The signing is done over the DER encoded authenticatedAttributes. This method provides that encoding and the parameters must be exactly the same as in PdfPKCS7.getEncodedPKCS7(byte[],Calendar) .

A simple example:

 Calendar cal = Calendar.getInstance();
 PdfPKCS7 pk7 = new PdfPKCS7(key, chain, null, "SHA1", null, false);
 MessageDigest messageDigest = MessageDigest.getInstance("SHA1");
 byte buf[] = new byte[8192];
 int n;
 InputStream inp = sap.getRangeStream();
 while ((n = inp.read(buf)) > 0) {
 messageDigest.update(buf, 0, n);
 }
 byte hash[] = messageDigest.digest();
 byte sh[] = pk7.getAuthenticatedAttributeBytes(hash, cal);
 pk7.update(sh, 0, sh.length);
 byte sg[] = pk7.getEncodedPKCS7(hash, cal);
 

Parameters:
  secondDigest - the content digest
Parameters:
  signingTime - the signing time the byte array representation of the authenticatedAttributes ready to be signed



getCRLs
public Collection getCRLs()(Code)
Get the X.509 certificate revocation lists associated with this PKCS#7 object the X.509 certificate revocation lists associated with this PKCS#7 object



getCertificates
public Certificate[] getCertificates()(Code)
Get the X.509 certificates associated with this PKCS#7 object the X.509 certificates associated with this PKCS#7 object



getDigestAlgorithm
public String getDigestAlgorithm()(Code)
Get the algorithm used to calculate the message digest the algorithm used to calculate the message digest



getEncodedPKCS1
public byte[] getEncodedPKCS1()(Code)
Gets the bytes for the PKCS#1 object. a byte array



getEncodedPKCS7
public byte[] getEncodedPKCS7()(Code)
Gets the bytes for the PKCS7SignedData object. the bytes for the PKCS7SignedData object



getEncodedPKCS7
public byte[] getEncodedPKCS7(byte secondDigest, Calendar signingTime)(Code)
Gets the bytes for the PKCS7SignedData object. Optionally the authenticatedAttributes in the signerInfo can also be set. If either of the parameters is null, none will be used.
Parameters:
  secondDigest - the digest in the authenticatedAttributes
Parameters:
  signingTime - the signing time in the authenticatedAttributes the bytes for the PKCS7SignedData object



getHashAlgorithm
public String getHashAlgorithm()(Code)
Returns the algorithm. the digest algorithm



getIssuerFields
public static X509Name getIssuerFields(X509Certificate cert)(Code)
Get the issuer fields from an X509 Certificate
Parameters:
  cert - an X509Certificate an X509Name



getLocation
public String getLocation()(Code)
Getter for property location. Value of property location.



getReason
public String getReason()(Code)
Getter for property reason. Value of property reason.



getSignDate
public Calendar getSignDate()(Code)
Getter for property signDate. Value of property signDate.



getSignName
public String getSignName()(Code)
Getter for property sigName. Value of property sigName.



getSigningCertificate
public X509Certificate getSigningCertificate()(Code)
Get the X.509 certificate actually used to sign the digest. the X.509 certificate actually used to sign the digest



getSigningInfoVersion
public int getSigningInfoVersion()(Code)
Get the version of the PKCS#7 "SignerInfo" object. Always 1 the version of the PKCS#7 "SignerInfo" object. Always 1



getSubjectFields
public static X509Name getSubjectFields(X509Certificate cert)(Code)
Get the subject fields from an X509 Certificate
Parameters:
  cert - an X509Certificate an X509Name



getVersion
public int getVersion()(Code)
Get the version of the PKCS#7 object. Always 1 the version of the PKCS#7 object. Always 1



loadCacertsKeyStore
public static KeyStore loadCacertsKeyStore()(Code)
Loads the default root certificates at <java.home>/lib/security/cacerts with the default provider. a KeyStore



loadCacertsKeyStore
public static KeyStore loadCacertsKeyStore(String provider)(Code)
Loads the default root certificates at <java.home>/lib/security/cacerts.
Parameters:
  provider - the provider or null for the default provider a KeyStore



setExternalDigest
public void setExternalDigest(byte digest, byte RSAdata, String digestEncryptionAlgorithm)(Code)
Sets the digest/signature to an external calculated value.
Parameters:
  digest - the digest. This is the actual signature
Parameters:
  RSAdata - the extra data that goes into the data tag in PKCS#7
Parameters:
  digestEncryptionAlgorithm - the encryption algorithm. It may must be null if the digestis also null. If the digest is not nullthen it may be "RSA" or "DSA"



setLocation
public void setLocation(String location)(Code)
Setter for property location.
Parameters:
  location - New value of property location.



setReason
public void setReason(String reason)(Code)
Setter for property reason.
Parameters:
  reason - New value of property reason.



setSignDate
public void setSignDate(Calendar signDate)(Code)
Setter for property signDate.
Parameters:
  signDate - New value of property signDate.



setSignName
public void setSignName(String signName)(Code)
Setter for property sigName.
Parameters:
  signName - New value of property sigName.



update
public void update(byte[] buf, int off, int len) throws SignatureException(Code)
Update the digest with the specified bytes. This method is used both for signing and verifying
Parameters:
  buf - the data buffer
Parameters:
  off - the offset in the data buffer
Parameters:
  len - the data length
throws:
  SignatureException - on error



verify
public boolean verify() throws SignatureException(Code)
Verify the digest.
throws:
  SignatureException - on error true if the signature checks out, false otherwise



verifyCertificate
public static String verifyCertificate(X509Certificate cert, Collection crls, Calendar calendar)(Code)
Verifies a single certificate.
Parameters:
  cert - the certificate to verify
Parameters:
  crls - the certificate revocation list or null
Parameters:
  calendar - the date or null for the current date a String with the error description or nullif no error



verifyCertificates
public static Object[] verifyCertificates(Certificate certs, KeyStore keystore, Collection crls, Calendar calendar)(Code)
Verifies a certificate chain against a KeyStore.
Parameters:
  certs - the certificate chain
Parameters:
  keystore - the KeyStore
Parameters:
  crls - the certificate revocation list or null
Parameters:
  calendar - the date or null for the current date null if the certificate chain could be validade or aObject[]{cert,error} where cert is thefailed certificate and error is the error message



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.