From 0876981fd70fdab07f7c3e1666cf77071b5fe03d Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Wed, 2 Oct 2013 10:28:30 +0200 Subject: + added PKCS7 detached siganture standard via keystore + added simple verification implementation --- .../java/at/gv/egiz/pdfas/common/utils/TempFileHelper.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'pdf-as-common/src/main/java/at') diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/TempFileHelper.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/TempFileHelper.java index 611d7a0b..03cd28f3 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/TempFileHelper.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/TempFileHelper.java @@ -27,6 +27,8 @@ public class TempFileHelper implements IProfileConstants { private List tmpFiles = new ArrayList(); + private boolean needsDeletion = false; + public TempFileHelper(ISettings settings) { initializeMD(); @@ -37,9 +39,12 @@ public class TempFileHelper implements IProfileConstants { // relatives tmp dir myTmpDirFile = new File(settings.getWorkingDirectory() + File.separator + myTmpDir); } - tmpDir = myTmpDirFile.getAbsolutePath(); + tmpDir = myTmpDirFile.getAbsolutePath() + File.separator; } else { - tmpDir = settings.getWorkingDirectory() + File.separator + TMP_DIR_DEFAULT_VALUE; + String uuidString = UUID.randomUUID().toString(); + logger.debug("Generated UUID " + uuidString); + tmpDir = settings.getWorkingDirectory() + File.separator + TMP_DIR_DEFAULT_VALUE + File.separator + getHashedHexString(uuidString) + File.separator; + needsDeletion = true; } logger.info("TempDirHelper for TempDirectory: " + tmpDir); @@ -66,6 +71,9 @@ public class TempFileHelper implements IProfileConstants { try { File tmpdir = new File(tmpDir); tmpdir.mkdirs(); + if(needsDeletion) { + tmpdir.deleteOnExit(); + } } catch (Throwable e) { logger.error("Failed to create temporary directory: " + tmpDir, e); } @@ -101,7 +109,7 @@ public class TempFileHelper implements IProfileConstants { public String getStaticFilename() { String uuidString = UUID.randomUUID().toString(); logger.debug("Generated UUID " + uuidString); - String tmpFilename = tmpFilePrefix + getHashedHexString(uuidString) + tmpFileSuffix; + String tmpFilename = tmpDir + getHashedHexString(uuidString) + tmpFileSuffix; logger.info("Temporary filename " + tmpFilename); tmpFiles.add(tmpFilename); return tmpFilename; -- cgit v1.2.3