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 "i_dlp_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(); ~DlpCredential()39 ~DlpCredential() {}; 40 static DlpCredential& GetInstance(); 41 int32_t GenerateDlpCertificate( 42 const std::string& policy, const std::string& accountInfo, DlpAccountType accountType, 43 const sptr<IDlpPermissionCallback>& callback); 44 int32_t ParseDlpCertificate(sptr<CertParcel>& certParcel, const sptr<IDlpPermissionCallback>& callback, 45 const std::string& appId, const bool& offlineAccess, AppExecFwk::ApplicationInfo& applicationInfo); 46 int32_t SetMDMPolicy(const std::vector<std::string>& appIdList); 47 int32_t GetMDMPolicy(std::vector<std::string>& appIdList); 48 int32_t RemoveMDMPolicy(); 49 int32_t CheckMdmPermission(const std::string& bundleName, int32_t userId); 50 }; 51 } // namespace DlpPermission 52 } // namespace Security 53 } // namespace OHOS 54 #endif // DLP_CREDENTIAL_H 55