From 0dc2727e0633a4b865d814c7ab8450e3c815e511 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 1 Nov 2018 13:13:08 +0300 Subject: ActivityPub: using custom http date formatter --- .../src/main/java/com/juick/server/SignatureManager.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'juick-server/src/main/java/com/juick') diff --git a/juick-server/src/main/java/com/juick/server/SignatureManager.java b/juick-server/src/main/java/com/juick/server/SignatureManager.java index 3b8a59a7..d43efd4a 100644 --- a/juick-server/src/main/java/com/juick/server/SignatureManager.java +++ b/juick-server/src/main/java/com/juick/server/SignatureManager.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.juick.server.api.activity.model.Context; import com.juick.server.api.activity.model.objects.Person; import com.juick.service.activities.DeleteUserEvent; +import com.juick.util.DateFormattersHolder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationEventPublisher; @@ -48,7 +49,7 @@ public class SignatureManager { UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(to.getInbox()); URI inbox = uriComponentsBuilder.build().toUri(); Instant now = Instant.now(); - String requestDate = DateTimeFormatter.RFC_1123_DATE_TIME.withZone(ZoneId.of("UTC")).format(now); + String requestDate = DateFormattersHolder.getHttpDateFormatter().format(now); Signature templateSignature = new Signature(from.getPublicKey().getId(), "rsa-sha256", null, "(request-target)", "host", "date"); Signer signer = new Signer(keystoreManager.getPrivateKey(), templateSignature); @@ -65,12 +66,8 @@ public class SignatureManager { // keystoreManager.getPublicKey(), "POST", inbox.getPath(), headers); logger.info("Sending context: {}", jsonMapper.writeValueAsString(data)); logger.info("Request date: {}", requestDate); - try { - ResponseEntity response = apClient.postForEntity(inbox, request, Void.class); - logger.info("accepted follower: {}", response.getStatusCodeValue()); - } catch (HttpClientErrorException e) { - logger.warn("Signature exception", e); - } + ResponseEntity response = apClient.postForEntity(inbox, request, Void.class); + logger.info("accepted follower: {}", response.getStatusCodeValue()); } public boolean verifySignature(String signatureString, URI actor, String method, String path, Map headers) { -- cgit v1.2.3