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