diff options
author | Alexander Kurtakov | 2019-11-21 06:35:00 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2019-12-11 07:20:20 +0000 |
commit | e77df4b0885d3b5d26ccd33ccc0aa9358586223d (patch) | |
tree | 8dd003105b828b91ccf6df434de4225d18badf43 | |
parent | b2d896b7f75fa833c5a40bb50604423f463d452a (diff) | |
download | rt.equinox.framework-e77df4b0885d3b5d26ccd33ccc0aa9358586223d.tar.gz rt.equinox.framework-e77df4b0885d3b5d26ccd33ccc0aa9358586223d.tar.xz rt.equinox.framework-e77df4b0885d3b5d26ccd33ccc0aa9358586223d.zip |
Bug 553294 - Use StandardCharsetsI20191211-1805
Change-Id: Id3d98b332c49de8a98990d7026611963b717e761
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
9 files changed, 113 insertions, 40 deletions
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java index 558afa417..385921444 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2016 IBM Corporation and others. + * Copyright (c) 2003, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,16 +14,38 @@ *******************************************************************************/ package org.eclipse.osgi.internal.resolver; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.DataInputStream; +import java.io.File; +import java.io.IOException; import java.lang.reflect.Constructor; +import java.nio.charset.StandardCharsets; import java.security.AccessController; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Dictionary; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; import org.eclipse.osgi.framework.util.ObjectPool; import org.eclipse.osgi.framework.util.SecureAction; -import org.eclipse.osgi.service.resolver.*; +import org.eclipse.osgi.service.resolver.BaseDescription; +import org.eclipse.osgi.service.resolver.BundleDescription; +import org.eclipse.osgi.service.resolver.BundleSpecification; +import org.eclipse.osgi.service.resolver.DisabledInfo; +import org.eclipse.osgi.service.resolver.ExportPackageDescription; +import org.eclipse.osgi.service.resolver.GenericDescription; +import org.eclipse.osgi.service.resolver.GenericSpecification; +import org.eclipse.osgi.service.resolver.ImportPackageSpecification; +import org.eclipse.osgi.service.resolver.NativeCodeSpecification; +import org.eclipse.osgi.service.resolver.StateWire; import org.eclipse.osgi.service.resolver.VersionRange; -import org.osgi.framework.*; +import org.osgi.framework.Constants; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.Version; /** * This class is internally threadsafe and supports client locking. Clients must <strong>not</strong> hold the monitor for @@ -33,7 +55,6 @@ import org.osgi.framework.*; final class StateReader { public static final String STATE_FILE = ".state"; //$NON-NLS-1$ public static final String LAZY_FILE = ".lazy"; //$NON-NLS-1$ - public static final String UTF_8 = "UTF-8"; //$NON-NLS-1$ private static final int BUFFER_SIZE_LAZY = 4096; private static final int BUFFER_SIZE_FULLYREAD = 16384; private static final SecureAction secureAction = AccessController.doPrivileged(SecureAction.createSecureAction()); @@ -761,7 +782,7 @@ final class StateReader { int length = in.readInt(); byte[] data = new byte[length]; in.readFully(data); - String string = new String(data, UTF_8); + String string = new String(data, StandardCharsets.UTF_8); if (intern) return string.intern(); diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java index 1c79dea2f..8d2d12bba 100644 --- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java +++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2016 IBM Corporation and others. + * Copyright (c) 2003, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,11 +14,35 @@ *******************************************************************************/ package org.eclipse.osgi.internal.resolver; -import java.io.*; -import java.util.*; -import org.eclipse.osgi.service.resolver.*; +import java.io.BufferedOutputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import org.eclipse.osgi.service.resolver.BaseDescription; +import org.eclipse.osgi.service.resolver.BundleDescription; +import org.eclipse.osgi.service.resolver.BundleSpecification; +import org.eclipse.osgi.service.resolver.DisabledInfo; +import org.eclipse.osgi.service.resolver.ExportPackageDescription; +import org.eclipse.osgi.service.resolver.GenericDescription; +import org.eclipse.osgi.service.resolver.GenericSpecification; +import org.eclipse.osgi.service.resolver.ImportPackageSpecification; +import org.eclipse.osgi.service.resolver.NativeCodeDescription; +import org.eclipse.osgi.service.resolver.NativeCodeSpecification; +import org.eclipse.osgi.service.resolver.StateWire; +import org.eclipse.osgi.service.resolver.VersionConstraint; import org.eclipse.osgi.service.resolver.VersionRange; -import org.osgi.framework.*; +import org.osgi.framework.Constants; +import org.osgi.framework.Filter; +import org.osgi.framework.Version; /** * This class is <strong>not</strong> thread safe. Instances must not be @@ -718,7 +742,7 @@ class StateWriter { if (string == null) out.writeByte(StateReader.NULL); else { - byte[] data = string.getBytes(StateReader.UTF_8); + byte[] data = string.getBytes(StandardCharsets.UTF_8); if (data.length > 65535) { out.writeByte(StateReader.LONG_STRING); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java index 4bedb3f30..1b27d8de2 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2017 IBM Corporation and others. + * Copyright (c) 2012, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -16,6 +16,7 @@ package org.eclipse.osgi.container; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -141,6 +142,7 @@ public class ModuleDatabase { static enum Sort { BY_DEPENDENCY, BY_START_LEVEL, BY_ID; + /** * Tests if this option is contained in the specified options */ @@ -962,7 +964,6 @@ public class ModuleDatabase { private static final byte OBJECT = 1; private static final byte INDEX = 2; private static final byte LONG_STRING = 3; - private static final String UTF_8 = "UTF-8"; //$NON-NLS-1$ private static final byte VALUE_STRING = 0; // REMOVED treated as List<String> - private static final byte VALUE_STRING_ARRAY = 1; @@ -1669,7 +1670,7 @@ public class ModuleDatabase { if (string == null) out.writeByte(NULL); else { - byte[] data = string.getBytes(UTF_8); + byte[] data = string.getBytes(StandardCharsets.UTF_8); if (data.length > 65535) { out.writeByte(LONG_STRING); @@ -1706,7 +1707,7 @@ public class ModuleDatabase { int length = in.readInt(); byte[] data = new byte[length]; in.readFully(data); - string = new String(data, UTF_8); + string = new String(data, StandardCharsets.UTF_8); } else { string = in.readUTF(); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java index 1fd7dcb6b..4e4946259 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2017 IBM Corporation and others. + * Copyright (c) 2004, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -372,7 +372,7 @@ class EquinoxLogWriter implements SynchronousLogListener, LogFilter { Reader fileIn = null; try { openFile(); - fileIn = new InputStreamReader(ExtendedLogServiceFactory.secureAction.getFileInputStream(oldOutFile), "UTF-8"); //$NON-NLS-1$ + fileIn = new InputStreamReader(ExtendedLogServiceFactory.secureAction.getFileInputStream(oldOutFile), StandardCharsets.UTF_8); copyReader(fileIn, this.writer); } catch (IOException e) { copyFailed = true; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/BERProcessor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/BERProcessor.java index 5cfb4215b..9c6742a8f 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/BERProcessor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/BERProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. + * Copyright (c) 2006, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,6 +15,7 @@ package org.eclipse.osgi.internal.signedcontent; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; import java.security.SignatureException; /** @@ -220,7 +221,7 @@ public class BERProcessor { * @return the content from the current structure as a String. */ public String getString() { - return new String(buffer, contentOffset, contentLength, SignedContentConstants.UTF8); + return new String(buffer, contentOffset, contentLength, StandardCharsets.UTF_8); } /** diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java index 37bc0ec11..394ce0147 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2016 IBM Corporation and others. + * Copyright (c) 2006, 2019 IBM Corporation and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which accompanies this distribution, @@ -14,11 +14,28 @@ package org.eclipse.osgi.internal.signedcontent; import java.io.ByteArrayInputStream; import java.math.BigInteger; -import java.security.*; -import java.security.cert.*; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Signature; +import java.security.SignatureException; import java.security.cert.Certificate; -import java.text.*; -import java.util.*; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.TimeZone; import javax.security.auth.x500.X500Principal; import org.eclipse.osgi.util.NLS; @@ -198,7 +215,7 @@ public class PKCS7Processor implements SignedContentConstants { eContentBER.stepOver(); // check time ends w/ 'Z' - String dateString = new String(eContentBER.getBytes(), SignedContentConstants.UTF8); + String dateString = new String(eContentBER.getBytes(), StandardCharsets.UTF_8); if (!dateString.endsWith("Z")) //$NON-NLS-1$ throw new SignatureException("Wrong dateformat used in time-stamp token"); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java index 04d6abe02..e3eb1a381 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 IBM Corporation and others. + * Copyright (c) 2007, 2019 IBM Corporation and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which accompanies this distribution, @@ -14,10 +14,21 @@ package org.eclipse.osgi.internal.signedcontent; import java.io.IOException; import java.io.InputStream; -import java.security.*; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.SignatureException; import java.security.cert.Certificate; import java.security.cert.CertificateException; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import org.eclipse.osgi.framework.log.FrameworkLogEntry; import org.eclipse.osgi.signedcontent.SignerInfo; import org.eclipse.osgi.storage.bundlefile.BundleEntry; @@ -131,7 +142,7 @@ public class SignatureBlockProcessor implements SignedContentConstants { */ private void verifyManifestAndSignatureFile(byte[] manifestBytes, byte[] sfBytes) throws SignatureException { - String sf = new String(sfBytes, SignedContentConstants.UTF8); + String sf = new String(sfBytes, StandardCharsets.UTF_8); sf = stripContinuations(sf); // check if there -Digest-Manfiest: header in the file @@ -168,7 +179,7 @@ public class SignatureBlockProcessor implements SignedContentConstants { private void populateMDResults(byte mfBuf[], SignerInfo signerInfo) { // need to make a string from the MF file data bytes - String mfStr = new String(mfBuf, SignedContentConstants.UTF8); + String mfStr = new String(mfBuf, StandardCharsets.UTF_8); // start parsing each entry in the MF String int entryStartOffset = mfStr.indexOf(MF_ENTRY_NEWLN_NAME); @@ -310,7 +321,7 @@ public class SignatureBlockProcessor implements SignedContentConstants { * Returns the Base64 encoded digest of the passed set of bytes. */ private static String calculateDigest(MessageDigest digest, byte[] bytes) { - return new String(Base64.encode(digest.digest(bytes)), SignedContentConstants.UTF8); + return new String(Base64.encode(digest.digest(bytes)), StandardCharsets.UTF_8); } synchronized MessageDigest getMessageDigest(String algorithm) { @@ -331,7 +342,7 @@ public class SignatureBlockProcessor implements SignedContentConstants { */ private static String getDigAlgFromSF(byte SFBuf[]) { // need to make a string from the MF file data bytes - String mfStr = new String(SFBuf, SignedContentConstants.UTF8); + String mfStr = new String(SFBuf, StandardCharsets.UTF_8); String entryStr = null; // start parsing each entry in the MF String diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentConstants.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentConstants.java index 6dd8d8042..11deee0be 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentConstants.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. + * Copyright (c) 2006, 2019 IBM Corporation and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which accompanies this distribution, @@ -13,8 +13,6 @@ package org.eclipse.osgi.internal.signedcontent; -import java.nio.charset.Charset; - public interface SignedContentConstants { public static final String SHA1_STR = "SHA1"; //$NON-NLS-1$ @@ -34,7 +32,6 @@ public interface SignedContentConstants { public static final String META_INF = "META-INF/"; //$NON-NLS-1$ public static final String META_INF_MANIFEST_MF = "META-INF/MANIFEST.MF"; //$NON-NLS-1$ public static final String[] EMPTY_STRING = new String[0]; - public static final Charset UTF8 = Charset.forName("UTF-8"); //$NON-NLS-1$ // // following are variables and methods to cache the entries related data diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java index c73f4dee2..2d5893bdd 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java @@ -29,6 +29,7 @@ import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; +import java.nio.charset.StandardCharsets; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; @@ -1377,7 +1378,7 @@ public class Storage { out.writeInt(0); } else { // don't use out.writeUTF because it has a hard string limit - byte[] data = value.getBytes("UTF-8"); //$NON-NLS-1$ + byte[] data = value.getBytes(StandardCharsets.UTF_8); out.writeInt(data.length); out.write(data); } @@ -1387,7 +1388,7 @@ public class Storage { int length = in.readInt(); byte[] data = new byte[length]; in.readFully(data); - return new String(data, "UTF-8"); //$NON-NLS-1$ + return new String(data, StandardCharsets.UTF_8); } private void saveStorageHookData(DataOutputStream out, List<Generation> generations) throws IOException { |