aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/SignatureManager.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2021-08-21 03:49:12 +0300
committerGravatar Vitaly Takmazov2021-08-21 03:49:12 +0300
commit389e29881724b90daa466247aef1b8a164511bb9 (patch)
tree66888f12de37dfef24de79bc23c0f4c5fb2939e6 /src/main/java/com/juick/SignatureManager.java
parent880535098d71e80944bbc6496cba692d68c342b6 (diff)
ActivityPub: add Application as an actor type
Diffstat (limited to 'src/main/java/com/juick/SignatureManager.java')
-rw-r--r--src/main/java/com/juick/SignatureManager.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main/java/com/juick/SignatureManager.java b/src/main/java/com/juick/SignatureManager.java
index 35d6215f..d14eedd1 100644
--- a/src/main/java/com/juick/SignatureManager.java
+++ b/src/main/java/com/juick/SignatureManager.java
@@ -24,6 +24,7 @@ import com.juick.service.UserService;
import com.juick.util.DateFormattersHolder;
import com.juick.www.api.activity.model.Context;
import com.juick.www.api.activity.model.objects.Person;
+import com.juick.www.api.activity.model.objects.SecurityObject;
import com.juick.www.api.webfinger.model.Account;
import com.juick.www.api.webfinger.model.Link;
import org.apache.commons.lang3.StringUtils;
@@ -93,14 +94,14 @@ public class SignatureManager {
logger.info("Remote response: {}", response.getStatusCodeValue());
}
- public String addSignature(Person from, String host, String method,
+ public String addSignature(SecurityObject from, String host, String method,
String path, String dateString, String digestHeader)
throws IOException {
return addSignature(from, host, method, path, dateString,
digestHeader, keystoreManager);
}
- public String addSignature(Person from, String host, String method,
+ public String addSignature(SecurityObject from, String host, String method,
String path, String dateString, String digestHeader,
KeystoreManager keystoreManager) throws IOException {
List<String> requiredHeaders = StringUtils.isEmpty(digestHeader) ?
@@ -126,9 +127,9 @@ public class SignatureManager {
Signature signature = Signature.fromString(signatureString);
Optional<Context> context = getContext(UriComponentsBuilder.fromUriString(signature.getKeyId())
.fragment(null).build().toUri());
- if (context.isPresent() && context.get() instanceof Person) {
- Person person = (Person) context.get();
- Key key = KeystoreManager.publicKeyOf(person);
+ if (context.isPresent() && context.get() instanceof SecurityObject) {
+ SecurityObject securityObject = (SecurityObject) context.get();
+ Key key = KeystoreManager.publicKeyOf(securityObject);
Verifier verifier = new Verifier(key, signature);
try {
@@ -136,9 +137,9 @@ public class SignatureManager {
logger.info("signature of {} is valid: {}", signature.getKeyId(), result);
if (result) {
User user = new User();
- user.setUri(URI.create(person.getId()));
+ user.setUri(URI.create(securityObject.getId()));
if (key.equals(keystoreManager.getPublicKey())) {
- return userService.getUserByName(person.getName());
+ return userService.getUserByName(securityObject.getName());
}
return user;
} else {