poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1701684 - /poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java
Date Mon, 07 Sep 2015 20:14:33 GMT
Author: kiwiwings
Date: Mon Sep  7 20:14:33 2015
New Revision: 1701684

URL: http://svn.apache.org/r1701684
Log:
Bug 58326 - Forbidden APIs patches - first set of changes for locale and timezone settings
commit single files because of svn failures ...

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java?rev=1701684&r1=1701683&r2=1701684&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java Mon Sep
 7 20:14:33 2015
@@ -52,7 +52,6 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
-import java.util.TimeZone;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.openxml4j.opc.OPCPackage;
@@ -71,6 +70,7 @@ import org.apache.poi.poifs.crypt.dsig.s
 import org.apache.poi.poifs.crypt.dsig.services.TimeStampServiceValidator;
 import org.apache.poi.util.DocumentHelper;
 import org.apache.poi.util.IOUtils;
+import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -99,10 +99,9 @@ public class TestSignatureInfo {
         CryptoFunctions.registerBouncyCastle();
 
         /*** TODO : set cal to now ... only set to fixed date for debugging ... */ 
-        cal = Calendar.getInstance();
-        cal.clear();
-        cal.setTimeZone(TimeZone.getTimeZone("UTC"));
-        cal.set(2014, 7, 6, 21, 42, 12);
+        cal = LocaleUtil.getLocaleCalendar(LocaleUtil.TIMEZONE_UTC);
+//        cal.set(2014, 7, 6, 21, 42, 12);
+//        cal.clear(Calendar.MILLISECOND);
 
         // don't run this test when we are using older Xerces as it triggers an XML Parser
backwards compatibility issue 
         // in the xmlsec jar file
@@ -241,6 +240,7 @@ public class TestSignatureInfo {
     public void testManipulation() throws Exception {
         // sign & validate
         String testFile = "hello-world-unsigned.xlsx";
+        @SuppressWarnings("resource")
         OPCPackage pkg = OPCPackage.open(copy(testdata.getFile(testFile)), PackageAccess.READ_WRITE);
         sign(pkg, "Test", "CN=Test", 1);
         
@@ -289,6 +289,7 @@ public class TestSignatureInfo {
         pkg.close();
     }
 
+    @SuppressWarnings("resource")
     @Test
     public void testSignEnvelopingDocument() throws Exception {
         String testFile = "hello-world-unsigned.xlsx";
@@ -350,9 +351,9 @@ public class TestSignatureInfo {
         } else {
             TimeStampServiceValidator tspValidator = new TimeStampServiceValidator() {
                 @Override
-                public void validate(List<X509Certificate> certificateChain,
+                public void validate(List<X509Certificate> validateChain,
                 RevocationData revocationData) throws Exception {
-                    for (X509Certificate certificate : certificateChain) {
+                    for (X509Certificate certificate : validateChain) {
                         LOG.log(POILogger.DEBUG, "certificate: " + certificate.getSubjectX500Principal());
                         LOG.log(POILogger.DEBUG, "validity: " + certificate.getNotBefore()
+ " - " + certificate.getNotAfter());
                     }
@@ -370,7 +371,7 @@ public class TestSignatureInfo {
 
         RevocationDataService revocationDataService = new RevocationDataService(){
             @Override
-            public RevocationData getRevocationData(List<X509Certificate> certificateChain)
{
+            public RevocationData getRevocationData(List<X509Certificate> revocationChain)
{
                 return revocationData;
             }
         };
@@ -498,9 +499,8 @@ public class TestSignatureInfo {
         SignatureConfig signatureConfig = new SignatureConfig();
         signatureConfig.setKey(keyPair.getPrivate());
         signatureConfig.setSigningCertificateChain(certChain);
-        Calendar cal = Calendar.getInstance();
-        cal.set(2007, 7, 1);
-        signatureConfig.setExecutionTime(cal.getTime());
+        Calendar oldCal = LocaleUtil.getLocaleCalendar(2007, 7, 1);
+        signatureConfig.setExecutionTime(oldCal.getTime());
         signatureConfig.setDigestAlgo(HashAlgorithm.sha1);
         signatureConfig.setOpcPackage(pkg);
         
@@ -615,10 +615,10 @@ public class TestSignatureInfo {
             keyPair = new KeyPair(x509.getPublicKey(), (PrivateKey)key);
         } else {
             keyPair = PkiTestUtils.generateKeyPair();
-            Calendar cal = Calendar.getInstance();
             Date notBefore = cal.getTime();
-            cal.add(Calendar.YEAR, 1);
-            Date notAfter = cal.getTime();
+            Calendar cal2 = (Calendar)cal.clone();
+            cal2.add(Calendar.YEAR, 1);
+            Date notAfter = cal2.getTime();
             KeyUsage keyUsage = new KeyUsage(KeyUsage.digitalSignature);
             
             x509 = PkiTestUtils.generateCertificate(keyPair.getPublic(), subjectDN



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message