|
3 | 3 | import java.math.BigInteger; |
4 | 4 |
|
5 | 5 | /** |
6 | | - * Authentication info that must be provided when constructing a new {@link HomekitServer}. You will need to implement |
7 | | - * this interface yourself to provide the necessary callbacks to a persistent storage mechanism. All values provided |
8 | | - * must be constant across invocations or the accessories will require re-pairing within iOS. |
| 6 | + * Authentication info that must be provided when constructing a new {@link HomekitServer}. You will |
| 7 | + * need to implement this interface yourself to provide the necessary callbacks to a persistent |
| 8 | + * storage mechanism. All values provided must be constant across invocations or the accessories |
| 9 | + * will require re-pairing within iOS. |
9 | 10 | * |
10 | 11 | * @author Andy Lintner |
11 | 12 | */ |
12 | 13 | public interface HomekitAuthInfo { |
13 | 14 |
|
14 | | - /** |
15 | | - * A pin code used for pairing the device. This pin will be required within iOS in order to complete pairing. The numbers |
16 | | - * cannot be sequential and should not have a repeating pattern. |
17 | | - * |
18 | | - * @return the pin code, in the form ###-##-### |
19 | | - */ |
20 | | - String getPin(); |
21 | | - |
22 | | - /** |
23 | | - * A unique MAC address to be advertised with the Homekit information. This does not have to be the MAC address of the |
24 | | - * network interface. You can generate this using {@link HomekitServer#generateMac()}. |
25 | | - * |
26 | | - * @return the unique MAC address. |
27 | | - */ |
28 | | - String getMac(); |
| 15 | + /** |
| 16 | + * A pin code used for pairing the device. This pin will be required within iOS in order to |
| 17 | + * complete pairing. The numbers cannot be sequential and should not have a repeating pattern. |
| 18 | + * |
| 19 | + * @return the pin code, in the form ###-##-### |
| 20 | + */ |
| 21 | + String getPin(); |
29 | 22 |
|
30 | | - /** |
31 | | - * The Salt that will be used when hashing the pin code to send to the client. You should generate this using |
32 | | - * {@link HomekitServer#generateSalt()}. |
33 | | - * |
34 | | - * @return the Salt. |
35 | | - */ |
36 | | - BigInteger getSalt(); |
| 23 | + /** |
| 24 | + * A unique MAC address to be advertised with the Homekit information. This does not have to be |
| 25 | + * the MAC address of the network interface. You can generate this using {@link |
| 26 | + * HomekitServer#generateMac()}. |
| 27 | + * |
| 28 | + * @return the unique MAC address. |
| 29 | + */ |
| 30 | + String getMac(); |
37 | 31 |
|
38 | | - /** |
39 | | - * The private key used by the server during pairing and message encryption. You should generate this using |
40 | | - * {@link HomekitServer#generateKey()} |
41 | | - * |
42 | | - * @return the private key. |
43 | | - */ |
44 | | - byte[] getPrivateKey(); |
45 | | - |
46 | | - /** |
47 | | - * Called during the pairing process, you should store the user and public key in a manner that the public key can later |
48 | | - * be retrieved using {@link #getUserPublicKey(String)}. This must be stored in a persistent store as pairing will |
49 | | - * need to be reset if the information is lost. |
50 | | - * |
51 | | - * @param username the iOS device's username. The value will not be meaningful to anything but iOS. |
52 | | - * @param publicKey the iOS device's public key. |
53 | | - */ |
54 | | - void createUser(String username, byte[] publicKey); |
55 | | - |
56 | | - /** |
57 | | - * Called when an iOS device needs to remove an existing pairing. Subsequent calls to {@link #getUserPublicKey(String)} for this |
58 | | - * username return null. |
59 | | - * |
60 | | - * @param username the username to delete from the persistent store. |
61 | | - */ |
62 | | - void removeUser(String username); |
| 32 | + /** |
| 33 | + * The Salt that will be used when hashing the pin code to send to the client. You should generate |
| 34 | + * this using {@link HomekitServer#generateSalt()}. |
| 35 | + * |
| 36 | + * @return the Salt. |
| 37 | + */ |
| 38 | + BigInteger getSalt(); |
63 | 39 |
|
64 | | - /** |
65 | | - * Called when an already paired iOS device is re-connecting. The public key returned by this method will be compared |
66 | | - * with the signature of the pair verification request to validate the device. |
67 | | - * |
68 | | - * @param username the username of the iOS device to retrieve the public key for. |
69 | | - * @return the previously stored public key for this user. |
70 | | - */ |
71 | | - byte[] getUserPublicKey(String username); |
72 | | - |
73 | | - /** |
74 | | - * Called to check if a user has been created. The homekit accessory advertises whether the accessory has already been paired. |
75 | | - * At this time, it's unclear whether multiple users can be created, however it is known that advertising as unpaired |
76 | | - * will break in iOS 9. The default value has been provided to maintain API compatibility for implementations targeting iOS 8. |
77 | | - * |
78 | | - * @return whether a user has been created and stored |
79 | | - */ |
80 | | - default boolean hasUser() { return false; }; |
| 40 | + /** |
| 41 | + * The private key used by the server during pairing and message encryption. You should generate |
| 42 | + * this using {@link HomekitServer#generateKey()} |
| 43 | + * |
| 44 | + * @return the private key. |
| 45 | + */ |
| 46 | + byte[] getPrivateKey(); |
| 47 | + |
| 48 | + /** |
| 49 | + * Called during the pairing process, you should store the user and public key in a manner that |
| 50 | + * the public key can later be retrieved using {@link #getUserPublicKey(String)}. This must be |
| 51 | + * stored in a persistent store as pairing will need to be reset if the information is lost. |
| 52 | + * |
| 53 | + * @param username the iOS device's username. The value will not be meaningful to anything but |
| 54 | + * iOS. |
| 55 | + * @param publicKey the iOS device's public key. |
| 56 | + */ |
| 57 | + void createUser(String username, byte[] publicKey); |
| 58 | + |
| 59 | + /** |
| 60 | + * Called when an iOS device needs to remove an existing pairing. Subsequent calls to {@link |
| 61 | + * #getUserPublicKey(String)} for this username return null. |
| 62 | + * |
| 63 | + * @param username the username to delete from the persistent store. |
| 64 | + */ |
| 65 | + void removeUser(String username); |
| 66 | + |
| 67 | + /** |
| 68 | + * Called when an already paired iOS device is re-connecting. The public key returned by this |
| 69 | + * method will be compared with the signature of the pair verification request to validate the |
| 70 | + * device. |
| 71 | + * |
| 72 | + * @param username the username of the iOS device to retrieve the public key for. |
| 73 | + * @return the previously stored public key for this user. |
| 74 | + */ |
| 75 | + byte[] getUserPublicKey(String username); |
| 76 | + |
| 77 | + /** |
| 78 | + * Called to check if a user has been created. The homekit accessory advertises whether the |
| 79 | + * accessory has already been paired. At this time, it's unclear whether multiple users can be |
| 80 | + * created, however it is known that advertising as unpaired will break in iOS 9. The default |
| 81 | + * value has been provided to maintain API compatibility for implementations targeting iOS 8. |
| 82 | + * |
| 83 | + * @return whether a user has been created and stored |
| 84 | + */ |
| 85 | + default boolean hasUser() { |
| 86 | + return false; |
| 87 | + }; |
81 | 88 | } |
0 commit comments