pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1652243 - /pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java
Date Thu, 15 Jan 2015 19:22:11 GMT
Author: tilman
Date: Thu Jan 15 19:22:11 2015
New Revision: 1652243

URL: http://svn.apache.org/r1652243
Log:
PDFBOX-2601: fix typo; use object identifiers from Bouncy Castle

Modified:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java?rev=1652243&r1=1652242&r2=1652243&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java
(original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/TSAClient.java
Thu Jan 15 19:22:11 2015
@@ -29,6 +29,9 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.io.IOUtils;
 import org.bouncycastle.asn1.ASN1ObjectIdentifier;
+import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
+import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
+import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
 import org.bouncycastle.tsp.TSPException;
 import org.bouncycastle.tsp.TimeStampRequest;
 import org.bouncycastle.tsp.TimeStampRequestGenerator;
@@ -165,34 +168,33 @@ public class TSAClient
     // returns the ASN.1 OID of the given hash algorithm
     private ASN1ObjectIdentifier getHashObjectIdentifier(String algorithm)
     {
-        // TODO can bouncy castle or Java provide this information?
         if (algorithm.equals("MD2"))
         {
-            return new ASN1ObjectIdentifier("1.2.840.113549.2.2");
+            return new ASN1ObjectIdentifier(PKCSObjectIdentifiers.md2.getId());
         }
         else if (algorithm.equals("MD5"))
         {
-            return new ASN1ObjectIdentifier("1.2.840.113549.2.5");
+            return new ASN1ObjectIdentifier(PKCSObjectIdentifiers.md5.getId());
         }
         else if (algorithm.equals("SHA-1"))
         {
-            return new ASN1ObjectIdentifier("1.3.14.3.2.26");
+            return new ASN1ObjectIdentifier(OIWObjectIdentifiers.idSHA1.getId());
         }
         else if (algorithm.equals("SHA-224"))
         {
-            return new ASN1ObjectIdentifier("2.16.840.1.101.3.4.2.4");
+            return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha224.getId());
         }
         else if (algorithm.equals("SHA-256"))
         {
-            return new ASN1ObjectIdentifier("2.16.840.1.101.3.4.2.1");
+            return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha256.getId());
         }
-        else if (algorithm.equals("SHA-394"))
+        else if (algorithm.equals("SHA-384"))
         {
-            return new ASN1ObjectIdentifier("2.16.840.1.101.3.4.2.2");
+            return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha384.getId());
         }
         else if (algorithm.equals("SHA-512"))
         {
-            return new ASN1ObjectIdentifier("2.16.840.1.101.3.4.2.3");
+            return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha512.getId());
         }
         else
         {



Mime
View raw message