Skip to content

Commit 9c63588

Browse files
committed
be sure to remove MAC from username before returning to iOS
1 parent f04a4d6 commit 9c63588

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/io/github/hapjava/server/impl/pairing/PairingUpdateController.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public HttpResponse handle(HttpRequest request) throws IOException {
4242
Collection<String> usernames = authInfo.listUsers();
4343
boolean first = true;
4444
Iterator<String> iterator = usernames.iterator();
45+
String mac = authInfo.getMac();
46+
4547
while (iterator.hasNext()) {
4648
String username = iterator.next();
4749
if (first) {
@@ -50,9 +52,14 @@ public HttpResponse handle(HttpRequest request) throws IOException {
5052
} else {
5153
e.add(MessageType.SEPARATOR);
5254
}
55+
byte[] publicKey = authInfo.getUserPublicKey(username);
56+
boolean isAdmin = authInfo.userIsAdmin(username);
57+
if (username.startsWith(mac)) {
58+
username = username.substring(mac.length());
59+
}
5360
e.add(MessageType.USERNAME, username);
54-
e.add(MessageType.PUBLIC_KEY, authInfo.getUserPublicKey(username));
55-
e.add(MessageType.PERMISSIONS, (short) (authInfo.userIsAdmin(username) ? 1 : 0));
61+
e.add(MessageType.PUBLIC_KEY, publicKey);
62+
e.add(MessageType.PERMISSIONS, (short) (isAdmin ? 1 : 0));
5663
}
5764
;
5865

0 commit comments

Comments
 (0)