summaryrefslogtreecommitdiff
path: root/BKUApplet/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'BKUApplet/src/main/java/at/gv/egiz')
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java24
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletSecureViewer.java31
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java106
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java18
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/viewer/URLFontLoader.java37
5 files changed, 111 insertions, 105 deletions
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java
index d5f8dd69..6fa9d45f 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java
@@ -37,12 +37,17 @@ import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.ws.WebServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
*
* @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
*/
public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
+ private final Logger log = LoggerFactory.getLogger(AbstractBKUWorker.class);
+
protected BKUApplet applet;
protected String sessionId;
@@ -55,7 +60,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
sessionId = applet.getParameter(BKUApplet.SESSION_ID);
if (sessionId == null) {
sessionId = "TestSession";
- log.warn("using dummy sessionId " + sessionId);
+ log.warn("Using dummy sessionId {}.", sessionId);
}
}
@@ -85,7 +90,8 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
// (rather use validator)
if (requests.size() == 0) {
- log.error("Received empty NextRequestResponse: no STAL requests to handle. (STAL-X requests might not have gotten unmarshalled)");
+ log.error("Received empty NextRequestResponse: no STAL requests to handle. " +
+ "(STAL-X requests might not have gotten unmarshalled)");
throw new RuntimeException("No STAL requests to handle.");
}
@@ -105,7 +111,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
try {
stalRequests.add(stalTranslator.translate(req));
} catch (TranslationException ex) {
- log.error("Received unknown request from server STAL: " + ex.getMessage());
+ log.error("Received unknown request from server STAL. {}", ex.getMessage());
throw new RuntimeException(ex);
}
}
@@ -117,7 +123,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
try {
responses.add(stalTranslator.translate(stalResponse));
} catch (TranslationException ex) {
- log.error("Received unknown response from STAL: " + ex.getMessage());
+ log.error("Received unknown response from STAL.{}", ex.getMessage());
throw new RuntimeException(ex);
}
}
@@ -131,7 +137,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
} else {
Throwable cause = ex.getCause();
if (cause != null && cause instanceof InterruptedException) {
- log.info("do not return error response, client might want to resume session");
+ log.info("Do not return error response, client might want to resume session.");
finished = true;
}
err.setErrorCode(4000);
@@ -160,13 +166,13 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
} while (!finished);
- log.info("Finished " + Thread.currentThread().getName());
+ log.info("Finished {}.", Thread.currentThread().getName());
} catch (WebServiceException ex) {
- log.fatal("communication error with server STAL: " + ex.getMessage(), ex);
+ log.error("Communication error with server STAL: {}.", ex.getMessage(), ex);
showErrorDialog(BKUGUIFacade.ERR_SERVICE_UNREACHABLE, ex);
} catch (MalformedURLException ex) {
- log.fatal(ex.getMessage(), ex);
+ log.error(ex.getMessage(), ex);
showErrorDialog(BKUGUIFacade.ERR_CONFIG, ex);
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
@@ -213,7 +219,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
try {
waitForAction();
} catch (InterruptedException e) {
- log.error(e);
+ log.error("Interrupted.", e);
}
}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletSecureViewer.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletSecureViewer.java
index c67699af..e9f36c2f 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletSecureViewer.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletSecureViewer.java
@@ -33,8 +33,8 @@ import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -42,7 +42,7 @@ import org.apache.commons.logging.LogFactory;
*/
public class AppletSecureViewer implements SecureViewer {
- private static final Log log = LogFactory.getLog(AppletSecureViewer.class);
+ private static final Logger log = LoggerFactory.getLogger(AppletSecureViewer.class);
protected BKUGUIFacade gui;
protected STALPortType stalPort;
@@ -81,8 +81,7 @@ public class AppletSecureViewer implements SecureViewer {
throws DigestException, Exception {
if (verifiedDataToBeSigned == null) {
- log.info("retrieve data to be signed for dsig:SignedInfo " +
- signedInfo.getId());
+ log.info("Retrieve data to be signed for dsig:SignedInfo {}.", signedInfo.getId());
List<GetHashDataInputResponseType.Reference> hdi =
getHashDataInput(signedInfo.getReference());
verifiedDataToBeSigned = verifyHashDataInput(signedInfo.getReference(),
@@ -106,16 +105,12 @@ public class AppletSecureViewer implements SecureViewer {
GetHashDataInputType request = new GetHashDataInputType();
request.setSessionId(sessId);
-// HashMap<String, ReferenceType> idSignedRefMap = new HashMap<String, ReferenceType>();
for (ReferenceType signedRef : signedReferences) {
//don't get Manifest, QualifyingProperties, ...
if (signedRef.getType() == null) {
String signedRefId = signedRef.getId();
if (signedRefId != null) {
- if (log.isTraceEnabled()) {
- log.trace("requesting hashdata input for reference " + signedRefId);
- }
-// idSignedRefMap.put(signedRefId, signedRef);
+ log.trace("Requesting hashdata input for reference {}.", signedRefId);
GetHashDataInputType.Reference ref = new GetHashDataInputType.Reference();
ref.setID(signedRefId);
request.getReference().add(ref);
@@ -127,12 +122,14 @@ public class AppletSecureViewer implements SecureViewer {
}
if (request.getReference().size() < 1) {
- log.error("No signature data (apart from any QualifyingProperties or a Manifest) for session " + sessId);
+ log.error("No signature data (apart from any QualifyingProperties or a Manifest) for session {}.", sessId);
throw new Exception("No signature data (apart from any QualifyingProperties or a Manifest)");
}
if (log.isDebugEnabled()) {
- log.debug("WebService call GetHashDataInput for " + request.getReference().size() + " references in session " + sessId);
+ log.debug(
+ "WebService call GetHashDataInput for {} references in session {}.",
+ request.getReference().size(), sessId);
}
GetHashDataInputResponseType response = stalPort.getHashDataInput(request);
return response.getReference();
@@ -154,7 +151,7 @@ public class AppletSecureViewer implements SecureViewer {
for (ReferenceType signedRef : signedReferences) {
if (signedRef.getType() == null) {
- log.info("Verifying digest for signed reference " + signedRef.getId());
+ log.info("Verifying digest for signed reference {}.", signedRef.getId());
String signedRefId = signedRef.getId();
byte[] signedDigest = signedRef.getDigestValue();
@@ -191,12 +188,9 @@ public class AppletSecureViewer implements SecureViewer {
byte[] hashDataInputDigest = digest(hdi, signedDigestAlg);
- if (log.isDebugEnabled()) {
- log.debug("Comparing digest to claimed digest value for reference " + signedRefId);
- }
-// log.warn("***************** DISABLED HASHDATA VERIFICATION");
+ log.debug("Comparing digest to claimed digest value for reference {}.", signedRefId);
if (!Arrays.equals(hashDataInputDigest, signedDigest)) {
- log.error("Bad digest value for reference " + signedRefId);
+ log.error("Bad digest value for reference {}.", signedRefId);
throw new DigestException("Bad digest value for reference " + signedRefId);
}
@@ -207,7 +201,6 @@ public class AppletSecureViewer implements SecureViewer {
return verifiedHashDataInputs;
}
- //TODO
private byte[] digest(byte[] hashDataInput, String mdAlg) throws NoSuchAlgorithmException {
if ("http://www.w3.org/2000/09/xmldsig#sha1".equals(mdAlg)) {
mdAlg = "SHA-1";
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
index 2fa4889a..7873b263 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
@@ -18,8 +18,6 @@ package at.gv.egiz.bku.online.applet;
import at.gv.egiz.bku.online.applet.viewer.URLFontLoader;
import at.gv.egiz.bku.gui.BKUGUIFacade.Style;
-import at.gv.egiz.bku.gui.DefaultHelpListener;
-import at.gv.egiz.bku.gui.AbstractHelpListener;
import at.gv.egiz.bku.gui.SwitchFocusListener;
import at.gv.egiz.smcc.SignatureCardFactory;
import at.gv.egiz.stal.service.translator.STALTranslator;
@@ -35,11 +33,13 @@ import javax.net.ssl.HttpsURLConnection;
import javax.swing.JApplet;
import javax.swing.JPanel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import at.gv.egiz.bku.gui.BKUGUIFacade;
import at.gv.egiz.bku.gui.BKUGUIImpl;
+import at.gv.egiz.bku.gui.DeafHelpListener;
+import at.gv.egiz.bku.gui.HelpListener;
import at.gv.egiz.bku.gui.viewer.FontProvider;
import at.gv.egiz.stal.service.STALPortType;
import at.gv.egiz.stal.service.STALService;
@@ -56,7 +56,9 @@ import javax.xml.namespace.QName;
public class BKUApplet extends JApplet {
private static final long serialVersionUID = 1L;
- private static Log log = LogFactory.getLog(BKUApplet.class);
+
+ private final Logger log = LoggerFactory.getLogger(BKUApplet.class);
+
/**
* Applet parameter keys
*/
@@ -71,8 +73,9 @@ public class BKUApplet extends JApplet {
public static final String BACKGROUND_COLOR = "BackgroundColor";
public static final String REDIRECT_URL = "RedirectURL";
public static final String REDIRECT_TARGET = "RedirectTarget";
- public static final String HASHDATA_DISPLAY_FRAME = "frame";
public static final String ENFORCE_RECOMMENDED_PIN_LENGTH = "EnforceRecommendedPINLength";
+
+
/**
* STAL WSDL namespace and service name
*/
@@ -88,22 +91,21 @@ public class BKUApplet extends JApplet {
static {
String tmp = UNKNOWN_VERSION;
+ Logger log = LoggerFactory.getLogger(BKUApplet.class);
try {
String BKUAppletJar = BKUApplet.class.getProtectionDomain().getCodeSource().getLocation().toString();
URL manifestURL = new URL("jar:" + BKUAppletJar + "!/META-INF/MANIFEST.MF");
- if (log.isTraceEnabled()) {
- log.trace("read version information from " + manifestURL);
- }
+ log.trace("Read version information from {}.", manifestURL);
Manifest manifest = new Manifest(manifestURL.openStream());
Attributes atts = manifest.getMainAttributes();
if (atts != null) {
tmp = atts.getValue("Implementation-Build");
}
} catch (IOException ex) {
- log.error("failed to read version", ex);
+ log.error("Failed to read version.", ex);
} finally {
VERSION = tmp;
- log.debug("BKU Applet " + VERSION);
+ log.debug("BKU Applet {}.", VERSION);
}
}
@@ -112,6 +114,7 @@ public class BKUApplet extends JApplet {
*/
protected AppletBKUWorker worker;
protected Thread workerThread;
+ protected HelpListener helpListener;
/*
* (non-Javadoc)
@@ -139,16 +142,15 @@ public class BKUApplet extends JApplet {
"URL for locating help files, e.g. '../help/' (no help provided if missing)"}};
}
-
/**
* Factory method to create and wire HelpListener, GUI and BKUWorker.
* (Config via applet parameters, see BKUApplet.* constants)
*/
@Override
public void init() {
- log.info("Welcome to MOCCA " + VERSION);
- log.trace("Called init()");
- showStatus("Initializing MOCCA applet");
+ log.info("Welcome to MOCCA {}.", VERSION);
+ log.trace("Called init().");
+ showStatus("Initializing MOCCA applet.");
HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory.getInstance());
@@ -156,12 +158,12 @@ public class BKUApplet extends JApplet {
if (locale != null) {
this.setLocale(new Locale(locale));
}
- log.trace("default locale: " + Locale.getDefault());
- log.debug("setting locale: " + getLocale());
+ log.trace("Default locale: {}.", Locale.getDefault());
+ log.debug("Applet locale set to: {}.", getLocale());
if (Boolean.parseBoolean(getParameter(ENFORCE_RECOMMENDED_PIN_LENGTH))) {
SignatureCardFactory.ENFORCE_RECOMMENDED_PIN_LENGTH = true;
- log.debug("enforce recommended pin length = " + SignatureCardFactory.ENFORCE_RECOMMENDED_PIN_LENGTH);
+ log.debug("Enforce recommended pin length = {}.", SignatureCardFactory.ENFORCE_RECOMMENDED_PIN_LENGTH);
}
BKUGUIFacade.Style guiStyle;
@@ -173,27 +175,30 @@ public class BKUApplet extends JApplet {
} else {
guiStyle = BKUGUIFacade.Style.simple;
}
- log.debug("setting gui-style: " + guiStyle);
+ log.debug("Setting gui-style: {}.", guiStyle);
URL backgroundImgURL = null;
try {
backgroundImgURL = getURLParameter(BACKGROUND_IMG, null);
- log.debug("setting background: " + backgroundImgURL);
+ log.debug("Setting background: {}.", backgroundImgURL);
} catch (MalformedURLException ex) {
- log.warn("cannot load applet background image: " + ex.getMessage());
+ log.warn("Cannot load applet background image. {}", ex.getMessage());
}
- AbstractHelpListener helpListener = null;
- try {
- helpListener = new DefaultHelpListener(getAppletContext(),
- getURLParameter(HELP_URL, null), getLocale());
- if (log.isDebugEnabled()) {
- log.debug("setting helpURL: " + getURLParameter(HELP_URL, null));
- }
- } catch (MalformedURLException ex) {
- log.warn("failed to load help URL: " + ex.getMessage() + ", disabling help");
- }
+ helpListener = new DeafHelpListener(getParameter(HELP_URL), getLocale());
+ SwitchFocusListener switchFocusListener = new SwitchFocusListener(
+ getAppletContext(), "focusToBrowser");
+
+
+//ViewerHelpListener example:
+// try {
+// String absoluteHelpURL = new URL(getCodeBase(), getParameter(HELP_URL)).toString();
+// helpListener = new ViewerHelpListener(getAppletContext(), absoluteHelpURL, getLocale());
+// } catch (MalformedURLException ex) {
+// log.error("invalid help URL, help disabled", ex);
+// }
+
// Note: We need a panel in order to be able to set the background
// properly.
// Setting the background without a panel has side effects with the
@@ -205,10 +210,10 @@ public class BKUApplet extends JApplet {
if (backgroundColor != null && backgroundColor.startsWith("#")) {
try {
Color color = new Color(Integer.parseInt(backgroundColor.substring(1), 16));
- log.debug("setting background color to " + color);
+ log.debug("Setting background color to {}.", color);
contentPanel.setBackground(color);
} catch (NumberFormatException e) {
- log.debug("failed to set background color '" + backgroundColor + "'");
+ log.debug("Failed to set background color '{}'.", backgroundColor);
}
}
@@ -216,30 +221,30 @@ public class BKUApplet extends JApplet {
URLFontLoader fontProvider = new URLFontLoader(getCodeBase());
fontProvider.loadInBackground();
BKUGUIFacade gui = createGUI(contentPanel, getLocale(), guiStyle,
- backgroundImgURL, fontProvider, helpListener, null);
+ backgroundImgURL, fontProvider, helpListener, switchFocusListener);
worker = createBKUWorker(this, gui);
} catch (MalformedURLException ex) {
- log.fatal("failed to load font provider URL", ex);
+ log.error("Failed to load font provider URL.", ex);
System.err.println("invalid font provider URL " + ex.getMessage());
}
}
@Override
public void start() {
- log.trace("Called start()");
+ log.trace("Called start().");
if (worker != null) {
showStatus("Starting MOCCA applet");
workerThread = new Thread(worker);
workerThread.start();
} else {
- log.debug("cannot start uninitialzed MOCCA applet");
+ log.debug("Cannot start uninitialzed MOCCA applet.");
}
}
@Override
public void stop() {
- log.trace("Called stop()");
+ log.trace("Called stop().");
showStatus("Stopping MOCCA applet");
if ((workerThread != null) && (workerThread.isAlive())) {
workerThread.interrupt();
@@ -248,7 +253,11 @@ public class BKUApplet extends JApplet {
@Override
public void destroy() {
- log.trace("Called destroy()");
+ log.trace("Called destroy().");
+ }
+
+ public String getHelpURL() {
+ return helpListener.getHelpURL();
}
// ///////////////////////////////////////////////////////////////////////////
@@ -256,7 +265,7 @@ public class BKUApplet extends JApplet {
// ///////////////////////////////////////////////////////////////////////////
protected BKUGUIFacade createGUI(Container contentPane, Locale locale,
Style guiStyle, URL backgroundImgURL,
- FontProvider fontProvider, AbstractHelpListener helpListener,
+ FontProvider fontProvider, HelpListener helpListener,
SwitchFocusListener switchFocusListener) {
return new BKUGUIImpl(contentPane, locale, guiStyle, backgroundImgURL,
fontProvider, helpListener, switchFocusListener);
@@ -277,7 +286,7 @@ public class BKUApplet extends JApplet {
*/
public STALPortType getSTALPort() throws MalformedURLException {
URL wsdlURL = getURLParameter(WSDL_URL, null);
- log.debug("setting STAL WSDL: " + wsdlURL);
+ log.debug("Setting STAL WSDL: {}.", wsdlURL);
QName endpointName = new QName(STAL_WSDL_NS, STAL_SERVICE);
STALService stal = new STALService(wsdlURL, endpointName);
return stal.getSTALPort();
@@ -304,25 +313,26 @@ public class BKUApplet extends JApplet {
try {
AppletContext ctx = getAppletContext();
if (ctx == null) {
- log.error("no applet context (applet might already have been destroyed)");
+ log.error("No applet context (applet might already have been destroyed).");
return;
}
URL redirectURL = getURLParameter(REDIRECT_URL, sessionId);
String redirectTarget = getParameter(REDIRECT_TARGET);
if (redirectTarget == null) {
- log.info("Done. Redirecting to " + redirectURL + " ...");
+ log.info("Done. Redirecting to {}.", redirectURL);
ctx.showDocument(redirectURL);
} else {
- log.info("Done. Redirecting to " + redirectURL + " (target=" + redirectTarget + ") ...");
+ log.info("Done. Redirecting to {} (target={}).", redirectURL, redirectTarget);
ctx.showDocument(redirectURL, redirectTarget);
}
} catch (MalformedURLException ex) {
- log.warn("Failed to redirect: " + ex.getMessage(), ex);
- // gui.showErrorDialog(errorMsg, okListener, actionCommand)
+ log.warn("Failed to redirect.", ex);
}
}
public void getFocusFromBrowser() {
+
+ log.debug("Obtained focus from browser.");
worker.getFocusFromBrowser();
}
@@ -348,11 +358,11 @@ public class BKUApplet extends JApplet {
}
return url;
} catch (MalformedURLException ex) {
- log.error("applet paremeter " + urlParam + " is not a valid URL: " + ex.getMessage());
+ log.error("Applet paremeter {} ist not a valid URL. {}", urlParam, ex.getMessage());
throw ex;
}
} else {
- log.error("applet paremeter " + paramKey + " not set");
+ log.error("Applet paremeter {} not set.", paramKey);
throw new MalformedURLException(paramKey + " not set");
}
}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
index a02e56eb..c9bf81ca 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
@@ -31,8 +31,8 @@ import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class InternalSSLSocketFactory extends SSLSocketFactory {
@@ -40,8 +40,7 @@ public class InternalSSLSocketFactory extends SSLSocketFactory {
private static InternalSSLSocketFactory instance = new InternalSSLSocketFactory();
- private final static Log log = LogFactory
- .getLog(InternalSSLSocketFactory.class);
+ private final Logger log = LoggerFactory.getLogger(InternalSSLSocketFactory.class);
private SSLSocket sslSocket;
@@ -107,19 +106,19 @@ public class InternalSSLSocketFactory extends SSLSocketFactory {
}
public boolean isEgovAgency() {
- log.info("Checking if server is egov agency");
+ log.info("Checking if server is egov agency.");
if (sslSocket != null) {
try {
X509Certificate cert = (X509Certificate) sslSocket.getSession()
.getPeerCertificates()[0];
- log.info("Server cert: " + cert);
+ log.info("Server cert: {}.", cert);
return isGovAgency(cert);
} catch (SSLPeerUnverifiedException e) {
- log.error(e);
+ log.error("Failed to check server cert.", e);
return false;
}
}
- log.info("Not a SSL connection");
+ log.info("Not a SSL connection.");
return false;
}
@@ -146,7 +145,8 @@ public class InternalSSLSocketFactory extends SSLSocketFactory {
}
}
} catch (CertificateParsingException e) {
- log.error(e);
+ Logger log = LoggerFactory.getLogger(InternalSSLSocketFactory.class);
+ log.error("Failed to parse certificate.", e);
}
if ((cert.getExtensionValue("1.2.40.0.10.1.1.1") != null)
|| (cert.getExtensionValue("1.2.40.0.10.1.1.2") != null)) {
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/viewer/URLFontLoader.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/viewer/URLFontLoader.java
index 49615887..d30080d0 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/viewer/URLFontLoader.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/viewer/URLFontLoader.java
@@ -16,17 +16,20 @@
*/
package at.gv.egiz.bku.online.applet.viewer;
-import at.gv.egiz.bku.gui.viewer.FontProviderException;
-import at.gv.egiz.bku.gui.viewer.FontProvider;
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.ExecutionException;
+
import javax.swing.SwingWorker;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.gv.egiz.bku.gui.viewer.FontProvider;
+import at.gv.egiz.bku.gui.viewer.FontProviderException;
/**
*
@@ -34,29 +37,24 @@ import org.apache.commons.logging.LogFactory;
*/
public class URLFontLoader extends SwingWorker<Font, Object> implements FontProvider {
- protected static final Log log = LogFactory.getLog(URLFontLoader.class);
+ private final Logger log = LoggerFactory.getLogger(URLFontLoader.class);
+
protected URL fontURL;
protected Font font;
public URLFontLoader(URL codebase) throws MalformedURLException {
this.fontURL = new URL(codebase, SANSMONO_FONT_RESOURCE);
- if (log.isDebugEnabled()) {
- log.debug("[" + Thread.currentThread().getName() + "] setting font load URL: " + fontURL);
- }
+ log.debug("[{}] setting font load URL: {}.", Thread.currentThread().getName(), fontURL);
}
public void loadInBackground() {
- if (log.isDebugEnabled()) {
- log.debug("[" + Thread.currentThread().getName() + "] scheduling font loading in background: " + fontURL);
- }
+ log.debug("[{}] scheduling font loading in background: {}.", Thread.currentThread().getName(), fontURL);
this.execute();
}
@Override
protected Font doInBackground() throws MalformedURLException, FontFormatException, IOException {
- if (log.isDebugEnabled()) {
- log.debug("[" + Thread.currentThread().getName() + "] loading font in background...");
- }
+ log.debug("[{}] loading font in background.", Thread.currentThread().getName());
return Font.createFont(Font.TRUETYPE_FONT, fontURL.openStream());
}
@@ -67,16 +65,15 @@ public class URLFontLoader extends SwingWorker<Font, Object> implements FontProv
*/
@Override
public Font getFont() throws FontProviderException {
- log.debug("[" + Thread.currentThread().getName() + "] get font (EDT?)");
+ log.debug("[{}] get font (EDT?)", Thread.currentThread().getName());
try {
return get();
} catch (InterruptedException ex) {
- log.error("font loader interrupted");
-// Thread.currentThread().interrupt();
- throw new FontProviderException("font loader interrupted", ex);
+ log.error("Font loader interrupted.");
+ throw new FontProviderException("Font loader interrupted.", ex);
} catch (ExecutionException ex) {
- log.error("failed to load font", ex.getCause());
- throw new FontProviderException("failed to load font", ex.getCause());
+ log.error("Failed to load font. {}", ex.getCause());
+ throw new FontProviderException("Failed to load font.", ex.getCause());
}
}
}