commit 2593dce6d0aeb44cfe3f29566d220b37a36801c9
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Sat May 13 20:25:26 2017 +0200
Fix deprecation warnings from Apache Commons Codec.
---
.../collector/bridgedescs/BridgeSnapshotReader.java | 4 ++--
.../collector/bridgedescs/SanitizedBridgesWriter.java | 16 ++++++++--------
.../torproject/collector/persist/VotePersistence.java | 2 +-
.../relaydescs/CachedRelayDescriptorReader.java | 6 +++---
.../collector/relaydescs/RelayDescriptorParser.java | 6 +++---
5 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/main/java/org/torproject/collector/bridgedescs/BridgeSnapshotReader.java b/src/main/java/org/torproject/collector/bridgedescs/BridgeSnapshotReader.java
index 9ffdf10..54aa891 100644
--- a/src/main/java/org/torproject/collector/bridgedescs/BridgeSnapshotReader.java
+++ b/src/main/java/org/torproject/collector/bridgedescs/BridgeSnapshotReader.java
@@ -141,7 +141,7 @@ public class BridgeSnapshotReader {
if (allData.length == 0) {
continue;
}
- String fileDigest = Hex.encodeHexString(DigestUtils.sha(
+ String fileDigest = Hex.encodeHexString(DigestUtils.sha1(
allData));
String ascii = new String(allData, "US-ASCII");
BufferedReader br3 = new BufferedReader(new StringReader(
@@ -194,7 +194,7 @@ public class BridgeSnapshotReader {
System.arraycopy(allData, start, descBytes, 0,
end - start);
String descriptorDigest = Hex.encodeHexString(
- DigestUtils.sha(descBytes));
+ DigestUtils.sha1(descBytes));
if (!descriptorImportHistory.contains(
descriptorDigest)) {
bdp.parse(descBytes, dateTime, authorityFingerprint);
diff --git a/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java b/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
index ae3db8f..6ad2325 100644
--- a/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
+++ b/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java
@@ -521,14 +521,14 @@ public class SanitizedBridgesWriter extends CollecTorMain {
}
/* Write scrubbed r line to buffer. */
- byte[] hashedBridgeIdentity = DigestUtils.sha(fingerprintBytes);
+ byte[] hashedBridgeIdentity = DigestUtils.sha1(fingerprintBytes);
String hashedBridgeIdentityBase64 = Base64.encodeBase64String(
hashedBridgeIdentity).substring(0, 27);
hashedBridgeIdentityHex = Hex.encodeHexString(
hashedBridgeIdentity);
String descriptorIdentifier = parts[3];
String hashedDescriptorIdentifier = Base64.encodeBase64String(
- DigestUtils.sha(Base64.decodeBase64(descriptorIdentifier
+ DigestUtils.sha1(Base64.decodeBase64(descriptorIdentifier
+ "=="))).substring(0, 27);
String scrubbedAddress = scrubIpv4Address(address,
fingerprintBytes,
@@ -725,7 +725,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
.replaceAll(" ", "").toLowerCase();
byte[] fingerprintBytes = Hex.decodeHex(
fingerprint.toCharArray());
- hashedBridgeIdentity = DigestUtils.shaHex(fingerprintBytes)
+ hashedBridgeIdentity = DigestUtils.sha1Hex(fingerprintBytes)
.toLowerCase();
try {
scrubbedAddress = scrubIpv4Address(address, fingerprintBytes,
@@ -799,7 +799,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
+ "expected: '" + line + "'. Skipping descriptor.");
return;
}
- scrubbed.append("extra-info-digest " + DigestUtils.shaHex(
+ scrubbed.append("extra-info-digest " + DigestUtils.sha1Hex(
Hex.decodeHex(parts[1].toCharArray())).toUpperCase());
if (parts.length > 2) {
if (!Base64.isBase64(parts[2])) {
@@ -894,7 +894,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
StringBuilder familyLine = new StringBuilder("family");
for (String s : line.substring(7).split(" ")) {
if (s.startsWith("$")) {
- familyLine.append(" $" + DigestUtils.shaHex(Hex.decodeHex(
+ familyLine.append(" $" + DigestUtils.sha1Hex(Hex.decodeHex(
s.substring(1).toCharArray())).toUpperCase());
} else {
familyLine.append(" " + s);
@@ -952,7 +952,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
if (start >= 0 && sig >= 0 && sig > start) {
byte[] forDigest = new byte[sig - start];
System.arraycopy(data, start, forDigest, 0, sig - start);
- descriptorDigest = DigestUtils.shaHex(DigestUtils.sha(forDigest));
+ descriptorDigest = DigestUtils.sha1Hex(DigestUtils.sha1(forDigest));
}
} catch (UnsupportedEncodingException e) {
/* Handle below. */
@@ -1112,7 +1112,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
+ "'. Skipping descriptor.");
return;
}
- hashedBridgeIdentity = DigestUtils.shaHex(Hex.decodeHex(
+ hashedBridgeIdentity = DigestUtils.sha1Hex(Hex.decodeHex(
parts[2].toCharArray())).toLowerCase();
scrubbed = new StringBuilder("extra-info " + parts[1] + " "
+ hashedBridgeIdentity.toUpperCase() + "\n");
@@ -1237,7 +1237,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
if (start >= 0 && sig >= 0 && sig > start) {
byte[] forDigest = new byte[sig - start];
System.arraycopy(data, start, forDigest, 0, sig - start);
- descriptorDigest = DigestUtils.shaHex(DigestUtils.sha(forDigest));
+ descriptorDigest = DigestUtils.sha1Hex(DigestUtils.sha1(forDigest));
}
} catch (UnsupportedEncodingException e) {
/* Handle below. */
diff --git a/src/main/java/org/torproject/collector/persist/VotePersistence.java b/src/main/java/org/torproject/collector/persist/VotePersistence.java
index c89ee51..26f9a72 100644
--- a/src/main/java/org/torproject/collector/persist/VotePersistence.java
+++ b/src/main/java/org/torproject/collector/persist/VotePersistence.java
@@ -55,7 +55,7 @@ public class VotePersistence
sig += sigToken.length();
byte[] forDigest = new byte[sig - start];
System.arraycopy(bytes, start, forDigest, 0, sig - start);
- digest = DigestUtils.shaHex(forDigest).toUpperCase();
+ digest = DigestUtils.sha1Hex(forDigest).toUpperCase();
} else {
log.error("No digest calculation possible. Returning empty string.");
}
diff --git a/src/main/java/org/torproject/collector/relaydescs/CachedRelayDescriptorReader.java b/src/main/java/org/torproject/collector/relaydescs/CachedRelayDescriptorReader.java
index 2fb9978..34da5fc 100644
--- a/src/main/java/org/torproject/collector/relaydescs/CachedRelayDescriptorReader.java
+++ b/src/main/java/org/torproject/collector/relaydescs/CachedRelayDescriptorReader.java
@@ -135,7 +135,7 @@ public class CachedRelayDescriptorReader {
/* Parse the cached consensus if we haven't parsed it before
* (but regardless of whether it's stale or not). */
if (rdp != null) {
- String digest = Hex.encodeHexString(DigestUtils.sha(
+ String digest = Hex.encodeHexString(DigestUtils.sha1(
allData));
if (!lastImportHistory.contains(digest)
&& !currentImportHistory.contains(digest)) {
@@ -162,7 +162,7 @@ public class CachedRelayDescriptorReader {
System.arraycopy(allData, start, rawNetworkStatusBytes, 0,
next - start);
if (rdp != null) {
- String digest = Hex.encodeHexString(DigestUtils.sha(
+ String digest = Hex.encodeHexString(DigestUtils.sha1(
rawNetworkStatusBytes));
if (!lastImportHistory.contains(digest)
&& !currentImportHistory.contains(digest)) {
@@ -209,7 +209,7 @@ public class CachedRelayDescriptorReader {
byte[] descBytes = new byte[end - start];
System.arraycopy(allData, start, descBytes, 0, end - start);
if (rdp != null) {
- String digest = Hex.encodeHexString(DigestUtils.sha(
+ String digest = Hex.encodeHexString(DigestUtils.sha1(
descBytes));
if (!lastImportHistory.contains(digest)
&& !currentImportHistory.contains(digest)) {
diff --git a/src/main/java/org/torproject/collector/relaydescs/RelayDescriptorParser.java b/src/main/java/org/torproject/collector/relaydescs/RelayDescriptorParser.java
index 7f4ab29..537572b 100644
--- a/src/main/java/org/torproject/collector/relaydescs/RelayDescriptorParser.java
+++ b/src/main/java/org/torproject/collector/relaydescs/RelayDescriptorParser.java
@@ -210,7 +210,7 @@ public class RelayDescriptorParser {
sig += sigToken.length();
byte[] forDigest = new byte[sig - start];
System.arraycopy(data, start, forDigest, 0, sig - start);
- String digest = DigestUtils.shaHex(forDigest).toUpperCase();
+ String digest = DigestUtils.sha1Hex(forDigest).toUpperCase();
if (this.aw != null) {
this.aw.storeVote(data, validAfter, dirSource, digest,
serverDescriptorDigests);
@@ -260,7 +260,7 @@ public class RelayDescriptorParser {
if (start >= 0 || sig >= 0 || sig > start) {
byte[] forDigest = new byte[sig - start];
System.arraycopy(data, start, forDigest, 0, sig - start);
- digest = DigestUtils.shaHex(forDigest);
+ digest = DigestUtils.sha1Hex(forDigest);
}
if (this.aw != null && digest != null) {
this.aw.storeServerDescriptor(data, digest, published,
@@ -299,7 +299,7 @@ public class RelayDescriptorParser {
if (start >= 0 && sig >= 0 && sig > start) {
byte[] forDigest = new byte[sig - start];
System.arraycopy(data, start, forDigest, 0, sig - start);
- digest = DigestUtils.shaHex(forDigest);
+ digest = DigestUtils.sha1Hex(forDigest);
}
if (this.aw != null && digest != null) {
this.aw.storeExtraInfoDescriptor(data, digest, published);