Skip to content

Commit 8e562de

Browse files
add custom cert support for java controller
1 parent 36c76e6 commit 8e562de

6 files changed

+6
-16
lines changed

src/controller/java/AndroidDeviceControllerWrapper.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
#include <lib/support/TestGroupData.h>
4141
#include <lib/support/ThreadOperationalDataset.h>
4242
#include <platform/KeyValueStoreManager.h>
43-
#ifndef JAVA_MATTER_CONTROLLER_TEST
44-
#include <platform/android/CHIPP256KeypairBridge.h>
45-
#endif // JAVA_MATTER_CONTROLLER_TEST
43+
4644
using namespace chip;
4745
using namespace chip::Controller;
4846
using namespace chip::Credentials;
@@ -52,13 +50,11 @@ AndroidDeviceControllerWrapper::~AndroidDeviceControllerWrapper()
5250
{
5351
mController->Shutdown();
5452

55-
#ifndef JAVA_MATTER_CONTROLLER_TEST
5653
if (mKeypairBridge != nullptr)
5754
{
5855
chip::Platform::Delete(mKeypairBridge);
5956
mKeypairBridge = nullptr;
6057
}
61-
#endif // JAVA_MATTER_CONTROLLER_TEST
6258

6359
if (mDeviceAttestationDelegateBridge != nullptr)
6460
{
@@ -296,7 +292,6 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew(
296292

297293
// The lifetime of the ephemeralKey variable must be kept until SetupParams is saved.
298294
Crypto::P256Keypair ephemeralKey;
299-
#ifndef JAVA_MATTER_CONTROLLER_TEST
300295
if (rootCertificate != nullptr && nodeOperationalCertificate != nullptr && keypairDelegate != nullptr)
301296
{
302297
CHIPP256KeypairBridge * nativeKeypairBridge = wrapper->GetP256KeypairBridge();
@@ -333,7 +328,6 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew(
333328
setupParams.controllerNOC = chip::ByteSpan(wrapper->mNocCertificate.data(), wrapper->mNocCertificate.size());
334329
}
335330
else
336-
#endif // JAVA_MATTER_CONTROLLER_TEST
337331
{
338332
ChipLogProgress(Controller,
339333
"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);
@@ -231,12 +228,12 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel
231228

232229
JavaVM * mJavaVM = nullptr;
233230
chip::JniGlobalReference mJavaObjectRef;
231+
CHIPP256KeypairBridge * mKeypairBridge = nullptr;
234232
#ifdef JAVA_MATTER_CONTROLLER_TEST
235233
ExampleOperationalCredentialsIssuerPtr mOpCredsIssuer;
236234
PersistentStorage mExampleStorage;
237235
#else
238236
AndroidOperationalCredentialsIssuerPtr mOpCredsIssuer;
239-
CHIPP256KeypairBridge * mKeypairBridge = nullptr;
240237
#endif // JAVA_MATTER_CONTROLLER_TEST
241238

242239
// 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
@@ -120,6 +120,8 @@ shared_library("jni") {
120120
check_includes = false
121121

122122
sources = [
123+
"CHIPP256KeypairBridge.cpp",
124+
"CHIPP256KeypairBridge.h",
123125
"AndroidCheckInDelegate.cpp",
124126
"AndroidCheckInDelegate.h",
125127
"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
@@ -51,8 +51,6 @@ static_library("android") {
5151
"BleConnectCallback-JNI.cpp",
5252
"BlePlatformConfig.h",
5353
"CHIPDevicePlatformEvent.h",
54-
"CHIPP256KeypairBridge.cpp",
55-
"CHIPP256KeypairBridge.h",
5654
"CommissionableDataProviderImpl.cpp",
5755
"CommissionableDataProviderImpl.h",
5856
"ConfigurationManagerImpl.cpp",

0 commit comments

Comments
 (0)