aboutsummaryrefslogtreecommitdiff
path: root/juick-server
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-11-01 13:13:08 +0300
committerGravatar Vitaly Takmazov2018-11-01 13:13:08 +0300
commit0dc2727e0633a4b865d814c7ab8450e3c815e511 (patch)
treeeee4ea810bdedf907baf098254c34be6700bed13 /juick-server
parent406d72ea371b95e30be68a511b9c516b67d34fd3 (diff)
ActivityPub: using custom http date formatter
Diffstat (limited to 'juick-server')
-rw-r--r--juick-server/src/main/java/com/juick/server/SignatureManager.java11
1 files changed, 4 insertions, 7 deletions
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<Void> response = apClient.postForEntity(inbox, request, Void.class);
- logger.info("accepted follower: {}", response.getStatusCodeValue());
- } catch (HttpClientErrorException e) {
- logger.warn("Signature exception", e);
- }
+ ResponseEntity<Void> 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<String, String> headers) {