aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-12-28 03:08:20 +0300
committerGravatar Vitaly Takmazov2022-12-28 03:08:20 +0300
commitc59988a0862e1acc2f5805b327db0bd00569d8e1 (patch)
tree11ae8123bc05baf1a03ddebb002ec907c059bb31 /src/main/java/com/juick
parent8cc6c06cb1202bca5f2475be095916b80fcd923c (diff)
webfinger: respond 404 on invalid resource request
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/www/api/webfinger/Resource.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/main/java/com/juick/www/api/webfinger/Resource.java b/src/main/java/com/juick/www/api/webfinger/Resource.java
index 570ceed3..c4e0d5ca 100644
--- a/src/main/java/com/juick/www/api/webfinger/Resource.java
+++ b/src/main/java/com/juick/www/api/webfinger/Resource.java
@@ -46,15 +46,19 @@ public class Resource {
@GetMapping(value = "/.well-known/webfinger", produces = "application/jrd+json;charset=utf-8")
public Account getWebResource(@RequestParam String resource) {
if (resource.startsWith("acct:")) {
- Jid account = Jid.of(resource.substring(5));
- if (account.getDomain().equals(domain)) {
- User user = userService.getUserByName(account.getLocal());
- if (!user.isAnonymous()) {
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUri);
- builder.path(String.format("/u/%s", user.getName()));
- Link blog = new Link("self", ACTIVITY_MEDIA_TYPE, builder.toUriString());
- return new Account(resource, List.of(blog));
+ try {
+ Jid account = Jid.of(resource.substring(5));
+ if (account.getDomain().equals(domain)) {
+ User user = userService.getUserByName(account.getLocal());
+ if (!user.isAnonymous()) {
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUri);
+ builder.path(String.format("/u/%s", user.getName()));
+ Link blog = new Link("self", ACTIVITY_MEDIA_TYPE, builder.toUriString());
+ return new Account(resource, List.of(blog));
+ }
}
+ } catch (NullPointerException | IllegalArgumentException e) {
+ throw new HttpNotFoundException();
}
}
throw new HttpNotFoundException();