From c2b94e353bc398d847e25c28ff2210cbc59b6cbe Mon Sep 17 00:00:00 2001 From: Tobias Kellner Date: Tue, 20 Oct 2015 17:26:18 +0200 Subject: Move JettyTempCleaner to own module, create signed jar --- BKUWebStart/pom.xml | 7 +- BKUWebStart/src/main/java/JettyTempCleaner.java | 57 ------- .../java/at/gv/egiz/bku/webstart/Container.java | 15 +- JettyTempCleaner/pom.xml | 173 +++++++++++++++++++++ .../src/main/java/JettyTempCleaner.java | 57 +++++++ pom.xml | 1 + 6 files changed, 245 insertions(+), 65 deletions(-) delete mode 100644 BKUWebStart/src/main/java/JettyTempCleaner.java create mode 100644 JettyTempCleaner/pom.xml create mode 100644 JettyTempCleaner/src/main/java/JettyTempCleaner.java diff --git a/BKUWebStart/pom.xml b/BKUWebStart/pom.xml index d4ff8cb6..0889071b 100644 --- a/BKUWebStart/pom.xml +++ b/BKUWebStart/pom.xml @@ -29,7 +29,7 @@ copy-dependencies - BKULocal + BKULocal,JettyTempCleaner at.gv.egiz ${project.build.directory}/classes true @@ -343,6 +343,11 @@ at.gv.egiz BKUCertificates + + at.gv.egiz + JettyTempCleaner + ${project.version} + iaik iaik_jce_full_signed diff --git a/BKUWebStart/src/main/java/JettyTempCleaner.java b/BKUWebStart/src/main/java/JettyTempCleaner.java deleted file mode 100644 index 67854ecb..00000000 --- a/BKUWebStart/src/main/java/JettyTempCleaner.java +++ /dev/null @@ -1,57 +0,0 @@ -import java.io.File; -import java.util.Timer; -import java.util.TimerTask; - -public class JettyTempCleaner extends TimerTask { - - private static final long CLEAN_INTERVAL = 60000; // 1 minute - - private File tmpDir; - - public JettyTempCleaner(File tmpDir) { - this.tmpDir = tmpDir; - } - - private static boolean deleteRecursive(File f) { - if (f.isDirectory()) { - String[] children = f.list(); - for (String child : children) { - if (!deleteRecursive(new File(f, child))) - return false; - } - } - return f.delete(); - } - - private static void clean(File tmpDir) { - System.out.println("Trying to remove " + tmpDir); - if (deleteRecursive(tmpDir)) { - System.out.println("Successfully removed temporary directory"); - System.exit(0); - } - } - - private void schedule() { - System.out.println("Scheduling cleaner for directory " + tmpDir); - Timer t = new Timer(); - t.scheduleAtFixedRate(this, 1000, CLEAN_INTERVAL); - } - - @Override - public void run() { - clean(tmpDir); - } - - public static void main(String[] args) { - if (args.length != 1) - System.exit(1); - File tmpDir = new File(args[0]); - if (!tmpDir.exists()) - { - System.err.println("Directory " + args[0] + " doesn't exist"); - System.exit(2); - } - JettyTempCleaner cleaner = new JettyTempCleaner(tmpDir); - cleaner.schedule(); - } -} diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Container.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Container.java index 9eaa13b2..19adf571 100644 --- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Container.java +++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Container.java @@ -57,7 +57,7 @@ public class Container { public static final String HTTP_PORT_PROPERTY = "mocca.http.port"; public static final String HTTPS_PORT_PROPERTY = "mocca.https.port"; - private static final String JETTY_TEMP_CLEANER_CLASSNAME = "JettyTempCleaner"; + private static final String JETTY_TEMP_CLEANER_JAR = "JettyTempCleaner.jar"; private static Logger log = LoggerFactory.getLogger(Container.class); @@ -176,11 +176,11 @@ public class Container { } private void copyCleaner(File dir) throws IOException { - File cleanerClass = new File(dir, JETTY_TEMP_CLEANER_CLASSNAME + ".class"); - log.debug("copying JettyTempCleaner to " + cleanerClass); - InputStream is = getClass().getClassLoader().getResourceAsStream(JETTY_TEMP_CLEANER_CLASSNAME + ".class"); + File cleanerJar = new File(dir, JETTY_TEMP_CLEANER_JAR); + log.debug("copying JettyTempCleaner to " + cleanerJar); + InputStream is = getClass().getClassLoader().getResourceAsStream(JETTY_TEMP_CLEANER_JAR); OutputStream os; - os = new BufferedOutputStream(new FileOutputStream(cleanerClass)); + os = new BufferedOutputStream(new FileOutputStream(cleanerJar)); new StreamCopier(is, os).copyStream(); os.close(); } @@ -198,11 +198,12 @@ public class Container { copyCleaner(userDir); List args = new ArrayList(); args.add("java"); - args.add(JETTY_TEMP_CLEANER_CLASSNAME); + args.add("-jar"); + args.add(JETTY_TEMP_CLEANER_JAR); args.add(tempDir.getAbsolutePath()); ProcessBuilder pb = new ProcessBuilder(args); pb.directory(userDir); - log.debug("Starting " + JETTY_TEMP_CLEANER_CLASSNAME + " to remove " + tempDir.getAbsolutePath()); + log.debug("Starting " + JETTY_TEMP_CLEANER_JAR + " to remove " + tempDir.getAbsolutePath()); pb.start(); } catch (IOException e) { log.error("Failed to copy jetty temp cleaner", e); diff --git a/JettyTempCleaner/pom.xml b/JettyTempCleaner/pom.xml new file mode 100644 index 00000000..8924fb0d --- /dev/null +++ b/JettyTempCleaner/pom.xml @@ -0,0 +1,173 @@ + + 4.0.0 + + at.gv.egiz + mocca + 1.3.21-SNAPSHOT + + JettyTempCleaner + Jetty Temp Cleaner + http://joinup.ec.europa.eu/site/mocca/ + Clean Jetty temp dir under windows after MOCCA webstart finishes + + + + buildnumber-maven-plugin + org.codehaus.mojo + + + validate + + create + + + + + false + false + SvnRevMissing + + + + maven-jar-plugin + org.apache.maven.plugins + + + + sign + + + + + + + false + false + + false + true + JettyTempCleaner + + + JettyTempCleaner + ${project.version}-r${buildNumber} + all-permissions + * + * + true + + + test-applet signer + ../BKUApplet/keystore.ks + storepass + keypass + true + + + + + + + pkcs11-sign + + + + maven-jar-plugin + org.apache.maven.plugins + 2.2-mocca + + NONE + PKCS11 + iaik.pkcs.pkcs11.provider.IAIKPkcs11 + a-sit-2 + ${pkcs11-pass} + + + + + + + ks-sign + + + + maven-jar-plugin + org.apache.maven.plugins + 2.2-mocca + + ${ks-file} + a-sit-3 + ${ks-pass} + ${ks-pass} + + + + + + + + buildnumber-git + + + .svn + + + + + + org.codehaus.groovy.maven + gmaven-plugin + 1.0 + + + generate-resources + + execute + + + + def shell = "sh" + def param = "-c" + if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")) { + shell = "cmd" + param = "/c" + } + def gitSvnProc = [shell, param, "git rev-parse --short HEAD"].execute() + gitSvnProc.waitFor() + def svnref = gitSvnProc.in.text.trim() + project.properties['gitSvnRev'] = svnref + + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + + + generate-resources + + create + + + + + false + false + {0} + + ${gitSvnRev} + + + + + + + + diff --git a/JettyTempCleaner/src/main/java/JettyTempCleaner.java b/JettyTempCleaner/src/main/java/JettyTempCleaner.java new file mode 100644 index 00000000..67854ecb --- /dev/null +++ b/JettyTempCleaner/src/main/java/JettyTempCleaner.java @@ -0,0 +1,57 @@ +import java.io.File; +import java.util.Timer; +import java.util.TimerTask; + +public class JettyTempCleaner extends TimerTask { + + private static final long CLEAN_INTERVAL = 60000; // 1 minute + + private File tmpDir; + + public JettyTempCleaner(File tmpDir) { + this.tmpDir = tmpDir; + } + + private static boolean deleteRecursive(File f) { + if (f.isDirectory()) { + String[] children = f.list(); + for (String child : children) { + if (!deleteRecursive(new File(f, child))) + return false; + } + } + return f.delete(); + } + + private static void clean(File tmpDir) { + System.out.println("Trying to remove " + tmpDir); + if (deleteRecursive(tmpDir)) { + System.out.println("Successfully removed temporary directory"); + System.exit(0); + } + } + + private void schedule() { + System.out.println("Scheduling cleaner for directory " + tmpDir); + Timer t = new Timer(); + t.scheduleAtFixedRate(this, 1000, CLEAN_INTERVAL); + } + + @Override + public void run() { + clean(tmpDir); + } + + public static void main(String[] args) { + if (args.length != 1) + System.exit(1); + File tmpDir = new File(args[0]); + if (!tmpDir.exists()) + { + System.err.println("Directory " + args[0] + " doesn't exist"); + System.exit(2); + } + JettyTempCleaner cleaner = new JettyTempCleaner(tmpDir); + cleaner.schedule(); + } +} diff --git a/pom.xml b/pom.xml index 2974df41..543858ca 100644 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,7 @@ BKUGuiExt smccSTALExt BKUFonts + JettyTempCleaner 2007 -- cgit v1.2.3