[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>pull/14048/head
parent
fbf302e553
commit
7c2d5dcca5
|
@ -22,7 +22,7 @@
|
|||
<dependency>
|
||||
<groupId>io.github.hap-java</groupId>
|
||||
<artifactId>hap</artifactId>
|
||||
<version>2.0.4</version>
|
||||
<version>2.0.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.security.InvalidAlgorithmParameterException;
|
|||
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;
|
||||
|
@ -62,7 +63,7 @@ public class HomekitAuthInfoImpl implements HomekitAuthInfo {
|
|||
}
|
||||
|
||||
@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);
|
||||
|
@ -133,6 +134,18 @@ public class HomekitAuthInfoImpl implements HomekitAuthInfo {
|
|||
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() {
|
||||
logger.trace("clear all users");
|
||||
if (!this.blockUserDeletion) {
|
||||
|
|
Loading…
Reference in New Issue