diff --git a/hapsigntool/hap_sign_tool/src/main/java/com/ohos/hapsigntool/HapSignTool.java b/hapsigntool/hap_sign_tool/src/main/java/com/ohos/hapsigntool/HapSignTool.java index 2511c8befbd8f763913dd5beeeeb3b6db554fbe5..fc67b929f1f2ef83d6cd04729973042fed6147ba 100644 --- a/hapsigntool/hap_sign_tool/src/main/java/com/ohos/hapsigntool/HapSignTool.java +++ b/hapsigntool/hap_sign_tool/src/main/java/com/ohos/hapsigntool/HapSignTool.java @@ -57,11 +57,11 @@ public final class HapSignTool { /** * Signed. */ - private static final int SIGNED = 1; + private static final String SIGNED = "1"; /** * No signed. */ - private static final int NOT_SIGNED = 0; + private static final String NOT_SIGNED = "0"; private HapSignTool() { } @@ -269,11 +269,16 @@ public final class HapSignTool { } String profileFile = params.getString(Options.PROFILE_FILE); - FileUtils.validFileType(profileFile, "p7b"); - int profileSigned = params.getInt(Options.PROFILE_SIGNED, SIGNED); - if (profileSigned != SIGNED && profileSigned != NOT_SIGNED) { + String profileSigned = params.getString(Options.PROFILE_SIGNED,SIGNED); + if (!SIGNED.equals(profileSigned) && !NOT_SIGNED.equals(profileSigned)) { CustomException.throwException(ERROR.NOT_SUPPORT_ERROR, "profileSigned params is incorrect"); } + if (SIGNED.equals(profileSigned)) { + FileUtils.validFileType(profileFile, "p7b"); + } else { + FileUtils.validFileType(profileFile, "json"); + } + String inForm = params.getString(Options.IN_FORM); if (!StringUtils.isEmpty(inForm) && !"zip".equalsIgnoreCase(inForm) && !"bin".equalsIgnoreCase(inForm)) { CustomException.throwException(ERROR.NOT_SUPPORT_ERROR, "inForm params is incorrect"); diff --git a/hapsigntool/hap_sign_tool_lib/src/main/java/com/ohos/hapsigntool/hap/provider/SignProvider.java b/hapsigntool/hap_sign_tool_lib/src/main/java/com/ohos/hapsigntool/hap/provider/SignProvider.java index e041bec5b409ac957206b59e69f57292e47d336f..fd076150f8aa8340b5aba2369771eafacae911ae 100644 --- a/hapsigntool/hap_sign_tool_lib/src/main/java/com/ohos/hapsigntool/hap/provider/SignProvider.java +++ b/hapsigntool/hap_sign_tool_lib/src/main/java/com/ohos/hapsigntool/hap/provider/SignProvider.java @@ -205,27 +205,6 @@ public abstract class SignProvider { return signerConfig; } - /** - * check profile signed in bin signed - * - * @param options inputted by user. - * @throws MissingParamsException Exception occurs when the required parameters are not entered. - */ - private void checkLiteParams(Options options) throws MissingParamsException { - String[] paramFileds = {ParamConstants.PARAM_BASIC_PROFILE_SIGNED}; - Set paramSet = ParamProcessUtil.initParamField(paramFileds); - - for (String paramKey : options.keySet()) { - if (paramSet.contains(paramKey)) { - signParams.put(paramKey, options.getString(paramKey)); - } - } - - if (!signParams.containsKey(ParamConstants.PARAM_BASIC_PROFILE_SIGNED)) { - signParams.put(ParamConstants.PARAM_BASIC_PROFILE_SIGNED, "1"); - } - } - /** * sign bin file * @@ -240,8 +219,6 @@ public abstract class SignProvider { // 1. check the parameters checkParams(options); - checkLiteParams(options); - // 2. load optionalBlocks loadOptionalBlocks(); @@ -615,7 +592,8 @@ public abstract class SignProvider { ParamConstants.PARAM_BASIC_PROFILE, ParamConstants.PARAM_BASIC_PROOF, ParamConstants.PARAM_BASIC_PROPERTY, - ParamConstants.PARAM_REMOTE_SERVER + ParamConstants.PARAM_REMOTE_SERVER, + ParamConstants.PARAM_BASIC_PROFILE_SIGNED }; Set paramSet = ParamProcessUtil.initParamField(paramFileds); @@ -624,7 +602,9 @@ public abstract class SignProvider { signParams.put(paramKey, getParamValue(paramKey, options.getString(paramKey))); } } - + if (!signParams.containsKey(ParamConstants.PARAM_BASIC_PROFILE_SIGNED)) { + signParams.put(ParamConstants.PARAM_BASIC_PROFILE_SIGNED, "1"); + } checkPrivateKeyPath(); checkSignatureAlg(); checkInputFile();