Show signatures into admin lookup queries

This commit is contained in:
Max Dor
2019-03-04 02:12:55 +01:00
parent 1dce59a02e
commit 57c7e4a91d
3 changed files with 28 additions and 3 deletions

View File

@@ -57,11 +57,16 @@ public class LookupCommandProcessor implements CommandProcessor {
SingleLookupReply lookup = r.get(); SingleLookupReply lookup = r.get();
StrBuilder b = new StrBuilder(); StrBuilder b = new StrBuilder();
b.append("Result for 3PID lookup on ").append(medium).append(" ").appendln(address).appendNewLine(); b.append("Result for 3PID lookup of ").append(medium).append(" ").appendln(address).appendNewLine();
b.append("Matrix ID: ").appendln(lookup.getMxid().getId()); b.append("Matrix ID: ").appendln(lookup.getMxid().getId());
b.appendln("Validity:") b.appendln("Validity:")
.append("\tNot Before: ").appendln(lookup.getNotBefore()) .append(" Not Before: ").appendln(lookup.getNotBefore())
.append("\tNot After: ").appendln(lookup.getNotAfter()); .append(" Not After: ").appendln(lookup.getNotAfter());
b.appendln("Signatures:");
lookup.getSignatures().forEach((host, signs) -> {
b.append(" ").append(host).appendln(":");
signs.forEach((key, sign) -> b.append(" ").append(key).append(" -> ").appendln("OK"));
});
room.sendNotice(b.toString()); room.sendNotice(b.toString());
} }

View File

@@ -22,6 +22,9 @@ package io.kamax.mxisd.http.io.identity;
import io.kamax.mxisd.lookup.SingleLookupReply; import io.kamax.mxisd.lookup.SingleLookupReply;
import java.util.HashMap;
import java.util.Map;
public class SingeLookupReplyJson { public class SingeLookupReplyJson {
private String address; private String address;
@@ -30,6 +33,7 @@ public class SingeLookupReplyJson {
private long not_after; private long not_after;
private long not_before; private long not_before;
private long ts; private long ts;
private Map<String, Map<String, String>> signatures = new HashMap<>();
public SingeLookupReplyJson(SingleLookupReply reply) { public SingeLookupReplyJson(SingleLookupReply reply) {
this.address = reply.getRequest().getThreePid(); this.address = reply.getRequest().getThreePid();
@@ -64,4 +68,8 @@ public class SingeLookupReplyJson {
return ts; return ts;
} }
public Map<String, Map<String, String>> getSignatures() {
return signatures;
}
} }

View File

@@ -27,6 +27,8 @@ import io.kamax.matrix._MatrixID;
import io.kamax.mxisd.http.io.identity.SingeLookupReplyJson; import io.kamax.mxisd.http.io.identity.SingeLookupReplyJson;
import java.time.Instant; import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
public class SingleLookupReply { public class SingleLookupReply {
@@ -39,6 +41,7 @@ public class SingleLookupReply {
private Instant notBefore; private Instant notBefore;
private Instant notAfter; private Instant notAfter;
private Instant timestamp; private Instant timestamp;
private Map<String, Map<String, String>> signatures = new HashMap<>();
public static SingleLookupReply fromRecursive(SingleLookupRequest request, String body) { public static SingleLookupReply fromRecursive(SingleLookupRequest request, String body) {
SingleLookupReply reply = new SingleLookupReply(); SingleLookupReply reply = new SingleLookupReply();
@@ -52,6 +55,7 @@ public class SingleLookupReply {
reply.notAfter = Instant.ofEpochMilli(json.getNot_after()); reply.notAfter = Instant.ofEpochMilli(json.getNot_after());
reply.notBefore = Instant.ofEpochMilli(json.getNot_before()); reply.notBefore = Instant.ofEpochMilli(json.getNot_before());
reply.timestamp = Instant.ofEpochMilli(json.getTs()); reply.timestamp = Instant.ofEpochMilli(json.getTs());
reply.signatures = new HashMap<>(json.getSignatures());
} catch (JsonSyntaxException e) { } catch (JsonSyntaxException e) {
// stub - we only want to try, nothing more // stub - we only want to try, nothing more
} }
@@ -107,4 +111,12 @@ public class SingleLookupReply {
return timestamp; return timestamp;
} }
public Map<String, Map<String, String>> getSignatures() {
return signatures;
}
public Map<String, String> getSignature(String host) {
return signatures.computeIfAbsent(host, k -> new HashMap<>());
}
} }