summaryrefslogtreecommitdiff
path: root/BKUWebStart/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'BKUWebStart/src/main')
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Configurator.java26
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Container.java11
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java22
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/LogSecurityManager.java9
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/TLSServerCA.java9
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/AboutDialog.java7
-rw-r--r--BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/PINManagementInvoker.java7
-rw-r--r--BKUWebStart/src/main/resources/log4j.properties20
8 files changed, 60 insertions, 51 deletions
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Configurator.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Configurator.java
index 923a70d9..d8fe3e70 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Configurator.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Configurator.java
@@ -16,8 +16,9 @@
*/
package at.gv.egiz.bku.webstart;
-import at.gv.egiz.bku.utils.StreamUtil;
import iaik.asn1.CodingException;
+import iaik.utils.StreamCopier;
+
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
@@ -42,8 +43,10 @@ import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
+import org.apache.log4j.PropertyConfigurator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -71,7 +74,7 @@ public class Configurator {
public static final String KEYSTORE_FILE = "keystore.ks";
public static final String PASSWD_FILE = ".secret";
- private static final Log log = LogFactory.getLog(Configurator.class);
+ private static final Logger log = LoggerFactory.getLogger(Configurator.class);
/** currently installed configuration version */
private String version;
@@ -110,6 +113,11 @@ public class Configurator {
} else {
initConfig(configDir);
}
+ // re-configure logging
+ // TODO: move to appropriate place
+ String log4jconfig = configDir.getPath() + File.separatorChar + "log4j.properties";
+ log.debug("Reconfiguring logging with " + log4jconfig);
+ PropertyConfigurator.configureAndWatch(log4jconfig);
}
/**
@@ -312,7 +320,7 @@ public class Configurator {
ZipEntry entry = new ZipEntry(relativePath.toString());
zip.putNextEntry(entry);
BufferedInputStream entryIS = new BufferedInputStream(new FileInputStream(dir));
- StreamUtil.copyStream(entryIS, zip);
+ new StreamCopier(entryIS, zip).copyStream();
entryIS.close();
zip.closeEntry();
dir.delete();
@@ -341,7 +349,7 @@ public class Configurator {
File confTemplateFile = new File(configDir, CONF_TEMPLATE_FILE);
InputStream is = Configurator.class.getClassLoader().getResourceAsStream(CONF_TEMPLATE_RESOURCE);
OutputStream os = new BufferedOutputStream(new FileOutputStream(confTemplateFile));
- StreamUtil.copyStream(is, os);
+ new StreamCopier(is, os).copyStream();
os.close();
unzip(confTemplateFile, configDir);
confTemplateFile.delete();
@@ -374,7 +382,7 @@ public class Configurator {
new File(certsDir, f.substring(0, f.lastIndexOf('/'))).mkdirs();
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(certsDir, f)));
log.debug(f);
- StreamUtil.copyStream(Configurator.class.getClassLoader().getResourceAsStream(entry), bos);
+ new StreamCopier(Configurator.class.getClassLoader().getResourceAsStream(entry), bos).copyStream();
bos.close();
} else {
log.trace("ignore " + entry);
@@ -399,8 +407,8 @@ public class Configurator {
}
File f = new File(eF.getParent());
f.mkdirs();
- StreamUtil.copyStream(zipFile.getInputStream(entry),
- new FileOutputStream(eF));
+ new StreamCopier(zipFile.getInputStream(entry),
+ new FileOutputStream(eF)).copyStream();
}
zipFile.close();
}
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 2feae267..4d1fe658 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
@@ -1,6 +1,7 @@
package at.gv.egiz.bku.webstart;
-import at.gv.egiz.bku.utils.StreamUtil;
+import iaik.utils.StreamCopier;
+
import java.awt.AWTPermission;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -24,20 +25,20 @@ import java.security.SecurityPermission;
import java.security.cert.Certificate;
import java.util.PropertyPermission;
import javax.smartcardio.CardPermission;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.security.SslSocketConnector;
import org.mortbay.jetty.webapp.WebAppContext;
import org.mortbay.thread.QueuedThreadPool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Container {
public static final String HTTP_PORT_PROPERTY = "mocca.http.port";
public static final String HTTPS_PORT_PROPERTY = "mocca.http.port";
- private static Log log = LogFactory.getLog(Container.class);
+ private static Logger log = LoggerFactory.getLogger(Container.class);
static {
if (log.isDebugEnabled()) {
@@ -166,7 +167,7 @@ public class Container {
log.debug("copying BKULocal classpath resource to " + webapp);
InputStream is = getClass().getClassLoader().getResourceAsStream("BKULocal.war");
OutputStream os = new BufferedOutputStream(new FileOutputStream(webapp));
- StreamUtil.copyStream(is, os);
+ new StreamCopier(is, os).copyStream();
os.close();
return webapp.getPath();
}
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java
index 2bf42ccb..ef7edef1 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java
@@ -10,8 +10,6 @@ import java.util.Locale;
import java.util.ResourceBundle;
import javax.jnlp.UnavailableServiceException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import com.sun.javaws.security.JavaWebStartSecurity;
import java.awt.AWTException;
@@ -37,6 +35,8 @@ import javax.jnlp.BasicService;
import javax.jnlp.ServiceManager;
import javax.swing.JFrame;
import org.mortbay.util.MultiException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Launcher implements BKUControllerInterface, ActionListener {
public static final String HELP_COMMAND = "help";
@@ -71,9 +71,10 @@ public class Launcher implements BKUControllerInterface, ActionListener {
public static final String SHUTDOWN_COMMAND = "shutdown";
public static final String PIN_COMMAND = "pin";
public static final String ABOUT_COMMAND = "about";
+
+ private static Logger log = LoggerFactory.getLogger(Launcher.class);
- private static Log log = LogFactory.getLog(Launcher.class);
-
+
/** local bku uri */
public static final URL HTTP_SECURITY_LAYER_URL;
public static final URL HTTPS_SECURITY_LAYER_URL;
@@ -93,7 +94,7 @@ public class Launcher implements BKUControllerInterface, ActionListener {
cert = new URL(http, "/installCertificate");
help = new URL(http, "/help");
} catch (MalformedURLException ex) {
- log.error(ex);
+ log.error("Failed to create URL.", ex);
} finally {
HTTP_SECURITY_LAYER_URL = http;
HTTPS_SECURITY_LAYER_URL = https;
@@ -132,6 +133,7 @@ public class Launcher implements BKUControllerInterface, ActionListener {
public Launcher() {
+ log.info("Initializing Launcher");
if (log.isTraceEnabled()) {
SecurityManager sm = System.getSecurityManager();
if (sm instanceof JavaWebStartSecurity) {
@@ -147,7 +149,7 @@ public class Launcher implements BKUControllerInterface, ActionListener {
try {
initConfig();
} catch (Exception ex) {
- log.fatal("Failed to initialize configuration", ex);
+ log.error("Failed to initialize configuration", ex);
trayIcon.displayMessage(messages.getString(CAPTION_ERROR),
messages.getString(ERROR_CONFIG), TrayIcon.MessageType.ERROR);
throw ex;
@@ -156,12 +158,12 @@ public class Launcher implements BKUControllerInterface, ActionListener {
startServer();
initFinished();
} catch (BindException ex) {
- log.fatal("Failed to launch server, " + ex.getMessage(), ex);
+ log.error("Failed to launch server, " + ex.getMessage(), ex);
trayIcon.displayMessage(messages.getString(CAPTION_ERROR),
messages.getString(ERROR_BIND), TrayIcon.MessageType.ERROR);
throw ex;
} catch (MultiException ex) {
- log.fatal("Failed to launch server, " + ex.getMessage(), ex);
+ log.error("Failed to launch server, " + ex.getMessage(), ex);
if (ex.getThrowable(0) instanceof BindException) {
trayIcon.displayMessage(messages.getString(CAPTION_ERROR),
messages.getString(ERROR_BIND), TrayIcon.MessageType.ERROR);
@@ -172,7 +174,7 @@ public class Launcher implements BKUControllerInterface, ActionListener {
throw ex;
} catch (Exception ex) {
ex.printStackTrace();
- log.fatal("Failed to launch server, " + ex.getMessage(), ex);
+ log.error("Failed to launch server, " + ex.getMessage(), ex);
trayIcon.displayMessage(messages.getString(CAPTION_ERROR),
messages.getString(ERROR_START), TrayIcon.MessageType.ERROR);
throw ex;
@@ -379,7 +381,7 @@ public class Launcher implements BKUControllerInterface, ActionListener {
launcher.launch();
} catch (Exception ex) {
ex.printStackTrace();
- log.debug(ex);
+ log.debug("Caught exception " + ex.getMessage(), ex);
log.info("waiting to shutdown...");
Thread.sleep(5000);
log.info("exit");
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/LogSecurityManager.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/LogSecurityManager.java
index 99fd403b..d589812e 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/LogSecurityManager.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/LogSecurityManager.java
@@ -20,8 +20,9 @@ import com.sun.javaws.security.JavaWebStartSecurity;
import java.io.FileDescriptor;
import java.net.InetAddress;
import java.security.Permission;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* JVM argument -Djava.security.debug=access,failure
@@ -31,7 +32,7 @@ import org.apache.commons.logging.LogFactory;
*/
public class LogSecurityManager extends SecurityManager {
- protected static final Log log = LogFactory.getLog(LogSecurityManager.class);
+ protected static final Logger log = LoggerFactory.getLogger(LogSecurityManager.class);
JavaWebStartSecurity sm;
public LogSecurityManager(JavaWebStartSecurity sm) {
@@ -182,6 +183,7 @@ public class LogSecurityManager extends SecurityManager {
}
}
+ @SuppressWarnings("deprecation")
@Override
public void checkMulticast(InetAddress maddr, byte ttl) {
try {
@@ -399,6 +401,7 @@ public class LogSecurityManager extends SecurityManager {
// protected Class[] getClassContext() {
// log.info("getClassContext"); return sm.getClassContext();
// }
+ @SuppressWarnings("deprecation")
@Override
public boolean getInCheck() {
log.info("getInCheck");
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/TLSServerCA.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/TLSServerCA.java
index 08a06570..745042f8 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/TLSServerCA.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/TLSServerCA.java
@@ -16,8 +16,6 @@ import iaik.x509.extensions.SubjectAltName;
import iaik.x509.extensions.SubjectKeyIdentifier;
import java.io.IOException;
import java.math.BigInteger;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.security.GeneralSecurityException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
@@ -27,14 +25,15 @@ import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Random;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class TLSServerCA {
public static final int CA_VALIDITY_Y = 3;
public static final String MOCCA_TLS_SERVER_ALIAS = "server";
public static final int SERVER_VALIDITY_Y = 3;
- private final static Log log = LogFactory.getLog(TLSServerCA.class);
+ private final static Logger log = LoggerFactory.getLogger(TLSServerCA.class);
private KeyPair caKeyPair;
private X509Certificate caCert;
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/AboutDialog.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/AboutDialog.java
index 1e35af58..ba2c007d 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/AboutDialog.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/AboutDialog.java
@@ -11,7 +11,6 @@
package at.gv.egiz.bku.webstart.gui;
-import java.text.Format;
import java.text.MessageFormat;
import java.util.ResourceBundle;
@@ -21,6 +20,11 @@ import java.util.ResourceBundle;
*/
public class AboutDialog extends javax.swing.JDialog {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
/** Creates new form AboutDialog */
public AboutDialog(java.awt.Frame parent, boolean modal, String version) {
super(parent, modal);
@@ -33,7 +37,6 @@ public class AboutDialog extends javax.swing.JDialog {
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
- @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/PINManagementInvoker.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/PINManagementInvoker.java
index 55e26313..1f14d751 100644
--- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/PINManagementInvoker.java
+++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/PINManagementInvoker.java
@@ -21,8 +21,9 @@ import java.awt.TrayIcon;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.ResourceBundle;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* GUI is painted using SwingUtilities.invokeLater, but TrayIcon ActionListener Thread (== webstart thread) joined Jetty Thread
@@ -31,7 +32,7 @@ import org.apache.commons.logging.LogFactory;
*/
public class PINManagementInvoker implements Runnable {
- private static final Log log = LogFactory.getLog(PINManagementInvoker.class);
+ private static final Logger log = LoggerFactory.getLogger(PINManagementInvoker.class);
TrayIcon trayIcon;
ResourceBundle messages;
diff --git a/BKUWebStart/src/main/resources/log4j.properties b/BKUWebStart/src/main/resources/log4j.properties
index 76562ccf..81832418 100644
--- a/BKUWebStart/src/main/resources/log4j.properties
+++ b/BKUWebStart/src/main/resources/log4j.properties
@@ -13,23 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# loglever DEBUG, appender STDOUT
-log4j.rootLogger=DEBUG, file
-log4j.logger.org.mortbay.log=INFO
-log4j.logger.pki=INFO
-
-#log4j.additivity.pki=false
+# root log level INFO, appender file
+log4j.rootLogger=INFO, 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
+# jetty's log level
+log4j.logger.org.mortbay.log=INFO
-### FILE appender
+# file appender
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.datePattern='.'yyyy-MM-dd
log4j.appender.file.File=${user.home}/.mocca/logs/webstart.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
+log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %-5p %c{2} - %m%n \ No newline at end of file