Skip to content

Commit

Permalink
[homekit] implement List-Pairings method
Browse files Browse the repository at this point in the history
refs openhab#13949

Signed-off-by: Cody Cutrer <cody@cutrer.us>
  • Loading branch information
ccutrer committed Dec 22, 2022
1 parent df8e0bb commit 119caf7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bundles/org.openhab.io.homekit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>io.github.hap-java</groupId>
<artifactId>hap</artifactId>
<version>2.0.4</version>
<version>2.0.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Base64;
import java.util.Collection;
import java.util.HashSet;
import java.util.stream.Collectors;

import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.storage.Storage;
Expand Down Expand Up @@ -58,7 +59,7 @@ public HomekitAuthInfoImpl(Storage<Object> storage, String pin, String setupId,
}

@Override
public void createUser(String username, byte[] publicKey) {
public void createUser(String username, byte[] publicKey, boolean isAdmin) {
logger.trace("create user {}", username);
final String userKey = createUserKey(username);
final String encodedPublicKey = Base64.getEncoder().encodeToString(publicKey);
Expand Down Expand Up @@ -129,6 +130,17 @@ public boolean hasUser() {
return keys.stream().anyMatch(this::isUserKey);
}

@Override
public Collection<String> listUsers() {
Collection<String> keys = storage.getKeys();
return keys.stream().filter(this::isUserKey).collect(Collectors.toList());
}

@Override
public boolean userIsAdmin(String username) {
return true;
}

public void clear() {
logger.trace("clear all users");
if (!this.blockUserDeletion) {
Expand Down

0 comments on commit 119caf7

Please sign in to comment.