diff --git a/LICENSE b/LICENSE
new file mode 100755
index 0000000000000000000000000000000000000000..4947287f7b5ccb5d1e8b7b2d3aa5d89f322c160d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/OAT.xml b/OAT.xml
new file mode 100755
index 0000000000000000000000000000000000000000..131151bd4c3191474082dba3c418dde7ebf340ad
--- /dev/null
+++ b/OAT.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/coauth.gni b/coauth.gni
new file mode 100755
index 0000000000000000000000000000000000000000..c3fbfa78cb48028873fba931d441ce8d0b28f89a
--- /dev/null
+++ b/coauth.gni
@@ -0,0 +1,29 @@
+# Copyright (c) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build/ohos.gni")
+
+coauth_native_part_name = "coauthmgr"
+
+coauth_root_path = "//base/useriam/coauth/"
+
+coauth_service_path = "${coauth_root_path}/services"
+
+coauth_frameworks_path = "${coauth_root_path}/frameworks"
+
+coauth_interfaces_path = "${coauth_root_path}/interfaces"
+
+coauth_innerkits_path = "${coauth_interfaces_path}/innerkits"
+
+coauth_utils_path = "${coauth_root_path}/utils"
+
diff --git a/frameworks/kitsimpl/include/coauth_callback_proxy.h b/frameworks/kitsimpl/include/coauth_callback_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..128b7e9ac3050f9fe02d2cb4a6d0bb6ac998e5fc
--- /dev/null
+++ b/frameworks/kitsimpl/include/coauth_callback_proxy.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COAUTH_CALLBACK_PROXY_H
+#define COAUTH_CALLBACK_PROXY_H
+
+#include
+#include
+#include "icoauth_callback.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+class CoAuthCallbackProxy : public IRemoteProxy {
+public:
+ explicit CoAuthCallbackProxy(const sptr& impl)
+ : IRemoteProxy(impl) {}
+ ~CoAuthCallbackProxy() override = default;
+
+ virtual void OnFinish(uint32_t resultCode, std::vector &scheduleToken) override;
+ virtual void OnAcquireInfo(uint32_t acquire) override;
+private:
+ bool SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply);
+
+private:
+ static inline BrokerDelegator delegator_;
+};
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
+#endif // COAUTH_CALLBACK_PROXY_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/coauth_callback_stub.h b/frameworks/kitsimpl/include/coauth_callback_stub.h
new file mode 100644
index 0000000000000000000000000000000000000000..aae0218a992a08e91a77d9f0b7cbc80fc7027832
--- /dev/null
+++ b/frameworks/kitsimpl/include/coauth_callback_stub.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COAUTH_CALLBACK_STUB_H
+#define COAUTH_CALLBACK_STUB_H
+
+#include
+#include "icoauth_callback.h"
+#include "coauth_callback.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+class CoAuthCallbackStub : public IRemoteStub {
+public:
+ explicit CoAuthCallbackStub(const std::shared_ptr& impl);
+ ~CoAuthCallbackStub() override = default;
+
+ virtual void OnFinish(uint32_t resultCode, std::vector &scheduleToken) override;
+ virtual void OnAcquireInfo(uint32_t acquire) override;
+
+ int32_t OnRemoteRequest(
+ uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
+private:
+ int32_t OnFinishStub(MessageParcel &data, MessageParcel &reply);
+ int32_t OnAcquireInfoStub(MessageParcel &data, MessageParcel &reply);
+
+ std::shared_ptr callback_;
+};
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
+#endif // COAUTH_CALLBACK_STUB_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/coauth_proxy.h b/frameworks/kitsimpl/include/coauth_proxy.h
new file mode 100755
index 0000000000000000000000000000000000000000..ad0bc59c64cb3245bfb052d40a55dd863e43f291
--- /dev/null
+++ b/frameworks/kitsimpl/include/coauth_proxy.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COAUTH_PROXY_H
+#define COAUTH_PROXY_H
+
+#include
+#include
+#include "i_coauth.h"
+#include "auth_attributes.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+class CoAuthProxy : public IRemoteProxy {
+public:
+ explicit CoAuthProxy(const sptr& impl)
+ : IRemoteProxy(impl) {}
+ ~CoAuthProxy() override = default;
+
+ virtual uint64_t Register(std::shared_ptr executorInfo,
+ const sptr &callback) override;
+ virtual void QueryStatus(AuthResPool::AuthExecutor &executorInfo,
+ const sptr &callback) override;
+ virtual void coAuth(uint64_t scheduleId, AuthInfo &authInfo, const sptr &callback) override;
+ virtual int32_t Cancel(uint64_t scheduleId) override;
+ virtual int32_t GetExecutorProp(AuthResPool::AuthAttributes &conditions,
+ std::shared_ptr values) override;
+ virtual void SetExecutorProp(AuthResPool::AuthAttributes &conditions,
+ const sptr &callback) override;
+
+private:
+ bool SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, bool isSync = true);
+ uint32_t WriteAuthExecutor(AuthResPool::AuthExecutor &executorInfo, MessageParcel &data);
+
+private:
+ static inline BrokerDelegator delegator_;
+};
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
+#endif // COAUTH_PROXY_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/executor_callback_proxy.h b/frameworks/kitsimpl/include/executor_callback_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..c9e64ef2fa77963fbc05fbcea8ea008057daa477
--- /dev/null
+++ b/frameworks/kitsimpl/include/executor_callback_proxy.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXECUTOR_CALLBACK_PROXY_H
+#define EXECUTOR_CALLBACK_PROXY_H
+
+#include
+#include "nocopyable.h"
+#include "iexecutor_callback.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+class ExecutorCallbackProxy : public IRemoteProxy {
+public:
+ explicit ExecutorCallbackProxy(const sptr& impl)
+ : IRemoteProxy(impl) {}
+
+ ~ExecutorCallbackProxy() override = default;
+ virtual void OnMessengerReady(const sptr &messenger) override;
+ virtual int32_t OnBeginExecute(uint64_t scheduleId, std::vector &publicKey,
+ std::shared_ptr commandAttrs) override;
+ virtual int32_t OnEndExecute(uint64_t scheduleId, std::shared_ptr consumerAttr) override;
+ virtual int32_t OnSetProperty(std::shared_ptr properties) override;
+ virtual int32_t OnGetProperty(std::shared_ptr conditions,
+ std::shared_ptr values) override;
+private:
+ bool SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply);
+ static inline BrokerDelegator delegator_;
+};
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
+
+#endif // EXECUTOR_CALLBACK_PROXY_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/executor_callback_stub.h b/frameworks/kitsimpl/include/executor_callback_stub.h
new file mode 100644
index 0000000000000000000000000000000000000000..59bbf4e04f4027cfe357ad4c2f5d4f92ccb14d1b
--- /dev/null
+++ b/frameworks/kitsimpl/include/executor_callback_stub.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXECUTOR_CALLBACK_STUB_H
+#define EXECUTOR_CALLBACK_STUB_H
+
+#include "iexecutor_callback.h"
+#include "executor_callback.h"
+#include "iremote_stub.h"
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+class ExecutorCallbackStub : public IRemoteStub {
+public:
+ ExecutorCallbackStub(const std::shared_ptr& impl);
+ ~ExecutorCallbackStub() override = default;
+ virtual void OnMessengerReady(const sptr &messenger) override;
+ virtual int32_t OnBeginExecute(uint64_t scheduleId, std::vector &publicKey,
+ std::shared_ptr commandAttrs) override;
+ virtual int32_t OnEndExecute(uint64_t scheduleId, std::shared_ptr consumerAttr) override;
+ virtual int32_t OnSetProperty(std::shared_ptr properties) override;
+ virtual int32_t OnGetProperty(std::shared_ptr conditions,
+ std::shared_ptr values) override;
+ int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
+private:
+ int32_t OnMessengerReadyStub(MessageParcel& data, MessageParcel& reply);
+ int32_t OnBeginExecuteStub(MessageParcel& data, MessageParcel& reply);
+ int32_t OnEndExecuteStub(MessageParcel& data, MessageParcel& reply);
+ int32_t OnGetPropertyStub(MessageParcel& data, MessageParcel& reply);
+ int32_t OnSetPropertyStub(MessageParcel& data, MessageParcel& reply);
+ std::shared_ptr callback_;
+};
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
+#endif // EXECUTOR_CALLBACK_STUB_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/executor_messenger_proxy.h b/frameworks/kitsimpl/include/executor_messenger_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..c5d3d76527359b80249bcb138e7f186aeaf9b49e
--- /dev/null
+++ b/frameworks/kitsimpl/include/executor_messenger_proxy.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXECUTOR_MESSENGER_PROXY_H
+#define EXECUTOR_MESSENGER_PROXY_H
+
+#include
+#include "nocopyable.h"
+#include "iexecutor_messenger.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+class ExecutorMessengerProxy : public IRemoteProxy {
+public:
+ explicit ExecutorMessengerProxy(const sptr& impl)
+ : IRemoteProxy(impl) {}
+
+ ~ExecutorMessengerProxy() override = default;
+ virtual int32_t SendData(uint64_t scheduleId, uint64_t transNum, int32_t srcType,
+ int32_t dstType, std::shared_ptr msg) override;
+ virtual int32_t Finish(uint64_t scheduleId, int32_t srcType, int32_t resultCode,
+ std::shared_ptr finalResult) override;
+
+private:
+ bool SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply);
+ static inline BrokerDelegator delegator_;
+};
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
+
+#endif // EXECUTOR_MESSENGER_PROXY_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/executor_messenger_stub.h b/frameworks/kitsimpl/include/executor_messenger_stub.h
new file mode 100644
index 0000000000000000000000000000000000000000..58939f3fc5d23b7c2b225dbba40dd8fa54587bde
--- /dev/null
+++ b/frameworks/kitsimpl/include/executor_messenger_stub.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXECUTOR_MESSENGER_STUB_H
+#define EXECUTOR_MESSENGER_STUB_H
+
+#include "nocopyable.h"
+#include "iexecutor_messenger.h"
+#include "iremote_stub.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+class ExecutorMessengerStub : public IRemoteStub {
+public:
+ ExecutorMessengerStub() = default;
+ ~ExecutorMessengerStub() override = default;
+
+ int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
+private:
+ int32_t SendDataStub(MessageParcel& data, MessageParcel& reply);
+ int32_t FinishStub(MessageParcel& data, MessageParcel& reply);
+};
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
+#endif // EXECUTOR_MESSENGER_STUB_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/i_coauth.h b/frameworks/kitsimpl/include/i_coauth.h
new file mode 100755
index 0000000000000000000000000000000000000000..fb9d039f5e036564cc8c59491f086b91dcd5bef1
--- /dev/null
+++ b/frameworks/kitsimpl/include/i_coauth.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef I_COAUTH_H
+#define I_COAUTH_H
+
+#include
+#include
+#include "auth_info.h"
+#include "icoauth_callback.h"
+#include "iset_prop_callback.h"
+#include "auth_attributes.h"
+#include "iexecutor_callback.h"
+#include "iquery_callback.h"
+#include "auth_executor.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+class ICoAuth : public IRemoteBroker {
+public:
+
+ /* Message ID */
+ enum {
+ COAUTH_EXECUTOR_REGIST = 0,
+ COAUTH_QUERY_STATUS,
+ COAUTH_SCHEDULE_REQUEST,
+ COAUTH_SCHEDULE_CANCEL,
+ COAUTH_GET_PROPERTY,
+ COAUTH_SET_PROPERTY
+ };
+
+ /* Business function */
+ virtual uint64_t Register(std::shared_ptr executorInfo,
+ const sptr &callback) = 0;
+ virtual void QueryStatus(AuthResPool::AuthExecutor &executorInfo,
+ const sptr &callback) = 0;
+ virtual void coAuth(uint64_t scheduleId, AuthInfo &authInfo, const sptr &callback) = 0;
+ virtual int32_t Cancel(uint64_t scheduleId) = 0;
+ virtual int32_t GetExecutorProp(AuthResPool::AuthAttributes &conditions,
+ std::shared_ptr values) = 0;
+ virtual void SetExecutorProp(AuthResPool::AuthAttributes &conditions, const sptr &callback) = 0;
+
+ DECLARE_INTERFACE_DESCRIPTOR(u"ohos.CoAuth.ICoAuth");
+};
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
+#endif // I_COAUTH_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/icoauth_callback.h b/frameworks/kitsimpl/include/icoauth_callback.h
new file mode 100644
index 0000000000000000000000000000000000000000..cc7eb6767644aff4488f3d831455e2f45e0130d1
--- /dev/null
+++ b/frameworks/kitsimpl/include/icoauth_callback.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ICOAUTH_CALLBACK_H
+#define ICOAUTH_CALLBACK_H
+
+#include
+#include
+#include
+#include
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+class ICoAuthCallback : public IRemoteBroker {
+public:
+
+ enum {
+ ONFINISH = 0,
+ ONACQUIREINFO
+ };
+
+ virtual void OnFinish(uint32_t resultCode, std::vector &scheduleToken) = 0;
+ virtual void OnAcquireInfo(uint32_t acquire) = 0;
+
+ DECLARE_INTERFACE_DESCRIPTOR(u"ohos.CoAuth.ICoAuthCallback");
+};
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
+#endif // ICOAUTH_CALLBACK_H
diff --git a/frameworks/kitsimpl/include/iexecutor_callback.h b/frameworks/kitsimpl/include/iexecutor_callback.h
new file mode 100755
index 0000000000000000000000000000000000000000..32507ebc71dcd3829427d663d0094879dbfd3473
--- /dev/null
+++ b/frameworks/kitsimpl/include/iexecutor_callback.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IEXECUTOR_CALLBACK_H
+#define IEXECUTOR_CALLBACK_H
+
+#include
+#include
+#include "iexecutor_messenger.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+class IExecutorCallback : public IRemoteBroker {
+public:
+ virtual void OnMessengerReady(const sptr &messenger) = 0;
+ virtual int32_t OnBeginExecute(uint64_t scheduleId, std::vector &publicKey,
+ std::shared_ptr commandAttrs) = 0;
+ virtual int32_t OnEndExecute(uint64_t scheduleId, std::shared_ptr consumerAttr) = 0;
+ virtual int32_t OnSetProperty(std::shared_ptr properties) = 0;
+ virtual int32_t OnGetProperty(std::shared_ptr conditions,
+ std::shared_ptr values) = 0;
+
+ DECLARE_INTERFACE_DESCRIPTOR(u"ohos.UserIAM.AuthResPool.ExecutorCallback");
+
+ enum Message {
+ ON_MESSENGER_READY = 1,
+ ON_BEGIN_EXECUTE,
+ ON_END_EXECUTE,
+ ON_SET_PROPERTY,
+ ON_GET_PROPERTY
+ };
+};
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
+
+#endif // IEXECUTOR_CALLBACK_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/iexecutor_messenger.h b/frameworks/kitsimpl/include/iexecutor_messenger.h
new file mode 100644
index 0000000000000000000000000000000000000000..f013584ac7be043789dba7826b4f7269e92c3e7f
--- /dev/null
+++ b/frameworks/kitsimpl/include/iexecutor_messenger.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IEXECUTOR_MESSENGER_H
+#define IEXECUTOR_MESSENGER_H
+
+#include
+
+#include "coauth_info_define.h"
+#include "auth_attributes.h"
+#include "auth_message.h"
+#include "coauth_hilog_wrapper.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+class IExecutorMessenger : public IRemoteBroker {
+public:
+ /* Message ID */
+ enum {
+ COAUTH_SEND_DATA = 0,
+ COAUTH_FINISH
+ };
+ /* Business function */
+ virtual int32_t SendData(uint64_t scheduleId, uint64_t transNum, int32_t srcType,
+ int32_t dstType, std::shared_ptr msg) = 0;
+ virtual int32_t Finish(uint64_t scheduleId, int32_t srcType, int32_t resultCode,
+ std::shared_ptr finalResult) = 0;
+
+ DECLARE_INTERFACE_DESCRIPTOR(u"ohos.UserIAM.AuthResPool.IExecutor_Messenger");
+};
+} // namespace IExecutor_Messenger
+} // namespace UserIAM
+} // namespace OHOS
+#endif // IEXECUTOR_MESSENGER_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/iquery_callback.h b/frameworks/kitsimpl/include/iquery_callback.h
new file mode 100644
index 0000000000000000000000000000000000000000..660be30c789fdaabbd56b2838b60384217e8a44e
--- /dev/null
+++ b/frameworks/kitsimpl/include/iquery_callback.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IQUERY_CALLBACK_H
+#define IQUERY_CALLBACK_H
+
+#include
+#include
+#include "query_callback.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+class IQueryCallback : public IRemoteBroker {
+public:
+ enum {
+ COAUTH_QUERY_RESULT = 0
+ };
+
+ virtual void OnResult(uint32_t resultCode) = 0;
+
+ DECLARE_INTERFACE_DESCRIPTOR(u"ohos.CoAuth.IQueryCallback");
+};
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
+#endif // IQUERY_CALLBACK_H
diff --git a/frameworks/kitsimpl/include/iset_prop_callback.h b/frameworks/kitsimpl/include/iset_prop_callback.h
new file mode 100644
index 0000000000000000000000000000000000000000..cf833e0a922fc1d808c227e64df83f267b801f4c
--- /dev/null
+++ b/frameworks/kitsimpl/include/iset_prop_callback.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ISET_PROP_CALLBACK_H
+#define ISET_PROP_CALLBACK_H
+
+#include
+#include
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+class ISetPropCallback : public IRemoteBroker {
+public:
+
+ enum {
+ ONRESULT = 0,
+ };
+
+ virtual void OnResult(uint32_t result, std::vector &extraInfo) = 0;
+
+ DECLARE_INTERFACE_DESCRIPTOR(u"ohos.CoAuth.ISetPropCallback");
+};
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
+#endif // ISET_PROP_CALLBACK_H
diff --git a/frameworks/kitsimpl/include/query_callback_proxy.h b/frameworks/kitsimpl/include/query_callback_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..91654f4477113a7cbe440790f3b8a9031172f604
--- /dev/null
+++ b/frameworks/kitsimpl/include/query_callback_proxy.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef QUERY_CALLBACK_PROXY_H
+#define QUERY_CALLBACK_PROXY_H
+
+#include
+#include "iquery_callback.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+class QueryCallbackProxy : public IRemoteProxy {
+public:
+ explicit QueryCallbackProxy(const sptr& impl)
+ : IRemoteProxy(impl) {}
+ ~QueryCallbackProxy() override = default;
+
+ virtual void OnResult(uint32_t resultCode) override;
+
+private:
+ bool SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply);
+
+private:
+ static inline BrokerDelegator delegator_;
+};
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
+#endif // QUERY_CALLBACK_PROXY_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/query_callback_stub.h b/frameworks/kitsimpl/include/query_callback_stub.h
new file mode 100644
index 0000000000000000000000000000000000000000..133d34290d443ea82acb4a6eed68ff9891e28399
--- /dev/null
+++ b/frameworks/kitsimpl/include/query_callback_stub.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef QUERY_CALLBACK_STUB_H
+#define QUERY_CALLBACK_STUB_H
+
+#include
+#include "iquery_callback.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+class QueryCallbackStub : public IRemoteStub {
+public:
+ explicit QueryCallbackStub(const std::shared_ptr& impl);
+ ~QueryCallbackStub() override = default;
+
+ virtual void OnResult(uint32_t resultCode) override;
+
+ int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
+
+private:
+ int32_t OnResultStub(MessageParcel& data, MessageParcel& reply);
+
+ std::shared_ptr callback_;
+};
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
+#endif // QUERY_CALLBACK_STUB_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/set_prop_callback_proxy.h b/frameworks/kitsimpl/include/set_prop_callback_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..6f3acb6601fabf52b37241d901738e38fd748073
--- /dev/null
+++ b/frameworks/kitsimpl/include/set_prop_callback_proxy.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SET_PROP_CALLBACK_PROXY_H
+#define SET_PROP_CALLBACK_PROXY_H
+
+#include
+#include "iset_prop_callback.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+class SetPropCallbackProxy : public IRemoteProxy {
+public:
+ explicit SetPropCallbackProxy(const sptr& impl)
+ : IRemoteProxy(impl) {}
+ ~SetPropCallbackProxy() override = default;
+ virtual void OnResult(uint32_t result, std::vector &extraInfo) override;
+
+private:
+ bool SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply);
+
+private:
+ static inline BrokerDelegator delegator_;
+};
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
+#endif // SET_PROP_CALLBACK_PROXY_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/include/set_prop_callback_stub.h b/frameworks/kitsimpl/include/set_prop_callback_stub.h
new file mode 100644
index 0000000000000000000000000000000000000000..88aafe412248a99189f3b30132184dfa36e9053a
--- /dev/null
+++ b/frameworks/kitsimpl/include/set_prop_callback_stub.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SET_PROP_CALLBACK_STUB_H
+#define SET_PROP_CALLBACK_STUB_H
+
+#include
+#include "iset_prop_callback.h"
+#include "set_prop_callback.h"
+#include "coauth_info_define.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+class SetPropCallbackStub : public IRemoteStub {
+public:
+ explicit SetPropCallbackStub(const std::shared_ptr& impl);
+ ~SetPropCallbackStub() override = default;
+
+ virtual void OnResult(uint32_t result, std::vector &extraInfo) override;
+
+ int32_t OnRemoteRequest(
+ uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
+private:
+ int32_t OnResultStub(MessageParcel &data, MessageParcel &reply);
+
+ std::shared_ptr callback_;
+};
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
+#endif // SET_PROP_CALLBACK_STUB_H
\ No newline at end of file
diff --git a/frameworks/kitsimpl/src/auth_executor_registry.cpp b/frameworks/kitsimpl/src/auth_executor_registry.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ec1d48c6bdbba1345414577f42030e112ef13a0f
--- /dev/null
+++ b/frameworks/kitsimpl/src/auth_executor_registry.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include
+#include "query_callback_stub.h"
+#include "executor_callback_stub.h"
+#include "auth_executor_registry.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+AuthExecutorRegistry::AuthExecutorRegistry() = default;
+AuthExecutorRegistry::~AuthExecutorRegistry() = default;
+
+sptr AuthExecutorRegistry::GetProxy()
+{
+ if (proxy_ != nullptr) {
+ return proxy_;
+ }
+
+ sptr sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ if (sam == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "Failed to get system ability manager");
+ return nullptr;
+ }
+ sptr obj = sam->CheckSystemAbility(COOPERATION_AUTHENTICATION_SERVICE_SA_ID);
+ if (obj == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "Failed to get coauth service");
+ return nullptr;
+ }
+ sptr dr = new AuthExecutorRegistryDeathRecipient();
+ if ((obj->IsProxyObject()) && (!obj->AddDeathRecipient(dr))) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "Failed to add death recipient");
+ return nullptr;
+ }
+
+ proxy_ = iface_cast(obj);
+ deathRecipient_ = dr;
+ COAUTH_HILOGI(MODULE_INNERKIT, "Succeed to connect coauth service");
+ return proxy_;
+}
+
+void AuthExecutorRegistry::ResetProxy(const wptr& remote)
+{
+ std::lock_guard lock(mutex_);
+ auto serviceRemote = proxy_->AsObject();
+ if ((serviceRemote != nullptr) && (serviceRemote == remote.promote())) {
+ serviceRemote->RemoveDeathRecipient(deathRecipient_);
+ proxy_ = nullptr;
+ }
+}
+
+uint64_t AuthExecutorRegistry::Register(std::shared_ptr executorInfo,
+ std::shared_ptr callback)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "Register enter");
+ if (executorInfo == nullptr || callback == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "Register failed,executorInfo or callback is nullptr");
+ return FAIL;
+ }
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "GetProxy is nullptr");
+ return FAIL;
+ }
+ sptr iExecutorCallback = new ExecutorCallbackStub(callback);
+ return proxy->Register(executorInfo, iExecutorCallback);
+}
+
+void AuthExecutorRegistry::QueryStatus(AuthExecutor &executorInfo, std::shared_ptr callback)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "QueryStatus enter");
+ if (callback == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "QueryStatus failed, callback is nullptr");
+ return;
+ }
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "GetProxy is nullptr");
+ return;
+ }
+ sptr iQueryCallback = new QueryCallbackStub(callback);
+ return proxy->QueryStatus(executorInfo, iQueryCallback);
+}
+
+void AuthExecutorRegistry::AuthExecutorRegistryDeathRecipient::OnRemoteDied(const wptr& remote)
+{
+ if (remote == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "OnRemoteDied failed, remote is nullptr");
+ return;
+ }
+
+ AuthExecutorRegistry::GetInstance().ResetProxy(remote);
+ COAUTH_HILOGE(MODULE_INNERKIT, "CoAuthDeathRecipient::Recv death notice.");
+}
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/kitsimpl/src/auth_info.cpp b/frameworks/kitsimpl/src/auth_info.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..72066fb440dbbf5d72dcf2a10a4b3ae8d6c843c1
--- /dev/null
+++ b/frameworks/kitsimpl/src/auth_info.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "coauth_info_define.h"
+#include "auth_info.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+int32_t AuthInfo::GetPkgName(std::string &value)
+{
+ value = pkgName_;
+ return SUCCESS;
+}
+
+int32_t AuthInfo::GetCallerUid(uint64_t &value)
+{
+ value = callerUid_;
+ return SUCCESS;
+}
+
+int32_t AuthInfo::SetPkgName(std::string value)
+{
+ pkgName_ = value;
+ return SUCCESS;
+}
+
+int32_t AuthInfo::SetCallerUid(uint64_t value)
+{
+ callerUid_= value;
+ return SUCCESS;
+}
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
diff --git a/frameworks/kitsimpl/src/coauth.cpp b/frameworks/kitsimpl/src/coauth.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..d095f4f8f198adca8eeb806c17e7ab19f33e3227
--- /dev/null
+++ b/frameworks/kitsimpl/src/coauth.cpp
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include
+#include "coauth_hilog_wrapper.h"
+#include "coauth_callback_stub.h"
+#include "set_prop_callback_stub.h"
+#include "co_auth.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+CoAuth::CoAuth() = default;
+CoAuth::~CoAuth() = default;
+
+sptr CoAuth::GetProxy()
+{
+ if (proxy_ != nullptr) {
+ return proxy_;
+ }
+
+ sptr sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ if (sam == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "Failed to get system ability manager");
+ return nullptr;
+ }
+ sptr obj = sam->CheckSystemAbility(COOPERATION_AUTHENTICATION_SERVICE_SA_ID);
+ if (obj == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "Failed to get coauth manager service");
+ return nullptr;
+ }
+ sptr dr = new CoAuthDeathRecipient();
+ if ((obj->IsProxyObject()) && (!obj->AddDeathRecipient(dr))) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "Failed to add death recipient");
+ return nullptr;
+ }
+
+ proxy_ = iface_cast(obj);
+ deathRecipient_ = dr;
+ COAUTH_HILOGE(MODULE_INNERKIT, "Succeed to connect coauth manager service");
+ return proxy_;
+}
+
+void CoAuth::ResetProxy(const wptr& remote)
+{
+ std::lock_guard lock(mutex_);
+ if (proxy_ == nullptr) {
+ return;
+ }
+
+ auto serviceRemote = proxy_->AsObject();
+ if ((serviceRemote != nullptr) && (serviceRemote == remote.promote())) {
+ serviceRemote->RemoveDeathRecipient(deathRecipient_);
+ proxy_ = nullptr;
+ }
+}
+
+void CoAuth::coAuth(uint64_t scheduleId, AuthInfo &authInfo, std::shared_ptr callback)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "coAuth enter");
+ if (callback == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "coAuth failed, callback is nullptr");
+ return ;
+ }
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "coAuth failed, remote is nullptr");
+ return;
+ }
+
+ sptr icoAuthCallback = new CoAuthCallbackStub(callback);
+ if (icoAuthCallback == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "coAuth failed, icoAuthCallback is nullptr");
+ return ;
+ }
+ return proxy->coAuth(scheduleId, authInfo, icoAuthCallback);
+}
+
+int32_t CoAuth::Cancel(uint64_t scheduleId)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "CoAuth Cancel enter");
+ auto proxy = GetProxy();
+ if (proxy == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "Cancel failed, proxy is nullptr");
+ return FAIL;
+ }
+
+ return proxy->Cancel(scheduleId);
+}
+
+int32_t CoAuth::GetExecutorProp(AuthResPool::AuthAttributes &conditions,
+ std::shared_ptr values)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "CoAuth: GetExecutorProp enter");
+ auto proxy = GetProxy();
+ if (proxy == nullptr || values == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "GetExecutorProp failed, proxy or values is nullptr");
+ return FAIL;
+ }
+
+ return proxy->GetExecutorProp(conditions, values);
+}
+
+void CoAuth::SetExecutorProp(AuthResPool::AuthAttributes &conditions, std::shared_ptr callback)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "CoAuth: SetExecutorProp enter");
+ auto proxy = GetProxy();
+ if (proxy == nullptr || callback == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "SetExecutorProp failed, proxy or callback is nullptr");
+ return;
+ }
+
+ sptr iSetExecutorCallback = new SetPropCallbackStub(callback);
+ return proxy->SetExecutorProp(conditions, iSetExecutorCallback);
+}
+
+
+void CoAuth::CoAuthDeathRecipient::OnRemoteDied(const wptr& remote)
+{
+ if (remote == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "OnRemoteDied failed, remote is nullptr");
+ return;
+ }
+
+ CoAuth::GetInstance().ResetProxy(remote);
+ COAUTH_HILOGE(MODULE_INNERKIT, "CoAuthDeathRecipient::Recv death notice.");
+}
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/kitsimpl/src/coauth_callback_proxy.cpp b/frameworks/kitsimpl/src/coauth_callback_proxy.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..781795a8f6dcef3bf4295a90bdae69b41d221a05
--- /dev/null
+++ b/frameworks/kitsimpl/src/coauth_callback_proxy.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include
+#include
+#include "coauth_hilog_wrapper.h"
+#include "icoauth_callback.h"
+#include "coauth_callback_proxy.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+void CoAuthCallbackProxy::OnFinish(uint32_t resultCode, std::vector &scheduleToken)
+{
+ MessageParcel data;
+ MessageParcel reply;
+
+ if (!data.WriteUint32(resultCode)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteUint32(resultCode).");
+ }
+
+ if (!data.WriteUInt8Vector(scheduleToken)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteUInt8Vector(scheduleToken).");
+ }
+
+ bool ret = SendRequest(static_cast(ICoAuthCallback::ONFINISH), data, reply);
+ if (ret) {
+ COAUTH_HILOGI(MODULE_INNERKIT, "result = %{public}d", ret);
+ }
+}
+
+void CoAuthCallbackProxy::OnAcquireInfo(uint32_t acquire)
+{
+ MessageParcel data;
+ if (!data.WriteUint32(acquire)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteUint32(acquire).");
+ }
+
+ MessageParcel reply;
+ bool ret = SendRequest(static_cast(ICoAuthCallback::ONACQUIREINFO), data, reply);
+ if (ret) {
+ COAUTH_HILOGI(MODULE_INNERKIT, "result = %{public}d", ret);
+ }
+}
+
+bool CoAuthCallbackProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply)
+{
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to get remote.");
+ return false;
+ }
+ MessageOption option(MessageOption::TF_SYNC);
+ int32_t result = remote->SendRequest(code, data, reply, option);
+ if (result != OHOS::NO_ERROR) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to SendRequest.result = %{public}d", result);
+ return false;
+ }
+ return true;
+}
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/kitsimpl/src/coauth_callback_stub.cpp b/frameworks/kitsimpl/src/coauth_callback_stub.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..787c1aff518a5796aa2124a8dc3d8eab22171bc8
--- /dev/null
+++ b/frameworks/kitsimpl/src/coauth_callback_stub.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include
+#include "coauth_hilog_wrapper.h"
+#include "coauth_info_define.h"
+#include "coauth_callback_stub.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+CoAuthCallbackStub::CoAuthCallbackStub(const std::shared_ptr& impl)
+{
+ callback_ = impl;
+}
+
+int32_t CoAuthCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
+ MessageParcel &reply, MessageOption &option)
+{
+ switch (code) {
+ case static_cast(ICoAuthCallback::ONFINISH):
+ return OnFinishStub(data, reply);
+ case static_cast(ICoAuthCallback::ONACQUIREINFO):
+ return OnAcquireInfoStub(data, reply);
+ default:
+ return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
+ }
+}
+
+int32_t CoAuthCallbackStub::OnFinishStub(MessageParcel &data, MessageParcel &reply)
+{
+ uint32_t resultCode = data.ReadUint32();
+ std::vector scheduleToken;
+ data.ReadUInt8Vector(&scheduleToken);
+
+ OnFinish(resultCode, scheduleToken);
+ return SUCCESS;
+}
+
+int32_t CoAuthCallbackStub::OnAcquireInfoStub(MessageParcel &data, MessageParcel &reply)
+{
+ uint32_t acquire = data.ReadUint32();
+
+ OnAcquireInfo(acquire);
+ return SUCCESS;
+}
+
+void CoAuthCallbackStub::OnFinish(uint32_t resultCode, std::vector &scheduleToken)
+{
+ if (callback_ == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "CoAuthCallback is null.");
+ } else {
+ callback_->OnFinish(resultCode, scheduleToken);
+ }
+}
+
+void CoAuthCallbackStub::OnAcquireInfo(uint32_t acquire)
+{
+ if (callback_ == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "CoAuthCallback is null.");
+ } else {
+ callback_->OnAcquireInfo(acquire);
+ }
+}
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/kitsimpl/src/coauth_proxy.cpp b/frameworks/kitsimpl/src/coauth_proxy.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..b835baa1f8f864ed0411051a46d4f7e39064c7fd
--- /dev/null
+++ b/frameworks/kitsimpl/src/coauth_proxy.cpp
@@ -0,0 +1,285 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include
+#include
+#include "coauth_hilog_wrapper.h"
+#include "coauth_proxy.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+uint32_t CoAuthProxy::WriteAuthExecutor(AuthResPool::AuthExecutor &executorInfo, MessageParcel &data)
+{
+ AuthType authType;
+ executorInfo.GetAuthType(authType);
+ if (!data.WriteInt32(authType)) {
+ return FAIL;
+ }
+ COAUTH_HILOGD(MODULE_INNERKIT, "WriteInt32,authType:%{public}d", authType);
+
+ uint64_t authAbility;
+ executorInfo.GetAuthAbility(authAbility);
+ if (!data.WriteUint64(authAbility)) {
+ return FAIL;
+ }
+ COAUTH_HILOGD(MODULE_INNERKIT, "WriteUint64,authAbility:%{public}llu", authAbility);
+
+ ExecutorSecureLevel executorSecLevel;
+ executorInfo.GetExecutorSecLevel(executorSecLevel);
+ if (!data.WriteInt32(executorSecLevel)) {
+ return FAIL;
+ }
+ COAUTH_HILOGD(MODULE_INNERKIT, "WriteInt32,executorSecLevel:%{public}d", executorSecLevel);
+
+ ExecutorType executorType;
+ executorInfo.GetExecutorType(executorType);
+ if (!data.WriteInt32(executorType)) {
+ return FAIL;
+ }
+ COAUTH_HILOGD(MODULE_INNERKIT, "WriteInt32,executorType:%{public}d", executorType);
+
+ std::vector publicKey;
+ executorInfo.GetPublicKey(publicKey);
+ if (!data.WriteUInt8Vector(publicKey)) {
+ return FAIL;
+ }
+
+ std::vector deviceId;
+ executorInfo.GetDeviceId(deviceId);
+ if (!data.WriteUInt8Vector(deviceId)) {
+ return FAIL;
+ }
+ return SUCCESS;
+}
+
+uint64_t CoAuthProxy::Register(std::shared_ptr executorInfo,
+ const sptr &callback)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "Register enter");
+ if (executorInfo == nullptr || callback == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "Register failed,executorInfo or callback is nullptr");
+ return FAIL;
+ }
+ MessageParcel data;
+ MessageParcel reply;
+ uint64_t result = 0;
+
+ if (!data.WriteInterfaceToken(CoAuthProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ return FAIL;
+ }
+
+ if (WriteAuthExecutor(*executorInfo, data) == FAIL) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write executorInfo failed!");
+ return FAIL;
+ }
+ if (!data.WriteRemoteObject(callback->AsObject())) {
+ COAUTH_HILOGD(MODULE_INNERKIT, "failed to WriteRemoteObject(callback).");
+ return FAIL;
+ }
+
+ bool ret = SendRequest(static_cast(ICoAuth::COAUTH_EXECUTOR_REGIST), data, reply);
+ if (ret) {
+ result = reply.ReadUint64();
+ COAUTH_HILOGD(MODULE_INNERKIT, "result = %{public}llu", result);
+ }
+ return result;
+}
+
+void CoAuthProxy::QueryStatus(AuthResPool::AuthExecutor &executorInfo,
+ const sptr &callback)
+{
+ MessageParcel data;
+ MessageParcel reply;
+
+ if (!data.WriteInterfaceToken(CoAuthProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ return;
+ }
+ if (WriteAuthExecutor(executorInfo, data) == FAIL) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write executorInfo failed!");
+ return ;
+ }
+
+ if (!data.WriteRemoteObject(callback->AsObject())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteRemoteObject(callback).");
+ return;
+ }
+
+ bool ret = SendRequest(static_cast(ICoAuth::COAUTH_QUERY_STATUS), data, reply, false);
+ if (ret) {
+ COAUTH_HILOGD(MODULE_INNERKIT, "ret = %{public}d", ret);
+ }
+ return;
+}
+
+void CoAuthProxy::coAuth(uint64_t scheduleId, AuthInfo &authInfo, const sptr &callback)
+{
+ MessageParcel data;
+ MessageParcel reply;
+
+ if (!data.WriteInterfaceToken(CoAuthProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ }
+
+ std::string GetPkgName;
+ authInfo.GetPkgName(GetPkgName);
+ if (!data.WriteString(GetPkgName)) {
+ COAUTH_HILOGD(MODULE_INNERKIT, "WriteString,GetPkgName failed");
+ }
+ uint64_t GetCallerUid;
+ authInfo.GetCallerUid(GetCallerUid);
+ data.WriteUint64(GetCallerUid);
+ COAUTH_HILOGD(MODULE_INNERKIT, "WriteUint64,GetCallerUid:%{public}llu", GetCallerUid);
+
+ if (!data.WriteUint64(scheduleId)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteUint64(scheduleId).");
+ } else {
+ COAUTH_HILOGD(MODULE_INNERKIT, "WriteUint64,scheduleId:%{public}llu", scheduleId);
+ }
+
+ if (!data.WriteRemoteObject(callback->AsObject())) {
+ COAUTH_HILOGD(MODULE_INNERKIT, "failed to WriteRemoteObject(callback).");
+ }
+
+ bool ret = SendRequest(static_cast(ICoAuth::COAUTH_SCHEDULE_REQUEST), data, reply, false);
+ if (ret) {
+ COAUTH_HILOGD(MODULE_INNERKIT, "ret = %{public}d", ret);
+ } else {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to SendRequest.");
+ }
+}
+
+int32_t CoAuthProxy::Cancel(uint64_t scheduleId)
+{
+ MessageParcel data;
+ COAUTH_HILOGD(MODULE_INNERKIT, "CoauthProxy: Cancel enter");
+ if (!data.WriteInterfaceToken(CoAuthProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ return FAIL;
+ }
+ if (!data.WriteUint64(scheduleId)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteUint64(scheduleId).");
+ return FAIL;
+ }
+
+ MessageParcel reply;
+ int32_t result = 0;
+ bool ret = SendRequest(static_cast(ICoAuth::COAUTH_SCHEDULE_CANCEL), data, reply);
+ if (ret) {
+ result = reply.ReadInt32();
+ COAUTH_HILOGD(MODULE_INNERKIT, "result = %{public}d", result);
+ }
+ return SUCCESS;
+}
+
+int32_t CoAuthProxy::GetExecutorProp(AuthResPool::AuthAttributes &conditions,
+ std::shared_ptr values)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "CoauthProxy: GetExecutorProp enter");
+ int32_t result = SUCCESS;
+ MessageParcel data;
+ MessageParcel reply;
+
+ if (!data.WriteInterfaceToken(CoAuthProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ return FAIL;
+ }
+
+ if (values == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to get valuesptr.");
+ return FAIL;
+ }
+ std::vector buffer;
+ if (conditions.Pack(buffer)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "conditions pack buffer failed!");
+ return FAIL;
+ }
+ if (!data.WriteUInt8Vector(buffer)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "data WriteUInt8Vector buffer failed!");
+ return FAIL;
+ }
+ if (values->Pack(buffer)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "values pack buffer failed!");
+ return FAIL;
+ }
+ if (!data.WriteUInt8Vector(buffer)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "data WriteUInt8Vector buffer failed!");
+ return FAIL;
+ }
+
+ bool ret = SendRequest(static_cast(ICoAuth::COAUTH_GET_PROPERTY), data, reply);
+ if (!ret) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "SendRequest is failed, error code: %d", ret);
+ return FAIL;
+ }
+ if (!reply.ReadInt32(result)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "Readback fail!");
+ return FAIL;
+ }
+ return result;
+}
+
+void CoAuthProxy::SetExecutorProp(AuthResPool::AuthAttributes &conditions,
+ const sptr &callback)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "CoauthProxy: SetExecutorProp enter");
+ int result = false;
+ MessageParcel data;
+ MessageParcel reply;
+
+ if (!data.WriteInterfaceToken(CoAuthProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ return ;
+ }
+ std::vector buffer;
+ if (conditions.Pack(buffer)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "conditions pack buffer failed!");
+ return;
+ }
+ if (!data.WriteUInt8Vector(buffer)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "data WriteUInt8Vector buffer failed!");
+ return;
+ }
+ if (!data.WriteRemoteObject(callback->AsObject())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteRemoteObject(callback).");
+ }
+ bool ret = SendRequest(static_cast(ICoAuth::COAUTH_SET_PROPERTY), data, reply, false);
+ if (ret) {
+ COAUTH_HILOGD(MODULE_INNERKIT, "ret = %{public}d", result);
+ } else {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to SendRequest.");
+ }
+}
+
+bool CoAuthProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, bool isSync)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "CoauthProxy: SendRequest enter");
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to get remote.");
+ return false;
+ }
+ MessageOption option(isSync ? MessageOption::TF_SYNC : MessageOption::TF_ASYNC);
+ int32_t result = remote->SendRequest(code, data, reply, option);
+ if (result != OHOS::NO_ERROR) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to SendRequest.result = %{public}d", result);
+ return false;
+ }
+ return true;
+}
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/kitsimpl/src/executor_callback_proxy.cpp b/frameworks/kitsimpl/src/executor_callback_proxy.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..16f0043a20623c20afa1a9b5aaf774cacf330fec
--- /dev/null
+++ b/frameworks/kitsimpl/src/executor_callback_proxy.cpp
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "executor_callback_proxy.h"
+#include "coauth_hilog_wrapper.h"
+#include "message_parcel.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+void ExecutorCallbackProxy::OnMessengerReady(const sptr &messenger)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "ExecutorCallbackProxy OnMessengerReady!");
+ MessageParcel data;
+ MessageParcel reply;
+ if (!data.WriteInterfaceToken(ExecutorCallbackProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ return ;
+ }
+
+ if (!data.WriteRemoteObject(messenger.GetRefPtr()->AsObject())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write RemoteObject failed!");
+ return ;
+ }
+ bool ret = SendRequest(static_cast(IExecutorCallback::ON_MESSENGER_READY), data, reply);
+ if (ret) {
+ COAUTH_HILOGI(MODULE_INNERKIT, "ret = %{public}d", ret);
+ }
+ return ;
+}
+
+int32_t ExecutorCallbackProxy::OnBeginExecute(uint64_t scheduleId, std::vector &publicKey,
+ std::shared_ptr commandAttrs)
+{
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = 0;
+ if (!data.WriteInterfaceToken(ExecutorCallbackProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ return FAIL;
+ }
+
+ if (!data.WriteUint64(scheduleId)) {
+ return FAIL;
+ }
+ if (!data.WriteUInt8Vector(publicKey)) {
+ return FAIL;
+ }
+ std::vector buffer;
+ if (commandAttrs->Pack(buffer)) {
+ return FAIL;
+ }
+ if (!data.WriteUInt8Vector(buffer)) {
+ return FAIL;
+ }
+
+ bool ret = SendRequest(static_cast(IExecutorCallback::ON_BEGIN_EXECUTE), data, reply);
+ if (ret) {
+ result = reply.ReadInt32();
+ COAUTH_HILOGI(MODULE_INNERKIT, "result = %{public}d", result);
+ }
+ return SUCCESS;
+}
+int32_t ExecutorCallbackProxy::OnEndExecute(uint64_t scheduleId, std::shared_ptr consumerAttr)
+{
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = 0;
+ if (!data.WriteInterfaceToken(ExecutorCallbackProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ return FAIL;
+ }
+
+ if (!data.WriteUint64(scheduleId)) {
+ return FAIL;
+ }
+
+ std::vector buffer;
+ if (consumerAttr->Pack(buffer)) {
+ return FAIL;
+ }
+ if (!data.WriteUInt8Vector(buffer)) {
+ return FAIL;
+ }
+
+ bool ret = SendRequest(static_cast(IExecutorCallback::ON_END_EXECUTE), data, reply);
+ if (ret) {
+ result = reply.ReadInt32();
+ COAUTH_HILOGI(MODULE_INNERKIT, "result = %{public}d", result);
+ }
+ return SUCCESS;
+}
+
+int32_t ExecutorCallbackProxy::OnSetProperty(std::shared_ptr properties)
+{
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = 0;
+ if (!data.WriteInterfaceToken(ExecutorCallbackProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ return FAIL;
+ }
+ std::vector buffer;
+ if (properties->Pack(buffer)) {
+ return FAIL;
+ }
+ if (!data.WriteUInt8Vector(buffer)) {
+ return FAIL;
+ }
+ bool ret = SendRequest(static_cast(IExecutorCallback::ON_SET_PROPERTY), data, reply);
+ if (ret) {
+ result = reply.ReadInt32();
+ COAUTH_HILOGI(MODULE_INNERKIT, "result = %{public}d", result);
+ }
+ return SUCCESS;
+}
+
+int32_t ExecutorCallbackProxy::OnGetProperty(std::shared_ptr conditions,
+ std::shared_ptr values)
+{
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = 0;
+ if (!data.WriteInterfaceToken(ExecutorCallbackProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ return FAIL;
+ }
+
+ std::vector buffer;
+ if (conditions->Pack(buffer)) {
+ return FAIL;
+ }
+ if (!data.WriteUInt8Vector(buffer)) {
+ return FAIL;
+ }
+ if (values->Pack(buffer)) {
+ return FAIL;
+ }
+ if (!data.WriteUInt8Vector(buffer)) {
+ return FAIL;
+ }
+ bool ret = SendRequest(static_cast(IExecutorCallback::ON_GET_PROPERTY), data, reply);
+ if (ret) {
+ result = reply.ReadInt32();
+ COAUTH_HILOGI(MODULE_INNERKIT, "result = %{public}d", result);
+ }
+ return result;
+}
+
+
+bool ExecutorCallbackProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply)
+{
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to get remote.");
+ return false;
+ }
+ MessageOption option(MessageOption::TF_SYNC);
+ int32_t result = remote->SendRequest(code, data, reply, option);
+ if (result != OHOS::NO_ERROR) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to SendRequest.result = %{public}d", result);
+ return false;
+ }
+ return true;
+}
+}
+}
+}
\ No newline at end of file
diff --git a/frameworks/kitsimpl/src/executor_callback_stub.cpp b/frameworks/kitsimpl/src/executor_callback_stub.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6731eb3f2d3f6cd2b613f78a753dbd5b925c54df
--- /dev/null
+++ b/frameworks/kitsimpl/src/executor_callback_stub.cpp
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "executor_callback_stub.h"
+#include "message_parcel.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+const std::string PERMISSION_AUTH_RESPOOL = "ohos.permission.ACCESS_AUTH_RESPOOL";
+const std::string PERMISSION_ACCESS_COAUTH = "ohos.permission.ACCESS_COAUTH";
+
+ExecutorCallbackStub::ExecutorCallbackStub(const std::shared_ptr& impl)
+{
+ callback_ = impl;
+}
+
+int32_t ExecutorCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
+ MessageParcel &reply, MessageOption &option)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "ExecutorCallbackStub::OnRemoteRequest!");
+ std::u16string descripter = ExecutorCallbackStub::GetDescriptor();
+ std::u16string remoteDescripter = data.ReadInterfaceToken();
+ if (descripter != remoteDescripter) {
+ COAUTH_HILOGD(MODULE_INNERKIT, "CoAuthStub::OnRemoteRequest failed, descriptor is not matched!");
+ return FAIL;
+ }
+
+ switch (code) {
+ case static_cast(IExecutorCallback::ON_MESSENGER_READY):
+ return OnMessengerReadyStub(data, reply);
+ case static_cast(IExecutorCallback::ON_BEGIN_EXECUTE):
+ return OnBeginExecuteStub(data, reply);
+ case static_cast(IExecutorCallback::ON_END_EXECUTE):
+ return OnEndExecuteStub(data, reply);
+ case static_cast(IExecutorCallback::ON_SET_PROPERTY):
+ return OnSetPropertyStub(data, reply);
+ case static_cast(IExecutorCallback::ON_GET_PROPERTY):
+ return OnGetPropertyStub(data, reply);
+ default:
+ return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
+ }
+}
+
+int32_t ExecutorCallbackStub::OnMessengerReadyStub(MessageParcel& data, MessageParcel& reply)
+{
+ COAUTH_HILOGD(MODULE_INNERKIT, "ExecutorCallbackStub::OnMessengerReadyStub");
+ sptr messenger = iface_cast(data.ReadRemoteObject());
+ if (messenger == nullptr) {
+ COAUTH_HILOGD(MODULE_INNERKIT, "messenger is nullptr");
+ return FAIL;
+ }
+ COAUTH_HILOGD(MODULE_INNERKIT, "iface_cast right");
+ OnMessengerReady(messenger);
+ COAUTH_HILOGD(MODULE_INNERKIT, "OnMessengerReady GetRefPtr");
+ return SUCCESS;
+}
+int32_t ExecutorCallbackStub::OnBeginExecuteStub(MessageParcel& data, MessageParcel& reply)
+{
+ uint64_t scheduleId = data.ReadUint64();
+ std::vector publicKey, buffer;
+ std::shared_ptr commandAttrs = std::make_shared();
+ data.ReadUInt8Vector(&publicKey);
+ data.ReadUInt8Vector(&buffer);
+ commandAttrs->Unpack(buffer);
+ int32_t ret = OnBeginExecute(scheduleId, publicKey, commandAttrs);
+ if (!reply.WriteInt32(ret)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteInt32(ret)");
+ return FAIL;
+ }
+ return SUCCESS;
+}
+
+int32_t ExecutorCallbackStub::OnEndExecuteStub(MessageParcel& data, MessageParcel& reply)
+{
+ uint64_t scheduleId = data.ReadUint64();
+ std::vector buffer;
+ std::shared_ptr consumerAttr = std::make_shared();
+ data.ReadUInt8Vector(&buffer);
+ consumerAttr->Unpack(buffer);
+ int32_t ret = OnEndExecute(scheduleId, consumerAttr);
+ if (!reply.WriteInt32(ret)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteInt32(ret)");
+ return FAIL;
+ }
+ return SUCCESS;
+}
+
+int32_t ExecutorCallbackStub::OnGetPropertyStub(MessageParcel& data, MessageParcel& reply)
+{
+ std::vector buffer;
+ std::shared_ptr conditions = std::make_shared();
+ data.ReadUInt8Vector(&buffer);
+ conditions->Unpack(buffer);
+ buffer.clear();
+ std::shared_ptr values = std::make_shared();
+ data.ReadUInt8Vector(&buffer);
+ values->Unpack(buffer);
+ int32_t ret = OnGetProperty(conditions, values);
+ if (!reply.WriteInt32(ret)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteInt32(ret)");
+ return FAIL;
+ }
+ return SUCCESS;
+}
+int32_t ExecutorCallbackStub::OnSetPropertyStub(MessageParcel& data, MessageParcel& reply)
+{
+ std::vector buffer;
+ std::shared_ptr properties = std::make_shared();
+ data.ReadUInt8Vector(&buffer);
+ properties->Unpack(buffer);
+
+ int32_t ret = OnSetProperty(properties);
+ if (!reply.WriteInt32(ret)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteInt32(ret)");
+ return FAIL;
+ }
+ return SUCCESS;
+}
+
+void ExecutorCallbackStub::OnMessengerReady(const sptr &messenger)
+{
+ if (callback_ == nullptr) {
+ return ;
+ } else {
+ callback_->OnMessengerReady(messenger);
+ }
+}
+int32_t ExecutorCallbackStub::OnBeginExecute(uint64_t scheduleId, std::vector &publicKey,
+ std::shared_ptr commandAttrs)
+{
+ int32_t ret = FAIL;
+ if (callback_ == nullptr) {
+ return FAIL;
+ } else {
+ ret = callback_->OnBeginExecute(scheduleId, publicKey, commandAttrs);
+ }
+ return ret;
+}
+int32_t ExecutorCallbackStub::OnEndExecute(uint64_t scheduleId, std::shared_ptr consumerAttr)
+{
+ int32_t ret = FAIL;
+ if (callback_ == nullptr) {
+ return FAIL;
+ } else {
+ ret = callback_->OnEndExecute(scheduleId, consumerAttr);
+ }
+ return ret;
+}
+int32_t ExecutorCallbackStub::OnSetProperty(std::shared_ptr properties)
+{
+ int32_t ret = FAIL;
+ if (callback_ == nullptr) {
+ return FAIL;
+ } else {
+ ret = callback_->OnSetProperty(properties);
+ }
+ return ret;
+}
+int32_t ExecutorCallbackStub::OnGetProperty(std::shared_ptr conditions,
+ std::shared_ptr values)
+{
+ int32_t ret = FAIL;
+ if (callback_ == nullptr) {
+ return FAIL;
+ } else {
+ ret = callback_->OnGetProperty(conditions, values);
+ }
+ return ret;
+}
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/kitsimpl/src/executor_messenger_proxy.cpp b/frameworks/kitsimpl/src/executor_messenger_proxy.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4cc0149614e17267c046c6b8b869b37191a28f58
--- /dev/null
+++ b/frameworks/kitsimpl/src/executor_messenger_proxy.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "executor_messenger_proxy.h"
+#include "coauth_hilog_wrapper.h"
+#include "message_parcel.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+int32_t ExecutorMessengerProxy::SendData(uint64_t scheduleId, uint64_t transNum,
+ int32_t srcType, int32_t dstType, std::shared_ptr msg)
+{
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = 0;
+ if (!data.WriteInterfaceToken(ExecutorMessengerProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ return FAIL;
+ }
+ if (!data.WriteUint64(scheduleId)) {
+ return FAIL;
+ }
+ if (!data.WriteUint64(transNum)) {
+ return FAIL;
+ }
+ if (!data.WriteInt32(srcType)) {
+ return FAIL;
+ }
+ if (!data.WriteInt32(dstType)) {
+ return FAIL;
+ }
+
+ std::vector buffer;
+ msg->FromUint8Array(buffer);
+ if (!data.WriteUInt8Vector(buffer)) {
+ return FAIL;
+ }
+ bool ret = SendRequest(static_cast(IExecutorMessenger::COAUTH_SEND_DATA), data, reply);
+ if (ret) {
+ result = reply.ReadInt32();
+ COAUTH_HILOGI(MODULE_INNERKIT, "result = %{public}d", result);
+ }
+ return result;
+}
+
+
+int32_t ExecutorMessengerProxy::Finish(uint64_t scheduleId, int32_t srcType, int32_t resultCode,
+ std::shared_ptr finalResult)
+{
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = 0;
+ if (!data.WriteInterfaceToken(ExecutorMessengerProxy::GetDescriptor())) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "write descriptor failed!");
+ return result;
+ }
+
+ if (!data.WriteUint64(scheduleId)) {
+ return FAIL;
+ }
+ if (!data.WriteInt32(srcType)) {
+ return FAIL;
+ }
+ if (!data.WriteInt32(resultCode)) {
+ return FAIL;
+ }
+ std::vector buffer;
+ if (finalResult->Pack(buffer)) {
+ return FAIL;
+ }
+ if (!data.WriteUInt8Vector(buffer)) {
+ return FAIL;
+ }
+ bool ret = SendRequest(static_cast(IExecutorMessenger::COAUTH_FINISH), data, reply);
+ if (ret) {
+ result = reply.ReadInt32();
+ COAUTH_HILOGI(MODULE_INNERKIT, "result = %{public}d", result);
+ }
+ return result;
+}
+bool ExecutorMessengerProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply)
+{
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to get remote.");
+ return false;
+ }
+ MessageOption option(MessageOption::TF_SYNC);
+ int32_t result = remote->SendRequest(code, data, reply, option);
+ if (result != OHOS::NO_ERROR) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to SendRequest.result = %{public}d", result);
+ return false;
+ }
+ return true;
+}
+}
+}
+}
\ No newline at end of file
diff --git a/frameworks/kitsimpl/src/executor_messenger_stub.cpp b/frameworks/kitsimpl/src/executor_messenger_stub.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b6157e4cf2fd0c0e0a328217ed0d28f11c6f138e
--- /dev/null
+++ b/frameworks/kitsimpl/src/executor_messenger_stub.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "executor_messenger_stub.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+const std::string PERMISSION_AUTH_RESPOOL = "ohos.permission.ACCESS_AUTH_RESPOOL";
+const std::string PERMISSION_ACCESS_COAUTH = "ohos.permission.ACCESS_COAUTH";
+
+int32_t ExecutorMessengerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
+ MessageParcel &reply, MessageOption &option)
+{
+ COAUTH_HILOGD(MODULE_SERVICE, "CoAuthStub::OnRemoteRequest, cmd = %d, flags= %d",
+ code, option.GetFlags());
+ std::u16string descripter = ExecutorMessengerStub::GetDescriptor();
+ std::u16string remoteDescripter = data.ReadInterfaceToken();
+ if (descripter != remoteDescripter) {
+ COAUTH_HILOGE(MODULE_SERVICE, "CoAuthStub::OnRemoteRequest failed, descriptor is not matched!");
+ return FAIL;
+ }
+
+ switch (code) {
+ case static_cast(IExecutorMessenger::COAUTH_SEND_DATA):
+ return SendDataStub(data, reply); // call Stub
+ case static_cast(IExecutorMessenger::COAUTH_FINISH):
+ return FinishStub(data, reply);
+ default:
+ return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
+ }
+}
+int32_t ExecutorMessengerStub::SendDataStub(MessageParcel& data, MessageParcel& reply)
+{
+ uint64_t scheduleId = data.ReadUint64();
+ uint64_t transNum = data.ReadUint64();
+ int32_t srcType = data.ReadInt32();
+ int32_t dstType = data.ReadInt32();
+ std::vector buffer;
+ data.ReadUInt8Vector(&buffer);
+ std::shared_ptr msg = std::make_shared(buffer);
+ int32_t ret = SendData(scheduleId, transNum, srcType, dstType, msg); // Call business function
+ if (!reply.WriteInt32(ret)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteInt32(ret)");
+ return FAIL;
+ }
+ return SUCCESS;
+}
+
+int32_t ExecutorMessengerStub::FinishStub(MessageParcel& data, MessageParcel& reply)
+{
+ uint64_t scheduleId = data.ReadUint64();
+ int32_t srcType = data.ReadInt32();
+ int32_t resultCode = data.ReadInt32();
+
+ std::vector buffer;
+ std::shared_ptr finalResult = std::make_shared();
+ data.ReadUInt8Vector(&buffer);
+ finalResult->Unpack(buffer);
+
+ int32_t ret = Finish(scheduleId, srcType, resultCode, finalResult);
+ if (!reply.WriteInt32(ret)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteInt32(ret)");
+ return FAIL;
+ }
+ return SUCCESS;
+}
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/kitsimpl/src/query_callback_proxy.cpp b/frameworks/kitsimpl/src/query_callback_proxy.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6b9ce47ec522e568484dc159bf61fd8295481483
--- /dev/null
+++ b/frameworks/kitsimpl/src/query_callback_proxy.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include
+#include
+#include "coauth_hilog_wrapper.h"
+#include "query_callback_proxy.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+void QueryCallbackProxy::OnResult(uint32_t resultCode)
+{
+ MessageParcel data;
+ if (!data.WriteUint32(resultCode)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteUint64(scheduleId).");
+ }
+ MessageParcel reply;
+ bool ret = SendRequest(static_cast(IQueryCallback::COAUTH_QUERY_RESULT), data, reply);
+ if (ret) {
+ COAUTH_HILOGI(MODULE_INNERKIT, "ret = %{public}d", ret);
+ }
+}
+
+bool QueryCallbackProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply)
+{
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to get remote.");
+ return false;
+ }
+ MessageOption option(MessageOption::TF_SYNC);
+ int32_t result = remote->SendRequest(code, data, reply, option);
+ if (result != OHOS::NO_ERROR) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to SendRequest.result = %{public}d", result);
+ return false;
+ }
+ return true;
+}
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/kitsimpl/src/query_callback_stub.cpp b/frameworks/kitsimpl/src/query_callback_stub.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fa8bb3d25276e451329ead16c435134eba48d6ea
--- /dev/null
+++ b/frameworks/kitsimpl/src/query_callback_stub.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include
+#include "coauth_hilog_wrapper.h"
+#include "coauth_info_define.h"
+#include "query_callback_stub.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace AuthResPool {
+QueryCallbackStub::QueryCallbackStub(const std::shared_ptr& impl)
+{
+ callback_ = impl;
+}
+
+int32_t QueryCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
+ MessageParcel &reply, MessageOption &option)
+{
+ switch (code) {
+ case static_cast(IQueryCallback::COAUTH_QUERY_RESULT):
+ return OnResultStub(data, reply); // call Stub
+ default:
+ return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
+ }
+}
+
+int32_t QueryCallbackStub::OnResultStub(MessageParcel& data, MessageParcel& reply)
+{
+ uint32_t resultCode = data.ReadUint32();
+ OnResult(resultCode);
+
+ return SUCCESS;
+}
+
+void QueryCallbackStub::OnResult(uint32_t resultCode)
+{
+ if (callback_ == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "callback_ is null");
+ } else {
+ callback_->OnResult(resultCode);
+ }
+}
+} // namespace AuthResPool
+} // namespace UserIAM
+} // namespace OHOS
diff --git a/frameworks/kitsimpl/src/set_prop_callback_proxy.cpp b/frameworks/kitsimpl/src/set_prop_callback_proxy.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..45ca9d7f43f40b5de60e16a46052d625bb6d52ea
--- /dev/null
+++ b/frameworks/kitsimpl/src/set_prop_callback_proxy.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include
+#include
+#include "coauth_hilog_wrapper.h"
+#include "set_prop_callback_proxy.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+void SetPropCallbackProxy::OnResult(uint32_t result, std::vector &extraInfo)
+{
+ MessageParcel data;
+ MessageParcel reply;
+
+ if (!data.WriteUint32(result)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to WriteUint32(result).");
+ }
+
+ if (!data.WriteUInt8Vector(extraInfo)) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "fail to wirte WriteUInt8Vector extraInfo");
+ }
+
+ bool ret = SendRequest(static_cast(ISetPropCallback::ONRESULT), data, reply);
+ if (!ret) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "SendRequest is failed, error code: %d", ret);
+ }
+}
+
+bool SetPropCallbackProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply)
+{
+ sptr remote = Remote();
+ if (remote == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to get remote.");
+ return false;
+ }
+ MessageOption option(MessageOption::TF_SYNC);
+ int32_t result = remote->SendRequest(code, data, reply, option);
+ if (result != OHOS::NO_ERROR) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "failed to SendRequest.result = %{public}d", result);
+ return false;
+ }
+ return true;
+}
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/kitsimpl/src/set_prop_callback_stub.cpp b/frameworks/kitsimpl/src/set_prop_callback_stub.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f614dd8bf6624bf0828136c92d19c26e5a9276de
--- /dev/null
+++ b/frameworks/kitsimpl/src/set_prop_callback_stub.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include
+#include "coauth_hilog_wrapper.h"
+#include "set_prop_callback_stub.h"
+
+namespace OHOS {
+namespace UserIAM {
+namespace CoAuth {
+SetPropCallbackStub::SetPropCallbackStub(const std::shared_ptr& impl)
+{
+ callback_ = impl;
+}
+
+int32_t SetPropCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
+ MessageParcel &reply, MessageOption &option)
+{
+ switch (code) {
+ case static_cast(ISetPropCallback::ONRESULT):
+ return OnResultStub(data, reply);
+ default:
+ return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
+ }
+}
+
+int32_t SetPropCallbackStub::OnResultStub(MessageParcel &data, MessageParcel &reply)
+{
+ uint32_t result = data.ReadUint32();
+ std::vector extraInfo;
+ data.ReadUInt8Vector(&extraInfo);
+
+ OnResult(result, extraInfo);
+
+ return SUCCESS;
+}
+
+void SetPropCallbackStub::OnResult(uint32_t result, std::vector &extraInfo)
+{
+ if (callback_ == nullptr) {
+ COAUTH_HILOGE(MODULE_INNERKIT, "callback is null");
+ } else {
+ callback_->OnResult(result, extraInfo);
+ }
+}
+} // namespace CoAuth
+} // namespace UserIAM
+} // namespace OHOS
\ No newline at end of file
diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn
new file mode 100755
index 0000000000000000000000000000000000000000..ac64308f258284d07e4db0f6fa896d7f5bfece55
--- /dev/null
+++ b/interfaces/innerkits/BUILD.gn
@@ -0,0 +1,74 @@
+# Copyright (c) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//base/useriam/coauth/coauth.gni")
+
+config("coauth_private_config") {
+ include_dirs = [
+ "${coauth_service_path}/include",
+ "//utils/system/safwk/napi/include",
+ "${coauth_frameworks_path}/kitsimpl/include",
+ "//foundation/distributeddatamgr/distributeddatamgr/frameworks/innerkitsimpl/distributeddatafwk/include",
+ ]
+}
+
+config("coauth_public_config") {
+ include_dirs = [ "include",
+ "${coauth_frameworks_path}/kitsimpl/include",
+ ]
+}
+
+ohos_shared_library("coauth_framework") {
+ sources = [
+ "../../frameworks/kitsimpl/src/coauth_proxy.cpp",
+ "../../frameworks/kitsimpl/src/coauth.cpp",
+ "../../frameworks/kitsimpl/src/query_callback_proxy.cpp",
+ "../../frameworks/kitsimpl/src/query_callback_stub.cpp",
+ "../../frameworks/kitsimpl/src/executor_callback_stub.cpp",
+ "../../frameworks/kitsimpl/src/executor_callback_proxy.cpp",
+ "../../interfaces/innerkits/src/auth_attributes.cpp",
+ "../../interfaces/innerkits/src/auth_message.cpp",
+ "../../frameworks/kitsimpl/src/executor_messenger_proxy.cpp",
+ "../../frameworks/kitsimpl/src/executor_messenger_stub.cpp",
+ "../../frameworks/kitsimpl/src/auth_executor_registry.cpp",
+ "../../interfaces/innerkits/src/auth_executor.cpp",
+ "../../frameworks/kitsimpl/src/auth_info.cpp",
+ "../../frameworks/kitsimpl/src/set_prop_callback_proxy.cpp",
+ "../../frameworks/kitsimpl/src/set_prop_callback_stub.cpp",
+ "../../frameworks/kitsimpl/src/coauth_callback_proxy.cpp",
+ "../../frameworks/kitsimpl/src/coauth_callback_stub.cpp",
+ ]
+
+ configs = [
+ "${coauth_utils_path}:utils_config",
+ ":coauth_private_config"
+ ]
+
+ public_configs = [ ":coauth_public_config",
+ "${coauth_utils_path}:utils_config" ]
+
+ deps = [
+ "//utils/native/base:utils",
+ "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/distributeddata:distributeddata_inner",
+ "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/adapter:distributeddata_adapter",
+ ]
+
+ external_deps = [
+ "hiviewdfx_hilog_native:libhilog",
+ "ipc:ipc_core",
+ "safwk:system_ability_fwk",
+ "samgr_standard:samgr_proxy",
+ ]
+
+ part_name = "${coauth_native_part_name}"
+}
diff --git a/interfaces/innerkits/include/auth_attributes.h b/interfaces/innerkits/include/auth_attributes.h
new file mode 100644
index 0000000000000000000000000000000000000000..87bf8ba9544b3361faae6581218a96c4b95fc868
--- /dev/null
+++ b/interfaces/innerkits/include/auth_attributes.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AUTH_ATTRIBUTES_H
+#define AUTH_ATTRIBUTES_H
+
+#include
+#include
+#include
+#include