diff options
author | Vitaly Takmazov | 2020-05-21 12:45:15 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2020-05-21 12:45:15 +0300 |
commit | 6e5e857a967579f3050f4cbb6ab07da2cd9b0e49 (patch) | |
tree | 0293d1a52af414e4d7b82eb2322a972ef2b68439 /src/main/java | |
parent | 8dc6f5a8358cd4f0eceef46109592c45f26547ea (diff) |
Fix build with new http-signatures-java library
* cleanup deprecation warnings
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/juick/SignatureManager.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/com/juick/SignatureManager.java b/src/main/java/com/juick/SignatureManager.java index 959242f5..037f9e30 100644 --- a/src/main/java/com/juick/SignatureManager.java +++ b/src/main/java/com/juick/SignatureManager.java @@ -34,8 +34,10 @@ import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; +import org.tomitribe.auth.signatures.Algorithm; import org.tomitribe.auth.signatures.Signature; import org.tomitribe.auth.signatures.Signer; +import org.tomitribe.auth.signatures.SigningAlgorithm; import org.tomitribe.auth.signatures.Verifier; import rocks.xmpp.addr.Jid; @@ -46,6 +48,7 @@ import java.security.Key; import java.security.NoSuchAlgorithmException; import java.security.SignatureException; import java.time.Instant; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -87,8 +90,8 @@ public class SignatureManager { } public String addSignature(Person from, String host, String method, String path, String dateString, KeystoreManager keystoreManager) throws IOException { - Signature templateSignature = new Signature(from.getPublicKey().getId(), "rsa-sha256", null, - "(request-target)", "host", "date"); + Signature templateSignature = new Signature(from.getPublicKey().getId(), SigningAlgorithm.HS2019.getAlgorithmName(), Algorithm.RSA_SHA256.getJvmName(), null, + Arrays.asList("(request-target)", "host", "date")); Map<String, String> headers = new HashMap<>(); headers.put("host", host); headers.put("date", dateString); @@ -101,7 +104,7 @@ public class SignatureManager { public User verifySignature(String method, String path, Map<String, String> headers) { String signatureString = headers.get("signature"); logger.info("Signature: {}", signatureString); - Signature signature = Signature.fromString(signatureString); + Signature signature = Signature.fromString(signatureString, null); Optional<Context> context = getContext(UriComponentsBuilder.fromUriString(signature.getKeyId()) .fragment(null).build().toUri()); if (context.isPresent() && context.get() instanceof Person) { |