• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2024 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.entity;
17 
18 import com.ohos.hapsigntool.entity.Options;
19 import com.ohos.hapsigntool.error.ParamException;
20 
21 /**
22  * SignProfileParameters.
23  *
24  * @since 2024/04/06
25  */
26 public class SignProfileParameters implements Parameters {
27     /**
28      * signature mode, required fields, including localSign/remoteSign
29      */
30     private Mode mode;
31 
32     /**
33      * key alias, required fields
34      */
35     private String keyAlias;
36 
37     /**
38      * key password, optional fields on localSign mode
39      */
40     private char[] keyPwd;
41 
42     /**
43      * profile signing certificate, required fields
44      */
45     private String profileCertFile;
46 
47     /**
48      * input original profile file, required fields
49      */
50     private String inFile;
51 
52     /**
53      * signature algorithm, required fields
54      */
55     private String signAlg;
56 
57     /**
58      * keystore file, if signature mode is localSign, required fields on localSign mode, JKS or P12 format
59      */
60     private String keyStoreFile;
61 
62     /**
63      * keystore password, optional fields on localSign mode
64      */
65     private char[] keystorePwd;
66 
67     /**
68      * output the signed Provision Profile file, required fields
69      */
70     private String outFile;
71 
72     @Override
toOptions()73     public Options toOptions() throws ParamException {
74         Options options = new Options();
75         if (mode == null) {
76             throw new ParamException(Options.MODE);
77         }
78         options.put(Options.MODE, mode.getValue());
79 
80         if (keyAlias == null) {
81             throw new ParamException(Options.KEY_ALIAS);
82         }
83         options.put(Options.KEY_ALIAS, keyAlias);
84 
85         if (keyPwd != null) {
86             options.put(Options.KEY_RIGHTS, keyPwd);
87         }
88 
89         if (profileCertFile == null) {
90             throw new ParamException(Options.PROFILE_CERT_FILE);
91         }
92         options.put(Options.PROFILE_CERT_FILE, profileCertFile);
93 
94         if (inFile == null) {
95             throw new ParamException(Options.IN_FILE);
96         }
97         options.put(Options.IN_FILE, inFile);
98 
99         if (signAlg == null) {
100             throw new ParamException(Options.SIGN_ALG);
101         }
102         options.put(Options.SIGN_ALG, signAlg);
103 
104         if (keyStoreFile == null) {
105             throw new ParamException(Options.KEY_STORE_FILE);
106         }
107         options.put(Options.KEY_STORE_FILE, keyStoreFile);
108 
109         if (keystorePwd != null) {
110             options.put(Options.KEY_STORE_RIGHTS, keystorePwd);
111         }
112 
113         if (outFile == null) {
114             throw new ParamException(Options.OUT_FILE);
115         }
116         options.put(Options.OUT_FILE, outFile);
117         return options;
118     }
119 
getMode()120     public Mode getMode() {
121         return mode;
122     }
123 
setMode(Mode mode)124     public void setMode(Mode mode) {
125         this.mode = mode;
126     }
127 
getKeyAlias()128     public String getKeyAlias() {
129         return keyAlias;
130     }
131 
setKeyAlias(String keyAlias)132     public void setKeyAlias(String keyAlias) {
133         this.keyAlias = keyAlias;
134     }
135 
getKeyPwd()136     public char[] getKeyPwd() {
137         return keyPwd;
138     }
139 
setKeyPwd(char[] keyPwd)140     public void setKeyPwd(char[] keyPwd) {
141         this.keyPwd = keyPwd;
142     }
143 
getProfileCertFile()144     public String getProfileCertFile() {
145         return profileCertFile;
146     }
147 
setProfileCertFile(String profileCertFile)148     public void setProfileCertFile(String profileCertFile) {
149         this.profileCertFile = profileCertFile;
150     }
151 
getInFile()152     public String getInFile() {
153         return inFile;
154     }
155 
setInFile(String inFile)156     public void setInFile(String inFile) {
157         this.inFile = inFile;
158     }
159 
getSignAlg()160     public String getSignAlg() {
161         return signAlg;
162     }
163 
setSignAlg(String signAlg)164     public void setSignAlg(String signAlg) {
165         this.signAlg = signAlg;
166     }
167 
getKeyStoreFile()168     public String getKeyStoreFile() {
169         return keyStoreFile;
170     }
171 
setKeyStoreFile(String keyStoreFile)172     public void setKeyStoreFile(String keyStoreFile) {
173         this.keyStoreFile = keyStoreFile;
174     }
175 
getKeystorePwd()176     public char[] getKeystorePwd() {
177         return keystorePwd;
178     }
179 
setKeystorePwd(char[] keystorePwd)180     public void setKeystorePwd(char[] keystorePwd) {
181         this.keystorePwd = keystorePwd;
182     }
183 
getOutFile()184     public String getOutFile() {
185         return outFile;
186     }
187 
setOutFile(String outFile)188     public void setOutFile(String outFile) {
189         this.outFile = outFile;
190     }
191 }
192