Migrates to the new capitalization function
This commit is contained in:
@@ -9,6 +9,7 @@ import com.vitorpamplona.quartz.nip03Timestamp.ots.http.Response;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -94,7 +95,7 @@ public class Calendar implements ICalendar {
|
||||
headers.put("User-Agent", "java-opentimestamps");
|
||||
headers.put("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
URL obj = new URL(url + "/timestamp/" + Utils.bytesToHex(commitment).toLowerCase());
|
||||
URL obj = new URL(url + "/timestamp/" + Utils.bytesToHex(commitment).toLowerCase(Locale.ROOT));
|
||||
Request task = new Request(obj);
|
||||
task.setHeaders(headers);
|
||||
Response response = task.call();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.vitorpamplona.quartz.nip03Timestamp.ots;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.ots.op.OpCrypto;
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.ots.op.OpKECCAK256;
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.ots.op.OpRIPEMD160;
|
||||
@@ -11,6 +13,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Hash {
|
||||
|
||||
@@ -121,13 +124,13 @@ public class Hash {
|
||||
* @return The generated com.vitorpamplona.quartz.ots.OpCrypto object.
|
||||
*/
|
||||
public static OpCrypto getOp(String label) {
|
||||
if (label.toLowerCase().equals(new OpSHA1()._TAG_NAME())) {
|
||||
if (label.toLowerCase(Locale.ROOT).equals(new OpSHA1()._TAG_NAME())) {
|
||||
return new OpSHA1();
|
||||
} else if (label.toLowerCase().equals(new OpSHA256()._TAG_NAME())) {
|
||||
} else if (label.toLowerCase(Locale.ROOT).equals(new OpSHA256()._TAG_NAME())) {
|
||||
return new OpSHA256();
|
||||
} else if (label.toLowerCase().equals(new OpRIPEMD160()._TAG_NAME())) {
|
||||
} else if (label.toLowerCase(Locale.ROOT).equals(new OpRIPEMD160()._TAG_NAME())) {
|
||||
return new OpRIPEMD160();
|
||||
} else if (label.toLowerCase().equals(new OpKECCAK256()._TAG_NAME())) {
|
||||
} else if (label.toLowerCase(Locale.ROOT).equals(new OpKECCAK256()._TAG_NAME())) {
|
||||
return new OpKECCAK256();
|
||||
}
|
||||
|
||||
@@ -187,6 +190,7 @@ public class Hash {
|
||||
*
|
||||
* @return The output.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
String output = "com.vitorpamplona.quartz.ots.Hash\n";
|
||||
|
||||
+4
-3
@@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -63,7 +64,7 @@ public class OpenTimestamps {
|
||||
return "No ots file";
|
||||
}
|
||||
|
||||
String fileHash = Utils.bytesToHex(detachedTimestampFile.timestamp.msg).toLowerCase();
|
||||
String fileHash = Utils.bytesToHex(detachedTimestampFile.timestamp.msg).toLowerCase(Locale.ROOT);
|
||||
String hashOp = ((OpCrypto) detachedTimestampFile.fileHashOp)._TAG_NAME();
|
||||
|
||||
String firstLine = "File " + hashOp + " hash: " + fileHash + '\n';
|
||||
@@ -82,7 +83,7 @@ public class OpenTimestamps {
|
||||
return "No timestamp";
|
||||
}
|
||||
|
||||
String fileHash = Utils.bytesToHex(timestamp.msg).toLowerCase();
|
||||
String fileHash = Utils.bytesToHex(timestamp.msg).toLowerCase(Locale.ROOT);
|
||||
String firstLine = "Hash: " + fileHash + '\n';
|
||||
|
||||
return firstLine + "Timestamp:\n" + timestamp.strTree(0);
|
||||
@@ -270,7 +271,7 @@ public class OpenTimestamps {
|
||||
|
||||
public HashMap<VerifyResult.Chains, VerifyResult> verify(DetachedTimestampFile ots, byte[] diggest) throws Exception {
|
||||
if (!Arrays.equals(ots.fileDigest(), diggest)) {
|
||||
Log.e("OpenTimestamp", "Expected digest " + Hex.encode(ots.fileDigest()).toLowerCase());
|
||||
Log.e("OpenTimestamp", "Expected digest " + Hex.encode(ots.fileDigest()).toLowerCase(Locale.ROOT));
|
||||
Log.e("OpenTimestamp", "File does not match original!");
|
||||
throw new Exception("File does not match original!");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
@@ -376,7 +377,7 @@ public class Timestamp {
|
||||
|
||||
if (attestation instanceof BitcoinBlockHeaderAttestation) {
|
||||
String tx = Utils.bytesToHex(Utils.arrayReverse(this.msg));
|
||||
builder.append(Timestamp.indention(indent) + "# Bitcoin block merkle root " + tx.toLowerCase() + "\n");
|
||||
builder.append(Timestamp.indention(indent) + "# Bitcoin block merkle root " + tx.toLowerCase(Locale.ROOT) + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -395,7 +396,7 @@ public class Timestamp {
|
||||
curPar = ((OpBinary) op).arg;
|
||||
}
|
||||
|
||||
builder.append(Timestamp.indention(indent) + " -> " + op.toString().toLowerCase() + strResult(verbosity, curPar, curRes).toLowerCase() + "\n");
|
||||
builder.append(Timestamp.indention(indent) + " -> " + op.toString().toLowerCase(Locale.ROOT) + strResult(verbosity, curPar, curRes).toLowerCase(Locale.ROOT) + "\n");
|
||||
builder.append(timestamp.strTree(indent + 1, verbosity));
|
||||
}
|
||||
} else if (this.ops.size() > 0) {
|
||||
@@ -411,7 +412,7 @@ public class Timestamp {
|
||||
curPar = ((OpBinary) op).arg;
|
||||
}
|
||||
|
||||
builder.append(Timestamp.indention(indent) + op.toString().toLowerCase() + strResult(verbosity, curPar, curRes).toLowerCase() + "\n");
|
||||
builder.append(Timestamp.indention(indent) + op.toString().toLowerCase(Locale.ROOT) + strResult(verbosity, curPar, curRes).toLowerCase(Locale.ROOT) + "\n");
|
||||
builder.append(timestamp.strTree(indent, verbosity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.vitorpamplona.quartz.nip03Timestamp.ots;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
@@ -181,7 +182,7 @@ public class Utils {
|
||||
* @return the string, with its first character converted to uppercase
|
||||
*/
|
||||
public static String toUpperFirstLetter(String string) {
|
||||
return string.substring(0, 1).toUpperCase() + string.substring(1).toLowerCase();
|
||||
return string.substring(0, 1).toUpperCase(Locale.getDefault()) + string.substring(1).toLowerCase(Locale.getDefault());
|
||||
}
|
||||
|
||||
// TODO: This is not the way to do logging. Fix later, possibly with slf4j annotation. Need to read up on the subject.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.vitorpamplona.quartz.nip03Timestamp.ots;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
@@ -32,6 +34,7 @@ public class VerifyResult implements Comparable<VerifyResult> {
|
||||
String pattern = "yyyy-MM-dd z";
|
||||
Locale locale = new Locale("en", "UK");
|
||||
DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern, dateFormatSymbols);
|
||||
String string = simpleDateFormat.format(new Date(timestamp * 1000));
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.vitorpamplona.quartz.nip03Timestamp.ots.exceptions.DeserializationExc
|
||||
import com.vitorpamplona.quartz.utils.Hex;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Operations that act on a message and a single argument.
|
||||
@@ -56,7 +57,7 @@ public abstract class OpBinary extends Op implements Comparable<Op> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this._TAG_NAME() + ' ' + Hex.encode(this.arg).toLowerCase();
|
||||
return this._TAG_NAME() + ' ' + Hex.encode(this.arg).toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user