Skip to content

Commit

Permalink
Address Spotbugs warning
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-tkachenko-datadog committed Sep 7, 2023
1 parent 437749d commit 87e8b6d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -87,7 +88,7 @@ private String getTracerDistributionUrl(DatadogTracerJobProperty<?> tracerConfig
}

private byte[] getTracerSignaturePublicKey(DatadogTracerJobProperty<?> tracerConfig) {
return getSetting(tracerConfig, TRACER_DISTRIBUTION_URL_ENV_VAR, SignatureVerifier.DATADOG_PUBLIC_KEY, String::getBytes);
return getSetting(tracerConfig, TRACER_DISTRIBUTION_URL_ENV_VAR, SignatureVerifier.DATADOG_PUBLIC_KEY.getBytes(StandardCharsets.UTF_8), String::getBytes);
}

private <T> T getSetting(DatadogTracerJobProperty<?> tracerConfig, String envVariableName, T defaultValue, Function<String, T> parser) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class SignatureVerifier {

public static final byte[] DATADOG_PUBLIC_KEY = (
public static final String DATADOG_PUBLIC_KEY = (
"-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +
"Version: Hockeypuck 2.1.0-222-g25248d4\n" +
"Comment: Hostname:\n" +
Expand Down Expand Up @@ -49,7 +49,7 @@ public class SignatureVerifier {
"IPdMz7WGf1S8iuZcBwF6PhAqJJv41pJ0mO4ewnZbnQ==\n" +
"=7erW\n" +
"-----END PGP PUBLIC KEY BLOCK-----"
).getBytes(StandardCharsets.UTF_8);
);

public static boolean verifySignature(InputStream artifactStream, InputStream signatureStream, InputStream publicKeyStream) throws Exception {
PGPPublicKeyRing publicKeys = loadPublicKeyRing(publicKeyStream);
Expand Down

0 comments on commit 87e8b6d

Please sign in to comment.