|
8 | 8 | import java.security.MessageDigest;
|
9 | 9 | import java.security.NoSuchAlgorithmException;
|
10 | 10 | import java.util.ArrayList;
|
| 11 | +import java.util.Base64; |
11 | 12 | import java.util.List;
|
12 | 13 |
|
13 |
| -import javax.xml.bind.DatatypeConverter; |
14 |
| - |
15 | 14 | import com.fasterxml.jackson.annotation.JsonCreator;
|
16 | 15 | import com.fasterxml.jackson.annotation.JsonValue;
|
17 | 16 | import com.fasterxml.jackson.databind.JsonNode;
|
@@ -74,28 +73,23 @@ public EndpointConfiguration(ObjectNode json)
|
74 | 73 | authenticationOptions.add(node.asText());
|
75 | 74 |
|
76 | 75 | }
|
77 |
| - if (json.has("tag")) |
78 |
| - { |
79 |
| - tag = json.get("tag").asText(); |
80 |
| - } else |
81 |
| - { |
82 |
| - tag = generateTag(configuration); |
83 |
| - } |
| 76 | + |
| 77 | + tag = json.has("tag") ? json.get("tag").asText() : generateTag(configuration); |
84 | 78 | }
|
85 | 79 |
|
86 | 80 | private String generateTag(String configuration)
|
87 | 81 | {
|
88 |
| - if(configuration != null) |
| 82 | + if (configuration != null) |
89 | 83 | {
|
90 | 84 | try
|
91 | 85 | {
|
92 |
| - return DatatypeConverter |
93 |
| - .printHexBinary((MessageDigest.getInstance("SHA-1").digest( |
94 |
| - configuration.getBytes(StandardCharsets.UTF_8)))) |
95 |
| - .toUpperCase(); |
| 86 | + byte[] digest = MessageDigest.getInstance("SHA-256").digest( |
| 87 | + configuration.getBytes(StandardCharsets.UTF_8)); |
| 88 | + return Base64.getEncoder().encodeToString(digest); |
96 | 89 | } catch (NoSuchAlgorithmException e)
|
97 | 90 | {
|
98 |
| - return configuration; |
| 91 | + throw new IllegalStateException("Can not generate message fingerprint " |
| 92 | + + "with SHA 256, java platform problem?", e); |
99 | 93 | }
|
100 | 94 | } else
|
101 | 95 | {
|
|
0 commit comments