diff --git a/dist/hap-sign-tool.jar b/dist/hap-sign-tool.jar index c0e24c5f5ff39350e7629e08702b305dc55d83e0..00161be3a932fd1b2d3d02b4ebe35750e811a7db 100644 Binary files a/dist/hap-sign-tool.jar and b/dist/hap-sign-tool.jar differ diff --git a/hapsigntool/hap_sign_tool_lib/src/main/java/com/ohos/hapsigntool/signer/SignerFactory.java b/hapsigntool/hap_sign_tool_lib/src/main/java/com/ohos/hapsigntool/signer/SignerFactory.java index 80c701e37e7e1500a246d891839f8628f9e3dd29..0cf9050b55c583ad3d29d81d997a1f4de7a753ac 100644 --- a/hapsigntool/hap_sign_tool_lib/src/main/java/com/ohos/hapsigntool/signer/SignerFactory.java +++ b/hapsigntool/hap_sign_tool_lib/src/main/java/com/ohos/hapsigntool/signer/SignerFactory.java @@ -19,6 +19,7 @@ import com.ohos.hapsigntool.api.LocalizationAdapter; import com.ohos.hapsigntool.error.CustomException; import com.ohos.hapsigntool.error.ERROR; import com.ohos.hapsigntool.utils.StringUtils; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -32,6 +33,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.net.URLDecoder; +import java.net.URLEncoder; import java.security.KeyPair; import java.util.HashMap; import java.util.Map; @@ -74,8 +76,19 @@ public class SignerFactory { LOGGER.warn("lost parameter signerPlugin"); return Optional.empty(); } - File classLocation = getClassLocation(); - File plugin = new File(classLocation, signerPlugin); + + File plugin = new File(signerPlugin); + if (!plugin.exists()) { + File classLocation = getClassLocation(); + plugin = new File(classLocation, signerPlugin); + } + + try { + LOGGER.info("try to find plugin by path {}", plugin.getCanonicalPath()); + } catch (IOException e) { + LOGGER.warn("can not find signerPlugin by param signerPlugin = {}", signerPlugin); + return Optional.empty(); + } Optional url = fileToUrl(plugin); if (!url.isPresent()) { return Optional.empty(); @@ -127,7 +140,7 @@ public class SignerFactory { CustomException.throwException(ERROR.COMMAND_ERROR, "class path is empty"); } try { - jarPath = URLDecoder.decode(jarPath, "utf-8"); + jarPath = URLDecoder.decode(URLEncoder.encode(jarPath, "utf-8"), "utf-8"); } catch (UnsupportedEncodingException | IllegalArgumentException e) { LOGGER.warn("decode class location failed, will ignored. msg :{}", e.getMessage()); }