You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2022/04/20 19:29:40 UTC
[tika] branch main updated: TIKA-3724 - refactor AES initialization
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/main by this push:
new 4b20970cb TIKA-3724 - refactor AES initialization
4b20970cb is described below
commit 4b20970cb1b579d19a07e7efac8fe5b99da67715
Author: tallison <ta...@apache.org>
AuthorDate: Wed Apr 20 15:28:45 2022 -0400
TIKA-3724 - refactor AES initialization
---
.../src/main/java/org/apache/tika/client/HttpClientFactory.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/tika-pipes/tika-httpclient-commons/src/main/java/org/apache/tika/client/HttpClientFactory.java b/tika-pipes/tika-httpclient-commons/src/main/java/org/apache/tika/client/HttpClientFactory.java
index 56fce6353..e29c03b2c 100644
--- a/tika-pipes/tika-httpclient-commons/src/main/java/org/apache/tika/client/HttpClientFactory.java
+++ b/tika-pipes/tika-httpclient-commons/src/main/java/org/apache/tika/client/HttpClientFactory.java
@@ -427,17 +427,16 @@ public class HttpClientFactory {
private static class AES {
private final SecretKeySpec secretKey;
- private byte[] key;
private AES() throws TikaConfigException {
secretKey = setKey(System.getenv(AES_ENV_VAR));
}
- private SecretKeySpec setKey(String myKey) throws TikaConfigException {
- MessageDigest sha = null;
+ private static SecretKeySpec setKey(String myKey) throws TikaConfigException {
+ //TODO: sha-256?
try {
- key = myKey.getBytes(StandardCharsets.UTF_8);
- sha = MessageDigest.getInstance("SHA-1");
+ byte[] key = myKey.getBytes(StandardCharsets.UTF_8);
+ MessageDigest sha = MessageDigest.getInstance("SHA-1");
key = sha.digest(key);
key = Arrays.copyOf(key, 16);
return new SecretKeySpec(key, "AES");