From 6e5e857a967579f3050f4cbb6ab07da2cd9b0e49 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 21 May 2020 12:45:15 +0300 Subject: Fix build with new http-signatures-java library * cleanup deprecation warnings --- src/main/java/com/juick/SignatureManager.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/juick') 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 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 headers) { String signatureString = headers.get("signature"); logger.info("Signature: {}", signatureString); - Signature signature = Signature.fromString(signatureString); + Signature signature = Signature.fromString(signatureString, null); Optional context = getContext(UriComponentsBuilder.fromUriString(signature.getKeyId()) .fragment(null).build().toUri()); if (context.isPresent() && context.get() instanceof Person) { -- cgit v1.2.3