• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025-2025 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.codesigning.exception;
17 
18 import com.ohos.hapsigntool.error.ErrorMsg;
19 
20 /**
21  * CodeSignErrMsg
22  *
23  * @since 2025/01/06
24  */
25 public class CodeSignErrMsg {
26     /**
27      * FILE_FORMAT_UNSUPPORTED_ERROR
28      */
29     public static final ErrorMsg FILE_FORMAT_UNSUPPORTED_ERROR = ErrorMsg.getCodeSignErrBuilder()
30         .addTypeCode("06")
31         .addErrCode("001")
32         .addDescription("Invalid File Format")
33         .addCause("Unsupported file to sign")
34         .addSolution("Support file format: %s")
35         .build();
36 
37     /**
38      * READ_INPUT_STREAM_ERROR
39      */
40     public static final ErrorMsg READ_INPUT_STREAM_ERROR = ErrorMsg.getCodeSignErrBuilder()
41         .addTypeCode("10")
42         .addErrCode("001")
43         .addDescription("Input Stream Read Error")
44         .addCause("Read buffer from input error")
45         .build();
46 
47     /**
48      * CERTIFICATES_CONFIGURE_ERROR
49      */
50     public static final ErrorMsg CERTIFICATES_CONFIGURE_ERROR = ErrorMsg.getCodeSignErrBuilder()
51         .addTypeCode("11")
52         .addErrCode("001")
53         .addDescription("Certificates Error")
54         .addCause("%s")
55         .addSolution("Please check whether the certificate is correct")
56         .build();
57 
58     /**
59      * SIGNATURE_VERIFY_FAILED_ERROR
60      */
61     public static final ErrorMsg SIGNATURE_VERIFY_FAILED_ERROR = ErrorMsg.getCodeSignErrBuilder()
62         .addTypeCode("11")
63         .addErrCode("002")
64         .addDescription("Certificates Error")
65         .addCause("Signing failed")
66         .addSolution("Please check whether the keyAlias is correct")
67         .build();
68 
69     /**
70      * PROFILE_TYPE_UNSUPPORTED_ERROR
71      */
72     public static final ErrorMsg PROFILE_TYPE_UNSUPPORTED_ERROR = ErrorMsg.getCodeSignErrBuilder()
73         .addTypeCode("12")
74         .addErrCode("001")
75         .addDescription("Profile Content Error")
76         .addCause("Unsupported profile type")
77         .addSolution("Value of 'type' in profile file should be debug or release")
78         .build();
79 
80     /**
81      * PROFILE_TYPE_NOT_EXISTED_ERROR
82      */
83     public static final ErrorMsg PROFILE_TYPE_NOT_EXISTED_ERROR = ErrorMsg.getCodeSignErrBuilder()
84         .addTypeCode("12")
85         .addErrCode("001")
86         .addDescription("Profile Content Error")
87         .addCause("'type' not found in profile file")
88         .addSolution("Add 'type' to the profile file")
89         .build();
90 
91     /**
92      * PROFILE_BUNDLE_INFO_NOT_EXISTED_ERROR
93      */
94     public static final ErrorMsg PROFILE_BUNDLE_INFO_NOT_EXISTED_ERROR = ErrorMsg.getCodeSignErrBuilder()
95         .addTypeCode("12")
96         .addErrCode("001")
97         .addDescription("Profile Content Error")
98         .addCause("'bundle-info' not found in profile file")
99         .addSolution("Add 'bundle-info' to the profile file")
100         .build();
101 
102     /**
103      * PROFILE_PLUGIN_ID_NOT_EXISTED_ERROR
104      */
105     public static final ErrorMsg PROFILE_PLUGIN_ID_NOT_EXISTED_ERROR = ErrorMsg.getCodeSignErrBuilder()
106         .addTypeCode("12")
107         .addErrCode("001")
108         .addDescription("Profile Content Error")
109         .addCause("'pluginDistributionIDs' not found in profile file")
110         .addSolution("Add 'pluginDistributionIDs' to the profile file")
111         .build();
112 
113     /**
114      * PROFILE_APPID_VALUE_TYPE_ERROR
115      */
116     public static final ErrorMsg PROFILE_APPID_VALUE_TYPE_ERROR = ErrorMsg.getCodeSignErrBuilder()
117         .addTypeCode("12")
118         .addErrCode("001")
119         .addDescription("Profile Content Error")
120         .addCause("Value type of app-identifier is not string")
121         .addSolution("Value type of app-identifier should be string")
122         .build();
123 
124     /**
125      * PROFILE_PLUGIN_ID_VALUE_TYPE_ERROR
126      */
127     public static final ErrorMsg PROFILE_PLUGIN_ID_VALUE_TYPE_ERROR = ErrorMsg.getCodeSignErrBuilder()
128         .addTypeCode("12")
129         .addErrCode("001")
130         .addDescription("Profile Content Error")
131         .addCause("Value type of pluginDistributionIDs is not string")
132         .addSolution("Value type of pluginDistributionIDs should be string")
133         .build();
134 
135     /**
136      * PROFILE_APPID_VALUE_LENGTH_ERROR
137      */
138     public static final ErrorMsg PROFILE_APPID_VALUE_LENGTH_ERROR = ErrorMsg.getCodeSignErrBuilder()
139         .addTypeCode("12")
140         .addErrCode("001")
141         .addDescription("Profile Content Error")
142         .addCause("Value length of app-identifier is invalid")
143         .addSolution("Modify to a valid app-identifier in profile file")
144         .build();
145 
146     /**
147      * PROFILE_PLUGIN_ID_VALUE_LENGTH_ERROR
148      */
149     public static final ErrorMsg PROFILE_PLUGIN_ID_VALUE_LENGTH_ERROR = ErrorMsg.getCodeSignErrBuilder()
150         .addTypeCode("12")
151         .addErrCode("001")
152         .addDescription("Profile Content Error")
153         .addCause("Value length of pluginDistributionIDs is invalid")
154         .addSolution("Modify to a valid pluginDistributionIDs in profile file")
155         .build();
156 
157     /**
158      * PROFILE_JSON_PARSE_ERROR
159      */
160     public static final ErrorMsg PROFILE_JSON_PARSE_ERROR = ErrorMsg.getCodeSignErrBuilder()
161         .addTypeCode("12")
162         .addErrCode("001")
163         .addDescription("Profile Content Error")
164         .addCause("Profile json content is invalid")
165         .addSolution("Please check whether the profile file is correct")
166         .build();
167 
168     /**
169      * MODULE_JSON_PARSE_ERROR
170      */
171     public static final ErrorMsg MODULE_JSON_PARSE_ERROR = ErrorMsg.getCodeSignErrBuilder()
172         .addTypeCode("12")
173         .addErrCode("002")
174         .addDescription("module.json Content Error")
175         .addCause("module.json content is invalid")
176         .addSolution("Please check whether the module.json is correct")
177         .build();
178 
179     /**
180      * HNP_FILE_DESCRIPTION_ERROR
181      */
182     public static final ErrorMsg HNP_FILE_DESCRIPTION_ERROR = ErrorMsg.getCodeSignErrBuilder()
183         .addTypeCode("12")
184         .addErrCode("002")
185         .addDescription("module.json Content Error")
186         .addCause("Hnp {%s} is not described in module.json")
187         .addSolution("Hnp file should be described in module.json")
188         .build();
189 
190     /**
191      * ELF_FILE_HEADER_ERROR
192      */
193     public static final ErrorMsg ELF_FILE_HEADER_ERROR = ErrorMsg.getCodeSignErrBuilder()
194         .addTypeCode("12")
195         .addErrCode("003")
196         .addDescription("Elf File Error")
197         .addCause("ELF {%s} is incorrect")
198         .addSolution("Failed to read the elf file, please check whether the file header information is correct")
199         .build();
200 
201     /**
202      * EXTRACT_HNP_FILE_ERROR
203      */
204     public static final ErrorMsg EXTRACT_HNP_FILE_ERROR = ErrorMsg.getCodeSignErrBuilder()
205         .addTypeCode("12")
206         .addErrCode("004")
207         .addDescription("File Format Error")
208         .addCause("Extract hnp file {%s} error")
209         .addSolution("Check whether the hnp file is packaged correctly")
210         .build();
211 
212     /**
213      * DIGEST_ALGORITHM_ERROR
214      */
215     public static final ErrorMsg ALGORITHM_NOT_SUPPORT_ERROR = ErrorMsg.getCodeSignErrBuilder()
216         .addTypeCode("13")
217         .addErrCode("001")
218         .addDescription("Digest Algorithm Error")
219         .addCause("Invalid algorithm {%s}")
220         .addSolution("Support SHA-256 and SHA-512, if an error occurs, please check the JDK version")
221         .build();
222 
223     /**
224      * CODE_SIGN_INTERNAL_ERROR
225      */
226     public static final ErrorMsg CODE_SIGN_INTERNAL_ERROR = ErrorMsg.getCodeSignErrBuilder()
227         .addTypeCode("14")
228         .addErrCode("001")
229         .addDescription("Code Sign Internal Error")
230         .addCause("%s")
231         .build();
232 
233     /**
234      * FILE_4K_ALIGNMENT_ERROR
235      */
236     public static final ErrorMsg FILE_4K_ALIGNMENT_ERROR = ErrorMsg.getCodeSignErrBuilder()
237         .addTypeCode("14")
238         .addErrCode("001")
239         .addDescription("Code Sign Internal Error")
240         .addCause("Invalid data size {%d}, not a multiple of 4096")
241         .build();
242 
243     /**
244      * PAGE_INFO_UNIT_SIZE_ERROR
245      */
246     public static final ErrorMsg PAGE_INFO_ERROR = ErrorMsg.getCodeSignErrBuilder()
247         .addTypeCode("14")
248         .addErrCode("001")
249         .addDescription("Code Sign Internal Error")
250         .addCause("Page Info Error : %s")
251         .build();
252 }
253