fix lint "Implied default locale in case conversion"
find app/src/full/java/kellinwood/ -name \*.java |xargs sed -i 's,\.toLowerCase(),.toLowerCase(Locale.ROOT),g'
This commit is contained in:
parent
6f7fdec4eb
commit
d5d3abe2a3
@ -6,7 +6,9 @@
|
|||||||
<!-- to make CI fail on errors until this is fixed
|
<!-- to make CI fail on errors until this is fixed
|
||||||
https://github.com/rtyley/spongycastle/issues/7 -->
|
https://github.com/rtyley/spongycastle/issues/7 -->
|
||||||
<issue id="InvalidPackage" severity="warning"/>
|
<issue id="InvalidPackage" severity="warning"/>
|
||||||
|
|
||||||
<issue id="ImpliedQuantity" severity="error"/>
|
<issue id="ImpliedQuantity" severity="error"/>
|
||||||
|
<issue id="DefaultLocale" severity="error"/>
|
||||||
|
|
||||||
<!-- These are important to us, so promote from warning to error -->
|
<!-- These are important to us, so promote from warning to error -->
|
||||||
<issue id="UnusedResources" severity="error">
|
<issue id="UnusedResources" severity="error">
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
package kellinwood.security.zipsigner;
|
package kellinwood.security.zipsigner;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default resource adapter.
|
* Default resource adapter.
|
||||||
*/
|
*/
|
||||||
@ -25,7 +27,7 @@ public class DefaultResourceAdapter implements ResourceAdapter {
|
|||||||
case GENERATING_SIGNATURE_BLOCK:
|
case GENERATING_SIGNATURE_BLOCK:
|
||||||
return "Generating signature block file";
|
return "Generating signature block file";
|
||||||
case COPYING_ZIP_ENTRY:
|
case COPYING_ZIP_ENTRY:
|
||||||
return String.format("Copying zip entry %d of %d", args[0], args[1]);
|
return String.format(Locale.ENGLISH, "Copying zip entry %d of %d", args[0], args[1]);
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unknown item " + item);
|
throw new IllegalArgumentException("Unknown item " + item);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import kellinwood.security.zipsigner.Base64;
|
|||||||
import org.bouncycastle.util.encoders.HexTranslator;
|
import org.bouncycastle.util.encoders.HexTranslator;
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: ken
|
* User: ken
|
||||||
@ -41,7 +42,7 @@ public class Fingerprint {
|
|||||||
builder.append((char) hex[i + 1]);
|
builder.append((char) hex[i + 1]);
|
||||||
if (i != (hex.length - 2)) builder.append(':');
|
if (i != (hex.length - 2)) builder.append(':');
|
||||||
}
|
}
|
||||||
return builder.toString().toUpperCase();
|
return builder.toString().toUpperCase(Locale.ENGLISH);
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
logger.error(x.getMessage(), x);
|
logger.error(x.getMessage(), x);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ power to enforce restrictions on reverse-engineering of their software,
|
|||||||
and it is irresponsible for them to claim they can. */
|
and it is irresponsible for them to claim they can. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package kellinwood.security.zipsigner.optional;
|
package kellinwood.security.zipsigner.optional;
|
||||||
|
|
||||||
import javax.crypto.EncryptedPrivateKeyInfo;
|
import javax.crypto.EncryptedPrivateKeyInfo;
|
||||||
@ -53,6 +52,7 @@ import java.util.Date;
|
|||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,7 +183,7 @@ public class JKS extends KeyStoreSpi {
|
|||||||
|
|
||||||
public Key engineGetKey(String alias, char[] password)
|
public Key engineGetKey(String alias, char[] password)
|
||||||
throws NoSuchAlgorithmException, UnrecoverableKeyException {
|
throws NoSuchAlgorithmException, UnrecoverableKeyException {
|
||||||
alias = alias.toLowerCase();
|
alias = alias.toLowerCase(Locale.ENGLISH);
|
||||||
|
|
||||||
if (!privateKeys.containsKey(alias))
|
if (!privateKeys.containsKey(alias))
|
||||||
return null;
|
return null;
|
||||||
@ -204,12 +204,12 @@ public class JKS extends KeyStoreSpi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Certificate[] engineGetCertificateChain(String alias) {
|
public Certificate[] engineGetCertificateChain(String alias) {
|
||||||
alias = alias.toLowerCase();
|
alias = alias.toLowerCase(Locale.ENGLISH);
|
||||||
return (Certificate[]) certChains.get(alias);
|
return (Certificate[]) certChains.get(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Certificate engineGetCertificate(String alias) {
|
public Certificate engineGetCertificate(String alias) {
|
||||||
alias = alias.toLowerCase();
|
alias = alias.toLowerCase(Locale.ENGLISH);
|
||||||
if (engineIsKeyEntry(alias)) {
|
if (engineIsKeyEntry(alias)) {
|
||||||
Certificate[] certChain = (Certificate[]) certChains.get(alias);
|
Certificate[] certChain = (Certificate[]) certChains.get(alias);
|
||||||
if (certChain != null && certChain.length > 0) return certChain[0];
|
if (certChain != null && certChain.length > 0) return certChain[0];
|
||||||
@ -218,7 +218,7 @@ public class JKS extends KeyStoreSpi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Date engineGetCreationDate(String alias) {
|
public Date engineGetCreationDate(String alias) {
|
||||||
alias = alias.toLowerCase();
|
alias = alias.toLowerCase(Locale.ENGLISH);
|
||||||
return (Date) dates.get(alias);
|
return (Date) dates.get(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ public class JKS extends KeyStoreSpi {
|
|||||||
|
|
||||||
public void engineSetKeyEntry(String alias, Key key, char[] passwd, Certificate[] certChain)
|
public void engineSetKeyEntry(String alias, Key key, char[] passwd, Certificate[] certChain)
|
||||||
throws KeyStoreException {
|
throws KeyStoreException {
|
||||||
alias = alias.toLowerCase();
|
alias = alias.toLowerCase(Locale.ENGLISH);
|
||||||
if (trustedCerts.containsKey(alias))
|
if (trustedCerts.containsKey(alias))
|
||||||
throw new KeyStoreException("\"" + alias + " is a trusted certificate entry");
|
throw new KeyStoreException("\"" + alias + " is a trusted certificate entry");
|
||||||
privateKeys.put(alias, encryptKey(key, charsToBytes(passwd)));
|
privateKeys.put(alias, encryptKey(key, charsToBytes(passwd)));
|
||||||
@ -242,7 +242,7 @@ public class JKS extends KeyStoreSpi {
|
|||||||
|
|
||||||
public void engineSetKeyEntry(String alias, byte[] encodedKey, Certificate[] certChain)
|
public void engineSetKeyEntry(String alias, byte[] encodedKey, Certificate[] certChain)
|
||||||
throws KeyStoreException {
|
throws KeyStoreException {
|
||||||
alias = alias.toLowerCase();
|
alias = alias.toLowerCase(Locale.ENGLISH);
|
||||||
if (trustedCerts.containsKey(alias))
|
if (trustedCerts.containsKey(alias))
|
||||||
throw new KeyStoreException("\"" + alias + "\" is a trusted certificate entry");
|
throw new KeyStoreException("\"" + alias + "\" is a trusted certificate entry");
|
||||||
try {
|
try {
|
||||||
@ -263,7 +263,7 @@ public class JKS extends KeyStoreSpi {
|
|||||||
|
|
||||||
public void engineSetCertificateEntry(String alias, Certificate cert)
|
public void engineSetCertificateEntry(String alias, Certificate cert)
|
||||||
throws KeyStoreException {
|
throws KeyStoreException {
|
||||||
alias = alias.toLowerCase();
|
alias = alias.toLowerCase(Locale.ENGLISH);
|
||||||
if (privateKeys.containsKey(alias))
|
if (privateKeys.containsKey(alias))
|
||||||
throw new KeyStoreException("\"" + alias + "\" is a private key entry");
|
throw new KeyStoreException("\"" + alias + "\" is a private key entry");
|
||||||
if (cert == null)
|
if (cert == null)
|
||||||
@ -276,7 +276,7 @@ public class JKS extends KeyStoreSpi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void engineDeleteEntry(String alias) throws KeyStoreException {
|
public void engineDeleteEntry(String alias) throws KeyStoreException {
|
||||||
alias = alias.toLowerCase();
|
alias = alias.toLowerCase(Locale.ENGLISH);
|
||||||
aliases.remove(alias);
|
aliases.remove(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ public class JKS extends KeyStoreSpi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean engineContainsAlias(String alias) {
|
public boolean engineContainsAlias(String alias) {
|
||||||
alias = alias.toLowerCase();
|
alias = alias.toLowerCase(Locale.ENGLISH);
|
||||||
return aliases.contains(alias);
|
return aliases.contains(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,12 +294,12 @@ public class JKS extends KeyStoreSpi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean engineIsKeyEntry(String alias) {
|
public boolean engineIsKeyEntry(String alias) {
|
||||||
alias = alias.toLowerCase();
|
alias = alias.toLowerCase(Locale.ENGLISH);
|
||||||
return privateKeys.containsKey(alias);
|
return privateKeys.containsKey(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean engineIsCertificateEntry(String alias) {
|
public boolean engineIsCertificateEntry(String alias) {
|
||||||
alias = alias.toLowerCase();
|
alias = alias.toLowerCase(Locale.ENGLISH);
|
||||||
return trustedCerts.containsKey(alias);
|
return trustedCerts.containsKey(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import java.security.KeyStore;
|
|||||||
import java.security.Provider;
|
import java.security.Provider;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.security.cert.Certificate;
|
import java.security.cert.Certificate;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +61,7 @@ public class KeyStoreFileManager {
|
|||||||
public static KeyStore createKeyStore(String keystorePath, char[] password)
|
public static KeyStore createKeyStore(String keystorePath, char[] password)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
KeyStore ks = null;
|
KeyStore ks = null;
|
||||||
if (keystorePath.toLowerCase().endsWith(".bks")) {
|
if (keystorePath.toLowerCase(Locale.ENGLISH).endsWith(".bks")) {
|
||||||
ks = KeyStore.getInstance("bks", new BouncyCastleProvider());
|
ks = KeyStore.getInstance("bks", new BouncyCastleProvider());
|
||||||
} else ks = new JksKeyStore();
|
} else ks = new JksKeyStore();
|
||||||
ks.load(null, password);
|
ks.load(null, password);
|
||||||
@ -206,7 +207,7 @@ public class KeyStoreFileManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
KeyStore ks = loadKeyStore(keystorePath, storePass);
|
KeyStore ks = loadKeyStore(keystorePath, storePass);
|
||||||
if (ks instanceof JksKeyStore) newKeyName = newKeyName.toLowerCase();
|
if (ks instanceof JksKeyStore) newKeyName = newKeyName.toLowerCase(Locale.ENGLISH);
|
||||||
|
|
||||||
if (ks.containsAlias(newKeyName)) throw new KeyNameConflictException();
|
if (ks.containsAlias(newKeyName)) throw new KeyNameConflictException();
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.SequenceInputStream;
|
import java.io.SequenceInputStream;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
import java.util.zip.Inflater;
|
import java.util.zip.Inflater;
|
||||||
import java.util.zip.InflaterInputStream;
|
import java.util.zip.InflaterInputStream;
|
||||||
@ -91,7 +92,7 @@ public class ZioEntry implements Cloneable {
|
|||||||
this.compressedSize = this.size;
|
this.compressedSize = this.size;
|
||||||
|
|
||||||
if (getLogger().isDebugEnabled())
|
if (getLogger().isDebugEnabled())
|
||||||
getLogger().debug(String.format("Computing CRC for %s, size=%d", sourceDataFile, size));
|
getLogger().debug(String.format(Locale.ENGLISH, "Computing CRC for %s, size=%d", sourceDataFile, size));
|
||||||
|
|
||||||
// compute CRC
|
// compute CRC
|
||||||
CRC32 crc = new CRC32();
|
CRC32 crc = new CRC32();
|
||||||
@ -292,10 +293,10 @@ public class ZioEntry implements Cloneable {
|
|||||||
output.writeBytes(alignBytes, 0, numAlignBytes);
|
output.writeBytes(alignBytes, 0, numAlignBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) getLogger().debug(String.format("Data position 0x%08x", output.getFilePointer()));
|
if (debug) getLogger().debug(String.format(Locale.ENGLISH, "Data position 0x%08x", output.getFilePointer()));
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
output.writeBytes(data);
|
output.writeBytes(data);
|
||||||
if (debug) getLogger().debug(String.format("Wrote %d bytes", data.length));
|
if (debug) getLogger().debug(String.format(Locale.ENGLISH, "Wrote %d bytes", data.length));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (debug) getLogger().debug(String.format("Seeking to position 0x%08x", dataPosition));
|
if (debug) getLogger().debug(String.format("Seeking to position 0x%08x", dataPosition));
|
||||||
@ -309,10 +310,10 @@ public class ZioEntry implements Cloneable {
|
|||||||
int numRead = zipInput.in.read(buffer, 0, (int) Math.min(compressedSize - totalCount, bufferSize));
|
int numRead = zipInput.in.read(buffer, 0, (int) Math.min(compressedSize - totalCount, bufferSize));
|
||||||
if (numRead > 0) {
|
if (numRead > 0) {
|
||||||
output.writeBytes(buffer, 0, numRead);
|
output.writeBytes(buffer, 0, numRead);
|
||||||
if (debug) getLogger().debug(String.format("Wrote %d bytes", numRead));
|
if (debug) getLogger().debug(String.format(Locale.ENGLISH, "Wrote %d bytes", numRead));
|
||||||
totalCount += numRead;
|
totalCount += numRead;
|
||||||
} else
|
} else
|
||||||
throw new IllegalStateException(String.format("EOF reached while copying %s with %d bytes left to go", filename, compressedSize - totalCount));
|
throw new IllegalStateException(String.format(Locale.ENGLISH, "EOF reached while copying %s with %d bytes left to go", filename, compressedSize - totalCount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -434,7 +435,7 @@ public class ZioEntry implements Cloneable {
|
|||||||
while (count != size) {
|
while (count != size) {
|
||||||
int numRead = din.read(tmpdata, count, size - count);
|
int numRead = din.read(tmpdata, count, size - count);
|
||||||
if (numRead < 0)
|
if (numRead < 0)
|
||||||
throw new IllegalStateException(String.format("Read failed, expecting %d bytes, got %d instead", size, count));
|
throw new IllegalStateException(String.format(Locale.ENGLISH, "Read failed, expecting %d bytes, got %d instead", size, count));
|
||||||
count += numRead;
|
count += numRead;
|
||||||
}
|
}
|
||||||
return tmpdata;
|
return tmpdata;
|
||||||
|
@ -23,6 +23,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +48,7 @@ public class ZioEntryInputStream extends InputStream {
|
|||||||
raf = entry.getZipInput().in;
|
raf = entry.getZipInput().in;
|
||||||
long dpos = entry.getDataPosition();
|
long dpos = entry.getDataPosition();
|
||||||
if (dpos >= 0) {
|
if (dpos >= 0) {
|
||||||
if (debug) log.debug(String.format("Seeking to %d", entry.getDataPosition()));
|
if (debug) log.debug(String.format(Locale.ENGLISH, "Seeking to %d", entry.getDataPosition()));
|
||||||
raf.seek(entry.getDataPosition());
|
raf.seek(entry.getDataPosition());
|
||||||
} else {
|
} else {
|
||||||
// seeks to, then reads, the local header, causing the
|
// seeks to, then reads, the local header, causing the
|
||||||
@ -78,7 +79,7 @@ public class ZioEntryInputStream extends InputStream {
|
|||||||
@Override
|
@Override
|
||||||
public int available() throws IOException {
|
public int available() throws IOException {
|
||||||
int available = size - offset;
|
int available = size - offset;
|
||||||
if (debug) log.debug(String.format("Available = %d", available));
|
if (debug) log.debug(String.format(Locale.ENGLISH, "Available = %d", available));
|
||||||
if (available == 0 && returnDummyByte) return 1;
|
if (available == 0 && returnDummyByte) return 1;
|
||||||
else return available;
|
else return available;
|
||||||
}
|
}
|
||||||
@ -119,7 +120,7 @@ public class ZioEntryInputStream extends InputStream {
|
|||||||
if (monitor != null) monitor.write(b, off, numRead);
|
if (monitor != null) monitor.write(b, off, numRead);
|
||||||
offset += numRead;
|
offset += numRead;
|
||||||
}
|
}
|
||||||
if (debug) log.debug(String.format("Read %d bytes for read(b,%d,%d)", numRead, off, len));
|
if (debug) log.debug(String.format(Locale.ENGLISH, "Read %d bytes for read(b,%d,%d)", numRead, off, len));
|
||||||
return numRead;
|
return numRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ public class ZioEntryInputStream extends InputStream {
|
|||||||
public long skip(long n) throws IOException {
|
public long skip(long n) throws IOException {
|
||||||
long numToSkip = Math.min(n, available());
|
long numToSkip = Math.min(n, available());
|
||||||
raf.seek(raf.getFilePointer() + numToSkip);
|
raf.seek(raf.getFilePointer() + numToSkip);
|
||||||
if (debug) log.debug(String.format("Skipped %d bytes", numToSkip));
|
if (debug) log.debug(String.format(Locale.ENGLISH, "Skipped %d bytes", numToSkip));
|
||||||
return numToSkip;
|
return numToSkip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import java.io.IOException;
|
|||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
@ -149,8 +150,8 @@ public class ZipInput implements Closeable {
|
|||||||
|
|
||||||
boolean debug = getLogger().isDebugEnabled();
|
boolean debug = getLogger().isDebugEnabled();
|
||||||
if (debug) {
|
if (debug) {
|
||||||
getLogger().debug(String.format("EOCD found in %d iterations", scanIterations));
|
getLogger().debug(String.format(Locale.ENGLISH, "EOCD found in %d iterations", scanIterations));
|
||||||
getLogger().debug(String.format("Directory entries=%d, size=%d, offset=%d/0x%08x", centralEnd.totalCentralEntries,
|
getLogger().debug(String.format(Locale.ENGLISH, "Directory entries=%d, size=%d, offset=%d/0x%08x", centralEnd.totalCentralEntries,
|
||||||
centralEnd.centralDirectorySize, centralEnd.centralStartOffset, centralEnd.centralStartOffset));
|
centralEnd.centralDirectorySize, centralEnd.centralStartOffset, centralEnd.centralStartOffset));
|
||||||
|
|
||||||
ZipListingHelper.listHeader(getLogger());
|
ZipListingHelper.listHeader(getLogger());
|
||||||
|
@ -21,6 +21,7 @@ import kellinwood.logging.LoggerInterface;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -38,7 +39,7 @@ public class ZipListingHelper {
|
|||||||
public static void listEntry(LoggerInterface log, ZioEntry entry) {
|
public static void listEntry(LoggerInterface log, ZioEntry entry) {
|
||||||
int ratio = 0;
|
int ratio = 0;
|
||||||
if (entry.getSize() > 0) ratio = (100 * (entry.getSize() - entry.getCompressedSize())) / entry.getSize();
|
if (entry.getSize() > 0) ratio = (100 * (entry.getSize() - entry.getCompressedSize())) / entry.getSize();
|
||||||
log.debug(String.format("%8d %6s %8d %4d%% %s %08x %s",
|
log.debug(String.format(Locale.ENGLISH, "%8d %6s %8d %4d%% %s %08x %s",
|
||||||
entry.getSize(),
|
entry.getSize(),
|
||||||
entry.getCompression() == 0 ? "Stored" : "Defl:N",
|
entry.getCompression() == 0 ? "Stored" : "Defl:N",
|
||||||
entry.getCompressedSize(),
|
entry.getCompressedSize(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user