Skip to content

Commit ac6863f

Browse files
add custom cert support for java controller
1 parent fef41bd commit ac6863f

6 files changed

+6
-16
lines changed

src/controller/java/AndroidDeviceControllerWrapper.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
4242
#include <lib/support/TestGroupData.h>
4343
#include <lib/support/ThreadOperationalDataset.h>
4444
#include <platform/KeyValueStoreManager.h>
45-
#ifndef JAVA_MATTER_CONTROLLER_TEST
46-
#include <platform/android/CHIPP256KeypairBridge.h>
47-
#endif // JAVA_MATTER_CONTROLLER_TEST
45+
4846
using namespace chip;
4947
using namespace chip::Controller;
5048
using namespace chip::Credentials;
@@ -54,13 +52,11 @@ AndroidDeviceControllerWrapper::~AndroidDeviceControllerWrapper()
5452
{
5553
mController->Shutdown();
5654

57-
#ifndef JAVA_MATTER_CONTROLLER_TEST
5855
if (mKeypairBridge != nullptr)
5956
{
6057
chip::Platform::Delete(mKeypairBridge);
6158
mKeypairBridge = nullptr;
6259
}
63-
#endif // JAVA_MATTER_CONTROLLER_TEST
6460

6561
if (mDeviceAttestationDelegateBridge != nullptr)
6662
{
@@ -298,7 +294,6 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew(
298294

299295
// The lifetime of the ephemeralKey variable must be kept until SetupParams is saved.
300296
Crypto::P256Keypair ephemeralKey;
301-
#ifndef JAVA_MATTER_CONTROLLER_TEST
302297
if (rootCertificate != nullptr && nodeOperationalCertificate != nullptr && keypairDelegate != nullptr)
303298
{
304299
CHIPP256KeypairBridge * nativeKeypairBridge = wrapper->GetP256KeypairBridge();
@@ -335,7 +330,6 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew(
335330
setupParams.controllerNOC = chip::ByteSpan(wrapper->mNocCertificate.data(), wrapper->mNocCertificate.size());
336331
}
337332
else
338-
#endif // JAVA_MATTER_CONTROLLER_TEST
339333
{
340334
ChipLogProgress(Controller,
341335
"No existing credentials provided: generating ephemeral local NOC chain with OperationalCredentialsIssuer");

src/controller/java/AndroidDeviceControllerWrapper.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@
3434
#include <crypto/RawKeySessionKeystore.h>
3535
#include <lib/support/TimeUtils.h>
3636
#include <platform/internal/DeviceNetworkInfo.h>
37-
37+
#include <controller/java/CHIPP256KeypairBridge.h>
3838
#ifdef JAVA_MATTER_CONTROLLER_TEST
3939
#include <controller/ExampleOperationalCredentialsIssuer.h>
4040
#include <controller/ExamplePersistentStorage.h>
4141
#else
4242
#include <platform/android/AndroidChipPlatform-JNI.h>
43-
#include <platform/android/CHIPP256KeypairBridge.h>
4443
#endif // JAVA_MATTER_CONTROLLER_TEST
4544

4645
#include "AndroidCheckInDelegate.h"
@@ -71,7 +70,6 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel
7170
jobject JavaObjectRef() { return mJavaObjectRef.ObjectRef(); }
7271
jlong ToJNIHandle();
7372

74-
#ifndef JAVA_MATTER_CONTROLLER_TEST
7573
/**
7674
* Returns a CHIPP256KeypairBridge which can be used to delegate signing operations
7775
* to a KeypairDelegate in the Java layer. Note that this will always return a pointer
@@ -85,7 +83,6 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel
8583
}
8684
return mKeypairBridge;
8785
}
88-
#endif // JAVA_MATTER_CONTROLLER_TEST
8986

9087
void CallJavaIntMethod(const char * methodName, jint argument);
9188
void CallJavaLongMethod(const char * methodName, jlong argument);
@@ -235,12 +232,12 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel
235232

236233
JavaVM * mJavaVM = nullptr;
237234
chip::JniGlobalReference mJavaObjectRef;
235+
CHIPP256KeypairBridge * mKeypairBridge = nullptr;
238236
#ifdef JAVA_MATTER_CONTROLLER_TEST
239237
ExampleOperationalCredentialsIssuerPtr mOpCredsIssuer;
240238
PersistentStorage mExampleStorage;
241239
#else
242240
AndroidOperationalCredentialsIssuerPtr mOpCredsIssuer;
243-
CHIPP256KeypairBridge * mKeypairBridge = nullptr;
244241
#endif // JAVA_MATTER_CONTROLLER_TEST
245242

246243
// These fields allow us to release the string/byte array memory later.

src/controller/java/BUILD.gn

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ shared_library("jni") {
121121
check_includes = false
122122

123123
sources = [
124+
"CHIPP256KeypairBridge.cpp",
125+
"CHIPP256KeypairBridge.h",
124126
"AndroidCheckInDelegate.cpp",
125127
"AndroidCheckInDelegate.h",
126128
"AndroidClusterExceptions.cpp",

src/platform/android/CHIPP256KeypairBridge.cpp src/controller/java/CHIPP256KeypairBridge.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include "platform/android/CHIPP256KeypairBridge.h"
18+
#include "CHIPP256KeypairBridge.h"
1919
#include "lib/core/CHIPError.h"
2020
#include "lib/support/CHIPJNIError.h"
2121
#include "lib/support/JniReferences.h"
@@ -26,7 +26,6 @@
2626
#include <cstdint>
2727
#include <cstdlib>
2828
#include <jni.h>
29-
#include <platform/PlatformManager.h>
3029
#include <string.h>
3130
#include <type_traits>
3231

src/platform/android/BUILD.gn

-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ static_library("android") {
6464
"BleConnectCallback-JNI.cpp",
6565
"BlePlatformConfig.h",
6666
"CHIPDevicePlatformEvent.h",
67-
"CHIPP256KeypairBridge.cpp",
68-
"CHIPP256KeypairBridge.h",
6967
"CommissionableDataProviderImpl.cpp",
7068
"CommissionableDataProviderImpl.h",
7169
"ConfigurationManagerImpl.cpp",

0 commit comments

Comments
 (0)