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 getDeveloperId()69 public String getDeveloperId() { 70 return developerId; 71 } 72 setDeveloperId(String developerId)73 public void setDeveloperId(String developerId) { 74 this.developerId = developerId; 75 } 76 getDevelopmentCertificate()77 public String getDevelopmentCertificate() { 78 return developmentCertificate; 79 } 80 setDevelopmentCertificate(String developmentCertificate)81 public void setDevelopmentCertificate(String developmentCertificate) { 82 this.developmentCertificate = developmentCertificate; 83 } 84 getDistributionCertificate()85 public String getDistributionCertificate() { 86 return distributionCertificate; 87 } 88 setDistributionCertificate(String distributionCertificate)89 public void setDistributionCertificate(String distributionCertificate) { 90 this.distributionCertificate = distributionCertificate; 91 } 92 getBundleName()93 public String getBundleName() { 94 return bundleName; 95 } 96 setBundleName(String bundleName)97 public void setBundleName(String bundleName) { 98 this.bundleName = bundleName; 99 } 100 getApl()101 public String getApl() { 102 return apl; 103 } 104 setApl(String apl)105 public void setApl(String apl) { 106 this.apl = apl; 107 } 108 getAppFeature()109 public String getAppFeature() { 110 return appFeature; 111 } 112 setAppFeature(String appFeature)113 public void setAppFeature(String appFeature) { 114 this.appFeature = appFeature; 115 } 116 117 /** 118 * Enforce valid. 119 * 120 * @param buildType build type 121 */ enforceValid(String buildType)122 public void enforceValid(String buildType) { 123 if (Provision.isBuildTypeRelease(buildType)) { 124 ValidateUtils.throwIfMatches(this.distributionCertificate == null, 125 ERROR.SIGN_ERROR, "Require cert in bundleInfo!"); 126 } else { 127 ValidateUtils.throwIfMatches(this.developmentCertificate == null, 128 ERROR.SIGN_ERROR, "Require cert in bundleInfo!"); 129 } 130 } 131 } 132