public static byte[] generateNewDocumentId() { MessageDigest md5; try { md5 = MessageDigest.getInstance("MD5"); } catch (Exception e) { throw new PdfException(PdfException.PdfEncryption, e); } long time = SystemUtil.getTimeBasedSeed(); long mem = SystemUtil.getFreeMemory(); String s = time + "+" + mem + "+" + (seq++); return md5.digest(s.getBytes(StandardCharsets.ISO_8859_1)); }
/** * Creates an instance of the CompareTool. */ public CompareTool() { gsExec = SystemUtil.getPropertyOrEnvironmentVariable("gsExec"); compareExec = SystemUtil.getPropertyOrEnvironmentVariable("compareExec"); }
public void tryProcessNextAsync(Boolean daemon) { long currentTime = SystemUtil.getRelativeTimeMillis(); if (currentTime - lastProcessedTime.get() > waitTime.getTime()) { Thread thread = new Thread() { @Override public void run() { tryProcessNext(); } }; if (daemon != null) { thread.setDaemon((boolean) daemon); } thread.start(); } }
BigInteger nonce = BigInteger.valueOf(SystemUtil.getTimeBasedSeed()); TimeStampRequest request = tsqGenerator.generate(new ASN1ObjectIdentifier(DigestAlgorithms.getAllowedDigest(digestAlgorithm)), imprint, nonce); byte[] requestBytes = request.getEncoded();
public static StringBuilder runProcessAndCollectErrors(String execPath, String params) throws IOException, InterruptedException { List<String> cmdArray = new ArrayList<String>(); cmdArray.add(execPath); Matcher m = Pattern.compile("((?:[^'\\s]|'.+?')+)\\s*").matcher(params); while (m.find()) { cmdArray.add(m.group(1).replace("'", "")); } Process p = Runtime.getRuntime().exec(cmdArray.toArray(new String[cmdArray.size()])); StringBuilder errorsBuilder = printProcessErrorsOutput(p); return errorsBuilder; }
public static boolean runProcessAndWait(String execPath, String params) throws IOException, InterruptedException { List<String> cmdArray = new ArrayList<String>(); cmdArray.add(execPath); Matcher m = Pattern.compile("((?:[^'\\s]|'.+?')+)\\s*").matcher(params); while (m.find()) { cmdArray.add(m.group(1).replace("'", "")); } Process p = Runtime.getRuntime().exec(cmdArray.toArray(new String[cmdArray.size()])); printProcessOutput(p); return p.waitFor() == 0; }
/** * Runs ghostscript to create images of pdfs. * * @param outPath Path to the output folder. * @throws CompareToolExecutionException * @throws IOException * @throws InterruptedException */ private void runGhostScriptImageGeneration(String outPath) throws IOException, InterruptedException { if (!FileUtil.directoryExists(outPath)) { throw new CompareToolExecutionException(cannotOpenOutputDirectory.replace("<filename>", outPdf)); } String currGsParams = gsParams.replace("<outputfile>", outPath + cmpImage).replace("<inputfile>", cmpPdf); if (!SystemUtil.runProcessAndWait(gsExec, currGsParams)) { throw new CompareToolExecutionException(gsFailed.replace("<filename>", cmpPdf)); } currGsParams = gsParams.replace("<outputfile>", outPath + outImage).replace("<inputfile>", outPdf); if (!SystemUtil.runProcessAndWait(gsExec, currGsParams)) { throw new CompareToolExecutionException(gsFailed.replace("<filename>", outPdf)); } }
BigInteger nonce = BigInteger.valueOf(SystemUtil.getTimeBasedSeed()); TimeStampRequest request = tsqGenerator.generate(new ASN1ObjectIdentifier(DigestAlgorithms.getAllowedDigest(digestAlgorithm)), imprint, nonce); byte[] requestBytes = request.getEncoded();
public static StringBuilder runProcessAndCollectErrors(String execPath, String params) throws IOException, InterruptedException { List<String> cmdArray = new ArrayList<String>(); cmdArray.add(execPath); Matcher m = Pattern.compile("((?:[^'\\s]|'.+?')+)\\s*").matcher(params); while (m.find()) { cmdArray.add(m.group(1).replace("'", "")); } Process p = Runtime.getRuntime().exec(cmdArray.toArray(new String[cmdArray.size()])); StringBuilder errorsBuilder = printProcessErrorsOutput(p); return errorsBuilder; }
public static boolean runProcessAndWait(String execPath, String params) throws IOException, InterruptedException { List<String> cmdArray = new ArrayList<String>(); cmdArray.add(execPath); Matcher m = Pattern.compile("((?:[^'\\s]|'.+?')+)\\s*").matcher(params); while (m.find()) { cmdArray.add(m.group(1).replace("'", "")); } Process p = Runtime.getRuntime().exec(cmdArray.toArray(new String[cmdArray.size()])); printProcessOutput(p); return p.waitFor() == 0; }
.replace("<image2>", cmpImageFiles[i].getAbsolutePath()) .replace("<difference>", outPath + differenceImagePrefix + Integer.toString(i + 1) + ".png"); if (!SystemUtil.runProcessAndWait(compareExec, currCompareParams)) differentPagesFail += "\nPlease, examine " + outPath + differenceImagePrefix + Integer.toString(i + 1) + ".png for more details.";
public void tryProcessNext() { long currentTime = SystemUtil.getRelativeTimeMillis(); if (currentTime - lastProcessedTime.get() > waitTime.getTime()) { lastProcessedTime.set(SystemUtil.getRelativeTimeMillis()); V data; synchronized (cache) { data = cache.retrieveNext(); } if (data != null) { boolean successful; synchronized (processLock) { successful = tryProcess(data); } if (successful) { onSuccess(data); } else { synchronized (cache) { cache.put(data); } onFailure(data); } } } }