forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generic OSGi console command for HomeKit
Removed eclipse specific OSGi console commands and replaced with ESH console command extension. Added copyright headers. Updated documentation. Decreased log levels from info to debug Signed-off-by: Andy Lintner <[email protected]> (github: beowulfe)
- Loading branch information
1 parent
8331cf9
commit 717e522
Showing
29 changed files
with
371 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> | ||
<title>About</title> | ||
</head> | ||
<body lang="EN-US"> | ||
<h2>About This Content</h2> | ||
<h3>Third Party Content</h3> | ||
<ul> | ||
<li><a href="https://github.com/beowulfe/HAP-Java">HAP-Java</a>: Homekit protocol implementation, under MIT license</li> | ||
<li><a href="http://connect2id.com/products/nimbus-srp">Nimbusds SRP6A</a>: Secure Remote Password library, dependency of HAP-Java, under Apache 2.0 license</li> | ||
<li><a href="http://netty.io">Netty</a>: Socket handling, dependency of HAP-Java, under Apache 2.0 license</li> | ||
<li><a href="https://jsonp.java.net">JSONP</a>: API and Glassfish implementation for JSR-353, dependency of HAP-Java, under GPLv2 or CDDL 1.1 license</li> | ||
<li><a href="https://github.com/str4d/ed25519-java">ed25519-java</a>: Java implementation of the Edwards-curve Digital Signature Algorithm, dependency of HAP-Java, under CC0 1.0 license</li> | ||
<li><a href="https://www.bouncycastle.org">Bouncycastle</a>: General purpose cryptography library, dependency of HAP-Java, under MIT license</li> | ||
<li><a href="https://code.google.com/archive/p/curve25519-java/">curve25519-java</a>: Java implementation of the Diffie-Hellman key agreement scheme, dependency of HAP_Java, under Apache 2.0 license</li> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
addons/io/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/Homekit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
/** | ||
* Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.openhab.io.homekit; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* HomeKit integration API | ||
* | ||
* @author Andy Lintner | ||
*/ | ||
public interface Homekit { | ||
|
||
/** | ||
* Refreshes the saved authentication info from the underlying storage service. If you | ||
* make changes to the saved authentication info, call this. | ||
* | ||
* @throws IOException | ||
*/ | ||
public void refreshAuthInfo() throws IOException; | ||
|
||
/** | ||
* HomeKit requests normally require authentication via the pairing mechanism. Use this | ||
* method to bypass that check and enable unauthenticated requests. This can be useful | ||
* when debugging. | ||
* | ||
* @param allow boolean indicating whether or not to allow unauthenticated requests | ||
*/ | ||
void allowUnauthenticatedRequests(boolean allow); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...hab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitAccessoryUpdater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitAuthInfoImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...b.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitCharacteristicType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...hab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitCommandExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/** | ||
* Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.openhab.io.homekit.internal; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.eclipse.smarthome.core.storage.StorageService; | ||
import org.eclipse.smarthome.io.console.Console; | ||
import org.eclipse.smarthome.io.console.extensions.AbstractConsoleCommandExtension; | ||
import org.openhab.io.homekit.Homekit; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Console commands for interacting with the HomeKit integration | ||
* | ||
* @author Andy Lintner | ||
*/ | ||
public class HomekitCommandExtension extends AbstractConsoleCommandExtension { | ||
|
||
private static final String SUBCMD_CLEAR_PAIRINGS = "clearPairings"; | ||
private static final String SUBCMD_ALLOW_UNAUTHENTICATED = "allowUnauthenticated"; | ||
|
||
private final Logger logger = LoggerFactory.getLogger(HomekitCommandExtension.class); | ||
private StorageService storageService; | ||
private Homekit homekit; | ||
|
||
public HomekitCommandExtension() { | ||
super("homekit", "Interact with the HomeKit integration."); | ||
} | ||
|
||
@Override | ||
public void execute(String[] args, Console console) { | ||
if (args.length > 0) { | ||
String subCommand = args[0]; | ||
switch (subCommand) { | ||
case SUBCMD_CLEAR_PAIRINGS: | ||
clearHomekitPairings(console); | ||
break; | ||
|
||
case SUBCMD_ALLOW_UNAUTHENTICATED: | ||
if (args.length > 1) { | ||
boolean allow = Boolean.valueOf(args[1]); | ||
allowUnauthenticatedHomekitRequests(allow, console); | ||
} else { | ||
console.println("true/false is required as an argument"); | ||
} | ||
break; | ||
|
||
default: | ||
console.println("Unknown command '" + subCommand + "'"); | ||
printUsage(console); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public List<String> getUsages() { | ||
return Arrays.asList( | ||
new String[] { buildCommandUsage(SUBCMD_CLEAR_PAIRINGS, "removes all pairings with Homekit clients"), | ||
buildCommandUsage(SUBCMD_ALLOW_UNAUTHENTICATED + " <boolean>", | ||
"enables or disables unauthenticated access to facilitate debugging") }); | ||
} | ||
|
||
public void setStorageService(StorageService storageService) { | ||
this.storageService = storageService; | ||
} | ||
|
||
public void setHomekit(Homekit homekit) { | ||
this.homekit = homekit; | ||
} | ||
|
||
private void clearHomekitPairings(Console console) { | ||
try { | ||
new HomekitAuthInfoImpl(storageService, null).clear(); | ||
homekit.refreshAuthInfo(); | ||
console.println("Cleared homekit pairings"); | ||
} catch (Exception e) { | ||
logger.error("Could not clear homekit pairings", e); | ||
} | ||
} | ||
|
||
private void allowUnauthenticatedHomekitRequests(boolean allow, Console console) { | ||
homekit.allowUnauthenticatedRequests(allow); | ||
console.println((allow ? "Enabled " : "Disabled ") + "unauthenticated homekit access"); | ||
} | ||
|
||
} |
Oops, something went wrong.