[homekit] implement List-Pairings method (#13982)

* [homekit] implement List-Pairings method
* [homekit] fix listUsers() method
* [homekit] bump HAP-java to 2.0.5

refs #13949

Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
Cody Cutrer 2022-12-22 16:16:55 -07:00 committed by GitHub
parent fbf302e553
commit 7c2d5dcca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -22,7 +22,7 @@
<dependency> <dependency>
<groupId>io.github.hap-java</groupId> <groupId>io.github.hap-java</groupId>
<artifactId>hap</artifactId> <artifactId>hap</artifactId>
<version>2.0.4</version> <version>2.0.5</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -17,6 +17,7 @@ import java.security.InvalidAlgorithmParameterException;
import java.util.Base64; import java.util.Base64;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.storage.Storage; import org.openhab.core.storage.Storage;
@ -62,7 +63,7 @@ public class HomekitAuthInfoImpl implements HomekitAuthInfo {
} }
@Override @Override
public void createUser(String username, byte[] publicKey) { public void createUser(String username, byte[] publicKey, boolean isAdmin) {
logger.trace("create user {}", username); logger.trace("create user {}", username);
final String userKey = createUserKey(username); final String userKey = createUserKey(username);
final String encodedPublicKey = Base64.getEncoder().encodeToString(publicKey); final String encodedPublicKey = Base64.getEncoder().encodeToString(publicKey);
@ -133,6 +134,18 @@ public class HomekitAuthInfoImpl implements HomekitAuthInfo {
return keys.stream().anyMatch(this::isUserKey); return keys.stream().anyMatch(this::isUserKey);
} }
@Override
public Collection<String> listUsers() {
Collection<String> keys = storage.getKeys();
// don't forget to strip user_ prefix
return keys.stream().filter(this::isUserKey).map(u -> u.substring(5)).collect(Collectors.toList());
}
@Override
public boolean userIsAdmin(String username) {
return true;
}
public void clear() { public void clear() {
logger.trace("clear all users"); logger.trace("clear all users");
if (!this.blockUserDeletion) { if (!this.blockUserDeletion) {