diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2015-09-07 20:19:50 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2015-09-07 20:19:50 +0000 |
commit | a3d2eb57ff4ac10ae215b9b7404260103eb6f538 (patch) | |
tree | 7b44ec32a7cdd0e0828779c793061ac6a00e4c00 /src/ooxml/java/org/apache/poi/poifs/crypt | |
parent | f2e85496125f7fc68f7434244b9d9d5bb026933d (diff) | |
download | poi-a3d2eb57ff4ac10ae215b9b7404260103eb6f538.tar.gz poi-a3d2eb57ff4ac10ae215b9b7404260103eb6f538.zip |
Bug 58326 - Forbidden APIs patches - first set of changes for locale and timezone settings
also includes fixes for
- name shadowing
- unused deprecated method "getClipRect" in classes extending Graphics2d
- HexDump - replaced intermediate String.format calls with custom padding
- convert testcases to junit4
- closing resources
also tested with an arbitary timezone (PST) and locale (ru)
supresses forbidden apis check for
- LocaleUtil (the only place where Locale.getDefault() and TimeZone.getDefault() should be called)
- Classes using FontMetrics - without the actual text it's difficult to return something sane
Some usage of UTC and Locale.ROOT might be still wrong, e.g. in MapiMessage we don't access the
extended mapi properties, which might contain the timezone
DataFormatter has now a Observable property which need to be observed when custom formats are used
and the Locale changes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1701688 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi/poifs/crypt')
3 files changed, 8 insertions, 5 deletions
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/OOXMLSignatureFacet.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/OOXMLSignatureFacet.java index 59ae52a20c..ab3aa070e7 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/OOXMLSignatureFacet.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/OOXMLSignatureFacet.java @@ -31,6 +31,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
import java.util.TimeZone;
@@ -196,7 +197,7 @@ public class OOXMLSignatureFacet extends SignatureFacet { /*
* SignatureTime
*/
- DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+ DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ROOT);
fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
String nowStr = fmt.format(signatureConfig.getExecutionTime());
LOG.log(POILogger.DEBUG, "now: " + nowStr);
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESSignatureFacet.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESSignatureFacet.java index c14fb38340..5441d58bbc 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESSignatureFacet.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESSignatureFacet.java @@ -31,6 +31,7 @@ import java.util.ArrayList; import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
@@ -115,8 +116,7 @@ public class XAdESSignatureFacet extends SignatureFacet { SignedSignaturePropertiesType signedSignatureProperties = signedProperties.addNewSignedSignatureProperties();
// SigningTime
- Calendar xmlGregorianCalendar = Calendar.getInstance();
- xmlGregorianCalendar.setTimeZone(TimeZone.getTimeZone("Z"));
+ Calendar xmlGregorianCalendar = Calendar.getInstance(TimeZone.getTimeZone("Z"), Locale.ROOT);
xmlGregorianCalendar.setTime(signatureConfig.getExecutionTime());
xmlGregorianCalendar.clear(Calendar.MILLISECOND);
signedSignatureProperties.setSigningTime(xmlGregorianCalendar);
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java index 1a1ac18391..136f3e0eb5 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java @@ -39,6 +39,8 @@ import java.util.ArrayList; import java.util.Calendar;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
import java.util.UUID;
import javax.xml.crypto.MarshalException;
@@ -214,7 +216,7 @@ public class XAdESXLSignatureFacet extends SignatureFacet { CRLIdentifierType crlIdentifier = crlRef.addNewCRLIdentifier();
String issuerName = crl.getIssuerDN().getName().replace(",", ", ");
crlIdentifier.setIssuer(issuerName);
- Calendar cal = Calendar.getInstance();
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Z"), Locale.ROOT);
cal.setTime(crl.getThisUpdate());
crlIdentifier.setIssueTime(cal);
crlIdentifier.setNumber(getCrlNumber(crl));
@@ -238,7 +240,7 @@ public class XAdESXLSignatureFacet extends SignatureFacet { BasicOCSPResp basicOcspResp = (BasicOCSPResp)ocspResp.getResponseObject();
- Calendar cal = Calendar.getInstance();
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Z"), Locale.ROOT);
cal.setTime(basicOcspResp.getProducedAt());
ocspIdentifier.setProducedAt(cal);
|