aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/juick/SignatureManager.java9
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) {