summaryrefslogtreecommitdiff
path: root/BKULocalApp
diff options
context:
space:
mode:
Diffstat (limited to 'BKULocalApp')
-rw-r--r--BKULocalApp/pom.xml99
-rw-r--r--BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java218
-rw-r--r--BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/CA.java117
-rw-r--r--BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java81
-rw-r--r--BKULocalApp/src/main/resources/at/gv/egiz/bku/local/defaultConf/template.zipbin24829 -> 0 bytes
-rw-r--r--BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/UIMessages.properties13
-rw-r--r--BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/favicon.pngbin2149 -> 0 bytes
-rw-r--r--BKULocalApp/src/main/resources/log4j.properties16
-rw-r--r--BKULocalApp/src/main/resources/splash.pngbin54978 -> 0 bytes
9 files changed, 0 insertions, 544 deletions
diff --git a/BKULocalApp/pom.xml b/BKULocalApp/pom.xml
deleted file mode 100644
index 7eb78aa9..00000000
--- a/BKULocalApp/pom.xml
+++ /dev/null
@@ -1,99 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>bku</artifactId>
- <groupId>at.gv.egiz</groupId>
- <version>1.1.2-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>at.gv.egiz</groupId>
- <artifactId>BKULocalApp</artifactId>
- <name>BKU Local App</name>
- <version>1.0.5-SNAPSHOT</version>
- <description />
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <groupId>org.apache.maven.plugins</groupId>
- <version>2.0.2</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- <verbose>true</verbose>
- <showWarnings>true</showWarnings>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <mainClass>at.gv.egiz.bku.local.app.BKULauncher</mainClass>
- </manifest>
- <manifestEntries>
- <mode>development</mode>
- <url>${pom.url}</url>
- <SplashScreen-Image>splash.png</SplashScreen-Image>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>package</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
-
-
- </build>
- <dependencies>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>at.gv.egiz</groupId>
- <artifactId>BKULocal</artifactId>
- <version>1.0.5-SNAPSHOT</version>
- <type>war</type>
- </dependency>
- <dependency>
- <artifactId>utils</artifactId>
- <groupId>at.gv.egiz</groupId>
- <version>1.1.2-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>6.1.15</version>
- </dependency>
- </dependencies>
-</project> \ No newline at end of file
diff --git a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java
deleted file mode 100644
index 213114d0..00000000
--- a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java
+++ /dev/null
@@ -1,218 +0,0 @@
-package at.gv.egiz.bku.local.app;
-
-import java.awt.SplashScreen;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.KeyStore;
-import java.util.Enumeration;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.utils.StreamUtil;
-
-public class BKULauncher implements BKUControllerInterface {
- private static Log log = LogFactory.getLog(BKULauncher.class);
-
- private ResourceBundle resourceBundle = null;
- private Container server;
- private SplashScreen splash = SplashScreen.getSplashScreen();
-
- private void startUpServer() throws Exception {
- server = new Container();
- // XmlConfiguration xcfg = new XmlConfiguration(getClass().getClassLoader()
- // .getResourceAsStream("at/gv/egiz/bku/local/app/jetty.xml"));
- // xcfg.configure(server);
- server.init();
- server.start();
- }
-
- private void initTrayIcon() {
- Locale loc = Locale.getDefault();
- try {
- resourceBundle = ResourceBundle.getBundle(
- "at/gv/egiz/bku/local/ui/UIMessages", loc);
- } catch (MissingResourceException mx) {
- resourceBundle = ResourceBundle.getBundle(
- "at/gv/egiz/bku/local/ui/UIMessages", Locale.ENGLISH);
- }
- TrayIconDialog.getInstance().init(resourceBundle);
- TrayIconDialog.getInstance().setShutdownHook(this);
- TrayIconDialog.getInstance().displayInfo("Greetings.Caption",
- "Greetings.Message");
- }
-
- private void initStart() {
-
- }
-
- private void initFinished() {
- try {
- if (splash != null) {
- try {
- splash.close();
- } catch (IllegalStateException ex) {
- log.warn("Failed to close splash screen: " + ex.getMessage());
- }
- }
- server.join();
- } catch (InterruptedException e) {
- log.info(e);
- }
- }
-
- private void copyDirs(File srcDir, File dstDir) {
- for (File cf : srcDir.listFiles()) {
- File of = new File(dstDir, cf.getName());
- if (cf.isDirectory()) {
- log.debug("Creating directory: " + of);
- of.mkdir();
- copyDirs(cf, of);
- } else {
- log.debug("Writing file: " + of);
- try {
- FileInputStream fis = new FileInputStream(cf);
- FileOutputStream fos = new FileOutputStream(of);
- StreamUtil.copyStream(fis, fos);
- fis.close();
- fos.close();
- } catch (IOException e) {
- log.error("Cannot copy default configuration", e);
- }
- }
- }
- }
-
- private void unzip(File zipfile) throws IOException {
- File dir = zipfile.getParentFile();
- ZipFile zipFile = new ZipFile(zipfile);
- Enumeration<? extends ZipEntry> entries = zipFile.entries();
- while (entries.hasMoreElements()) {
- ZipEntry entry = entries.nextElement();
- File eF = new File(dir, entry.getName());
- if (entry.isDirectory()) {
- eF.mkdirs();
- continue;
- }
- File f = new File(eF.getParent());
- f.mkdirs();
- StreamUtil.copyStream(zipFile.getInputStream(entry),
- new FileOutputStream(eF));
- }
- zipFile.close();
- }
-
- private void checkConfig(String[] args) {
- CommandLineParser parser = new PosixParser();
- Options options = new Options();
- options.addOption("c", true, "the configuration's base directory");
- options.addOption("h", false, "print this message");
- try {
- File cfgDir = new File(System.getProperty("user.home") + "/.mocca/conf");
- CommandLine cmd = parser.parse(options, args);
- if (cmd.hasOption("h")) {
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("BKULauncher", options);
- System.exit(0);
- }
-
- if (cmd.hasOption("c")) {
- cfgDir = new File(cmd.getOptionValue("c"));
- }
- log.debug("using config directory: " + cfgDir);
- if (cfgDir.exists() && cfgDir.isFile()) {
- log.error("Configuration directory must not be a file");
- }
- if (!cfgDir.exists()) {
- log.debug("Creating config directory: " + cfgDir);
- cfgDir.mkdirs();
- try {
- InputStream is = getClass().getClassLoader().getResourceAsStream(
- "at/gv/egiz/bku/local/defaultConf/template.zip");
- OutputStream os = new FileOutputStream(new File(cfgDir,
- "template.zip"));
- StreamUtil.copyStream(is, os);
- os.close();
- unzip(new File(cfgDir, "template.zip"));
- } catch (IOException iox) {
- log.error("Cannot create user directory", iox);
- return;
- }
- CA ca = new CA();
- char[] password = "changeMe".toCharArray();
- KeyStore ks = ca.generateKeyStore(password);
- if (ks != null) {
- File ksdir = new File(cfgDir, "keystore");
- ksdir.mkdirs();
- FileOutputStream fos;
- try {
- fos = new FileOutputStream(new File(ksdir, "keystore.ks"));
- ks.store(fos, password);
- fos.close();
- } catch (Exception e) {
- log.error("Cannot store keystore", e);
- }
- } else {
- log.error("Cannot create ssl certificate");
- }
- }
- } catch (ParseException e1) {
- log.error(e1);
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("BKULauncher", options);
- System.exit(0);
- }
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- try {
- BKULauncher launcher = new BKULauncher();
- launcher.initStart();
- launcher.checkConfig(args);
- launcher.startUpServer();
- launcher.initTrayIcon();
- launcher.initFinished();
- } catch (Exception e) {
- log.fatal("Cannot launch BKU", e);
- System.exit(-1000);
- }
-
- }
-
- public void shutDown() {
- log.info("Shutting down server");
- if ((server != null) && (server.isRunning())) {
- try {
- if (server.isRunning()) {
- server.stop();
- }
- } catch (Exception e) {
- log.debug(e.toString());
- } finally {
- if (server.isRunning()) {
- server.destroy();
- }
- }
- }
- System.exit(0);
- }
-
-}
diff --git a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/CA.java b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/CA.java
deleted file mode 100644
index 31d21ef7..00000000
--- a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/CA.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package at.gv.egiz.bku.local.app;
-
-import iaik.asn1.ObjectID;
-import iaik.asn1.structures.AlgorithmID;
-import iaik.asn1.structures.Name;
-import iaik.x509.X509Certificate;
-import iaik.x509.extensions.BasicConstraints;
-import iaik.x509.extensions.KeyUsage;
-
-import java.math.BigInteger;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.security.GeneralSecurityException;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.KeyStore;
-import java.security.NoSuchAlgorithmException;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.Random;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class CA {
- private final static Log log = LogFactory.getLog(CA.class);
-
- private KeyPair caKeyPair;
- private X509Certificate caCert;
-
- private KeyPair serverKeyPair;
- private X509Certificate serverCert;
-
- public CA() {
- }
-
- private KeyPair generateKeyPair() throws NoSuchAlgorithmException {
- KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
- gen.initialize(2048);
- return gen.generateKeyPair();
- }
-
- private void generateCA() throws GeneralSecurityException {
- log.debug("Generating CA certificate");
- Name subject = new Name();
- subject.addRDN(ObjectID.country, "AT");
- subject.addRDN(ObjectID.organization, "MOCCA");
- subject.addRDN(ObjectID.organizationalUnit, "MOCCA-CA");
-
- caKeyPair = generateKeyPair();
- caCert = new X509Certificate();
- caCert.setSerialNumber(new BigInteger(20, new Random()));
- caCert.setSubjectDN(subject);
- caCert.setPublicKey(caKeyPair.getPublic());
- caCert.setIssuerDN(subject);
-
- caCert.addExtension(new BasicConstraints(true));
- caCert.addExtension(new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign
- | KeyUsage.digitalSignature));
-
- GregorianCalendar date = new GregorianCalendar();
- date.add(Calendar.HOUR_OF_DAY, -1);
- caCert.setValidNotBefore(date.getTime());
- date.add(Calendar.YEAR, 7);
- caCert.setValidNotAfter(date.getTime());
- caCert.sign(AlgorithmID.sha1WithRSAEncryption, caKeyPair.getPrivate());
- log.debug("Successfully signed CA certificate");
- }
-
- private void generateServerCert() throws GeneralSecurityException {
- log.debug("Generating SSL certificate");
- Name subject = new Name();
- subject.addRDN(ObjectID.country, "AT");
- subject.addRDN(ObjectID.organization, "MOCCA");
- try {
- subject.addRDN(ObjectID.commonName, InetAddress.getLocalHost()
- .getHostName());
- } catch (UnknownHostException e) {
- subject.addRDN(ObjectID.commonName, "localhost");
- }
- serverKeyPair = generateKeyPair();
- serverCert = new X509Certificate();
- serverCert.setSerialNumber(new BigInteger(20, new Random()));
- serverCert.setSubjectDN(subject);
- serverCert.setPublicKey(serverKeyPair.getPublic());
- serverCert.setIssuerDN(caCert.getSubjectDN());
-
- serverCert.addExtension(new BasicConstraints(false));
- serverCert.addExtension(new KeyUsage(KeyUsage.keyEncipherment
- | KeyUsage.digitalSignature));
-
- GregorianCalendar date = new GregorianCalendar();
- date.add(Calendar.HOUR_OF_DAY, -1);
- serverCert.setValidNotBefore(date.getTime());
- date.add(Calendar.YEAR, 7);
- date.add(Calendar.HOUR_OF_DAY, -1);
- serverCert.setValidNotAfter(date.getTime());
- serverCert.sign(AlgorithmID.sha1WithRSAEncryption, caKeyPair.getPrivate());
- log.debug("Successfully signed server certificate");
- caKeyPair = null;
- }
-
- public KeyStore generateKeyStore(char[] password) {
- try {
- generateCA();
- generateServerCert();
- KeyStore ks = KeyStore.getInstance("JKS");
- ks.load(null, null);
- ks.setKeyEntry("server", serverKeyPair.getPrivate(), password, new X509Certificate[]{serverCert, caCert});
- return ks;
- } catch (Exception e) {
- log.error("Cannot generate certificate", e);
- }
- return null;
- }
-
-}
diff --git a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java
deleted file mode 100644
index 8e3c3a6a..00000000
--- a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package at.gv.egiz.bku.local.app;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.DefaultHandler;
-import org.mortbay.jetty.handler.HandlerCollection;
-import org.mortbay.jetty.nio.SelectChannelConnector;
-import org.mortbay.jetty.security.SslSocketConnector;
-import org.mortbay.jetty.webapp.WebAppContext;
-import org.mortbay.thread.QueuedThreadPool;
-
-public class Container {
-
- private static Log log = LogFactory.getLog(Container.class);
-
- private Server server;
-
- public Container() {
- }
-
- public void init() {
- server = new Server();
- QueuedThreadPool qtp = new QueuedThreadPool();
- qtp.setMaxThreads(5);
- qtp.setMinThreads(2);
- qtp.setLowThreads(0);
- server.setThreadPool(qtp);
- server.setStopAtShutdown(true);
- server.setGracefulShutdown(3000);
-
- SelectChannelConnector connector = new SelectChannelConnector();
- connector.setPort(3495);
- connector.setAcceptors(1);
- connector.setConfidentialPort(3496);
-
- SslSocketConnector sslConnector = new SslSocketConnector();
- sslConnector.setPort(3496);
- sslConnector.setAcceptors(1);
- sslConnector.setKeystore(System.getProperty("user.home")
- + "/.mocca/conf/keystore/keystore.ks");
- sslConnector.setPassword("changeMe");
- sslConnector.setKeyPassword("changeMe");
-
- server.setConnectors(new Connector[] { connector, sslConnector });
- HandlerCollection handlers = new HandlerCollection();
-
- WebAppContext webappcontext = new WebAppContext();
- webappcontext.setContextPath("/");
- webappcontext.setExtractWAR(false);
- System.out.println(getClass().getClassLoader().getResource("log4j.properties"));
- webappcontext.setWar("BKULocal-1.0.4-SNAPSHOT.war");
-
- handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
-
- server.setHandler(handlers);
- server.setGracefulShutdown(1000*3);
- }
-
- public void start() throws Exception {
- server.start();
- }
-
- public boolean isRunning() {
- return server.isRunning();
- }
-
- public void stop() throws Exception {
- server.stop();
- }
-
- public void destroy() {
- server.destroy();
- }
-
- public void join() throws InterruptedException {
- server.join();
- }
-} \ No newline at end of file
diff --git a/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/defaultConf/template.zip b/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/defaultConf/template.zip
deleted file mode 100644
index f14b0c19..00000000
--- a/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/defaultConf/template.zip
+++ /dev/null
Binary files differ
diff --git a/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/UIMessages.properties b/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/UIMessages.properties
deleted file mode 100644
index 873d03ef..00000000
--- a/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/UIMessages.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-#-------- tray icon messages -------
-TrayMenu.Tooltip=MOCCA
-TrayMenu.Shutdown=MOCCA Beenden
-
-Greetings.Message=MOCCA up and running
-Greetings.Caption=MOCCA Started
-
-Message.RequestCaption=New Request
-Message.InfoboxReadRequest=Reading Infobox
-Message.SecureSignatureKeypair=Reading secure signature certificate
-Message.CertifiedKeypair=Reading certified certificate
-Message.IdentityLink=Reading Identitylink
-Message.SignRequest=Creating Signature \ No newline at end of file
diff --git a/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/favicon.png b/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/favicon.png
deleted file mode 100644
index 2d0276de..00000000
--- a/BKULocalApp/src/main/resources/at/gv/egiz/bku/local/ui/favicon.png
+++ /dev/null
Binary files differ
diff --git a/BKULocalApp/src/main/resources/log4j.properties b/BKULocalApp/src/main/resources/log4j.properties
deleted file mode 100644
index fcdcb8e8..00000000
--- a/BKULocalApp/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# loglever DEBUG, appender STDOUT
-log4j.rootLogger=TRACE, STDOUT, file
-
-# STDOUT appender
-log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
-log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
-#log4j.appender.STDOUT.layout.ConversionPattern=%5p | %d{dd HH:mm:ss,SSS} | %20c | %10t | %m%n
-#log4j.appender.STDOUT.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
-log4j.appender.STDOUT.layout.ConversionPattern=%-5p |%d | %t | %c %x- %m%n
-
-### FILE appender
-log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.file.datePattern='.'yyyy-MM-dd
-log4j.appender.file.File=${user.home}/.mocca/logs/mocca.log
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n \ No newline at end of file
diff --git a/BKULocalApp/src/main/resources/splash.png b/BKULocalApp/src/main/resources/splash.png
deleted file mode 100644
index 72c1d868..00000000
--- a/BKULocalApp/src/main/resources/splash.png
+++ /dev/null
Binary files differ