private void handleCustomProcessorJar (InputStream jarFile, CustomProcessorInfo customProcessorInfo, boolean verify) throws NoSuchAlgorithmException, IOException { MessageDigest md = MessageDigest.getInstance("SHA-256"); java.io.File tmpFile; try (DigestInputStream dis = new DigestInputStream(jarFile, md)) { tmpFile = FileUtil.writeInputStreamToTempFile(dis, ".jar"); } customProcessorInfo.setDigest(Hex.encodeHexString(md.digest())); LOG.debug("Digest: {}", customProcessorInfo.getDigest()); if (verify && !verifyCustomProcessorImplFromJar(tmpFile, customProcessorInfo)) { String message = "Custom Processor jar file is missing customProcessorImpl class " + customProcessorInfo.getCustomProcessorImpl(); LOG.debug(message); throw new RuntimeException(message); } Collection<CustomProcessorInfo> customProcessorInfos = this.listCustomProcessorsFromBundleWithFilter(Collections.singletonList(new QueryParam (CustomProcessorInfo.DIGEST, customProcessorInfo.getDigest()))); if (!customProcessorInfos.isEmpty()) { customProcessorInfo.setJarFileName(customProcessorInfos.iterator().next().getJarFileName()); } else { customProcessorInfo.setJarFileName(String.format("custom-processor-%s.jar", UUID.randomUUID().toString())); try (InputStream inputStream = new FileInputStream(tmpFile)) { uploadFileToStorage(inputStream, customProcessorInfo.getJarFileName()); } } }
throw BadRequestException.missingParameter(BUNDLE_JAR_FILE_PARAM_NAME); } else { tmpFile = FileUtil.writeInputStreamToTempFile(bundleJar, ".jar");
File tmpFile; try (DigestInputStream dis = new DigestInputStream(inputStream, md)) { tmpFile = FileUtil.writeInputStreamToTempFile(dis, ".jar");
throw BadRequestException.missingParameter(BUNDLE_JAR_FILE_PARAM_NAME); } else { tmpFile = FileUtil.writeInputStreamToTempFile(bundleJar, ".jar");
throw BadRequestException.missingParameter(BUNDLE_JAR_FILE_PARAM_NAME); } else { tmpFile = FileUtil.writeInputStreamToTempFile(bundleJar, ".jar");