blob: 258a53528eb4e3ad8d7ddaf27902264ccc577b08 [file] [log] [blame]
panliming-tuya4a9c0a62023-01-12 11:46:30 +08001/**
2 *
3 * Copyright (c) 2022 Project CHIP Authors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#include <jni.h>
19#include <lib/core/NodeId.h>
20#include <platform/CHIPDeviceBuildConfig.h>
21
22#include <credentials/attestation_verifier/DeviceAttestationDelegate.h>
23
24class DeviceAttestationDelegateBridge : public chip::Credentials::DeviceAttestationDelegate
25{
26public:
27 DeviceAttestationDelegateBridge(jobject deviceAttestationDelegate, chip::Optional<uint16_t> expiryTimeoutSecs,
28 bool shouldWaitAfterDeviceAttestation) :
29 mResult(chip::Credentials::AttestationVerificationResult::kSuccess),
30 mDeviceAttestationDelegate(deviceAttestationDelegate), mExpiryTimeoutSecs(expiryTimeoutSecs),
31 mShouldWaitAfterDeviceAttestation(shouldWaitAfterDeviceAttestation)
32 {}
33
34 ~DeviceAttestationDelegateBridge();
35
36 chip::Optional<uint16_t> FailSafeExpiryTimeoutSecs() const override { return mExpiryTimeoutSecs; }
37
38 void OnDeviceAttestationCompleted(chip::Controller::DeviceCommissioner * deviceCommissioner, chip::DeviceProxy * device,
39 const chip::Credentials::DeviceAttestationVerifier::AttestationDeviceInfo & info,
40 chip::Credentials::AttestationVerificationResult attestationResult) override;
41
42 bool ShouldWaitAfterDeviceAttestation() override { return mShouldWaitAfterDeviceAttestation; }
43
44 chip::Credentials::AttestationVerificationResult attestationVerificationResult() const { return mResult; }
45
46private:
47 chip::Credentials::AttestationVerificationResult mResult;
48 jobject mDeviceAttestationDelegate = nullptr;
49 chip::Optional<uint16_t> mExpiryTimeoutSecs;
50 const bool mShouldWaitAfterDeviceAttestation;
51};