• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef DLP_CREDENTIAL_H
17 #define DLP_CREDENTIAL_H
18 
19 #include <string>
20 #include <vector>
21 #include "application_info.h"
22 #include "bundle_constants.h"
23 #include "cert_parcel.h"
24 #include "idlp_permission_callback.h"
25 #include "permission_policy.h"
26 
27 namespace OHOS {
28 namespace Security {
29 namespace DlpPermission {
30 typedef struct RequestInfo {
31     sptr<IDlpPermissionCallback> callback = nullptr;
32     DlpAccountType accountType = INVALID_ACCOUNT;
33     std::string appProvisionType = AppExecFwk::Constants::APP_PROVISION_TYPE_RELEASE;
34 } RequestInfo;
35 
36 class DlpCredential {
37 public:
38     ~DlpCredential();
39     static DlpCredential& GetInstance();
40     int32_t GenerateDlpCertificate(
41         const std::string& policy, const std::string& accountInfo, DlpAccountType accountType,
42         const sptr<IDlpPermissionCallback>& callback);
43     int32_t ParseDlpCertificate(const sptr<CertParcel>& certParcel, const sptr<IDlpPermissionCallback>& callback,
44         const std::string& appId, bool offlineAccess, AppExecFwk::ApplicationInfo& applicationInfo);
45     int32_t SetMDMPolicy(const std::vector<std::string>& appIdList);
46     int32_t GetMDMPolicy(std::vector<std::string>& appIdList);
47     int32_t RemoveMDMPolicy();
48     int32_t CheckMdmPermission(const std::string& bundleName, int32_t userId);
49 private:
50     DlpCredential();
51     DISALLOW_COPY_AND_MOVE(DlpCredential);
52 };
53 }  // namespace DlpPermission
54 }  // namespace Security
55 }  // namespace OHOS
56 #endif  // DLP_CREDENTIAL_H
57