1 /* 2 * Copyright (c) 2021-2022 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 package com.ohos.hapsigntool.profile.model; 17 18 import com.google.gson.annotations.SerializedName; 19 import com.ohos.hapsigntool.error.ERROR; 20 import com.ohos.hapsigntool.utils.ValidateUtils; 21 22 /** 23 * Sub dto of Provision. 24 * 25 * @since 2021/12/28 26 */ 27 public class BundleInfo { 28 /** 29 * Field developer-id. 30 */ 31 @SerializedName("developer-id") 32 private String developerId; 33 34 /** 35 * Field development-certificate. 36 */ 37 @SerializedName("development-certificate") 38 private String developmentCertificate; 39 40 /** 41 * Field distribution-certificate. 42 */ 43 @SerializedName("distribution-certificate") 44 private String distributionCertificate; 45 46 /** 47 * Field bundle-name. 48 */ 49 @SerializedName("bundle-name") 50 private String bundleName; 51 52 /** 53 * Field apl. 54 */ 55 @SerializedName("apl") 56 private String apl; 57 58 /** 59 * Field app-feature. 60 */ 61 @SerializedName("app-feature") 62 private String appFeature; 63 64 /** 65 * Sub dto of Provision. 66 */ BundleInfo()67 public BundleInfo() { 68 // Empty constructor of BundleInfo. 69 } 70 getDeveloperId()71 public String getDeveloperId() { 72 return developerId; 73 } 74 setDeveloperId(String developerId)75 public void setDeveloperId(String developerId) { 76 this.developerId = developerId; 77 } 78 getDevelopmentCertificate()79 public String getDevelopmentCertificate() { 80 return developmentCertificate; 81 } 82 setDevelopmentCertificate(String developmentCertificate)83 public void setDevelopmentCertificate(String developmentCertificate) { 84 this.developmentCertificate = developmentCertificate; 85 } 86 getDistributionCertificate()87 public String getDistributionCertificate() { 88 return distributionCertificate; 89 } 90 setDistributionCertificate(String distributionCertificate)91 public void setDistributionCertificate(String distributionCertificate) { 92 this.distributionCertificate = distributionCertificate; 93 } 94 getBundleName()95 public String getBundleName() { 96 return bundleName; 97 } 98 setBundleName(String bundleName)99 public void setBundleName(String bundleName) { 100 this.bundleName = bundleName; 101 } 102 getApl()103 public String getApl() { 104 return apl; 105 } 106 setApl(String apl)107 public void setApl(String apl) { 108 this.apl = apl; 109 } 110 getAppFeature()111 public String getAppFeature() { 112 return appFeature; 113 } 114 setAppFeature(String appFeature)115 public void setAppFeature(String appFeature) { 116 this.appFeature = appFeature; 117 } 118 119 /** 120 * Enforce valid. 121 * 122 * @param buildType build type 123 */ enforceValid(String buildType)124 public void enforceValid(String buildType) { 125 ValidateUtils.throwIfMatches(this.developerId == null, ERROR.SIGN_ERROR, 126 "Require developerId in bundleInfo!"); 127 if (Provision.isBuildTypeRelease(buildType)) { 128 ValidateUtils.throwIfMatches(this.distributionCertificate == null, 129 ERROR.SIGN_ERROR, "Require cert in bundleInfo!"); 130 } else { 131 ValidateUtils.throwIfMatches(this.developmentCertificate == null, 132 ERROR.SIGN_ERROR, "Require cert in bundleInfo!"); 133 } 134 ValidateUtils.throwIfMatches(this.bundleName == null, ERROR.SIGN_ERROR, 135 "Require bundleName in bundleInfo!"); 136 ValidateUtils.throwIfMatches(this.appFeature == null || Provision.isAppDistTypeValid(this.appFeature), 137 ERROR.SIGN_ERROR, "Require appFeature be hos_system_app or hos_normal_app,curr is :" 138 + this.appFeature + " in bundleInfo!"); 139 } 140 } 141