summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-11-05 19:05:14 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-11-05 19:05:14 +0000
commit83e8c95ea7d257166d350a59bfd81e9833ec14fd (patch)
tree1d989268e21e0ea2de24be718f40e5e86df74bbd
parent9f66f6cc09fd4d010b270d8a83b204728b9336e1 (diff)
downloadmocca-83e8c95ea7d257166d350a59bfd81e9833ec14fd.tar.gz
mocca-83e8c95ea7d257166d350a59bfd81e9833ec14fd.tar.bz2
mocca-83e8c95ea7d257166d350a59bfd81e9833ec14fd.zip
[#484] European Language support
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@535 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
-rw-r--r--BKUApplet/pom.xml1
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java572
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/viewer/URLFontLoader.java82
-rw-r--r--BKUApplet/src/test/resources/appletTest.html35
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/ActivationApplet.java4
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementApplet.java4
-rw-r--r--BKUCommonGUI/pom.xml18
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java27
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUIcons.java57
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SecureViewerDialog.java98
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProvider.java40
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProviderException.java29
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties2
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties2
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/chip128.png (renamed from BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip128.png)bin7775 -> 7775 bytes
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/chip16.png (renamed from BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip16.png)bin787 -> 787 bytes
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/chip24.png (renamed from BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip24.png)bin1227 -> 1227 bytes
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/chip48.png (renamed from BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip48.png)bin2771 -> 2771 bytes
-rw-r--r--BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java2
-rw-r--r--BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/DummyFontLoader.java35
-rw-r--r--BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/SecureViewerDialogTest.java165
-rw-r--r--BKUFonts/pom.xml43
-rw-r--r--BKUFonts/src/main/fonts/DejaVuLGCSans.ttfbin0 -> 498636 bytes
-rw-r--r--BKUFonts/src/main/fonts/DejaVuLGCSansMono.ttfbin0 -> 282704 bytes
-rw-r--r--BKUFonts/src/main/fonts/DejaVuLGCSerif.ttfbin0 -> 304924 bytes
-rw-r--r--BKUFonts/src/main/fonts/LICENSE99
-rw-r--r--BKUFonts/src/main/fonts/META-INF/services/at.gv.egiz.bku.gui.SecureFontProvider3
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java6
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java5
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java4
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java1
-rw-r--r--BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/ActivationGuiTest.java3
-rw-r--r--BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java1
-rw-r--r--BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/DummyFontLoader.java35
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSTALFactory.java36
-rw-r--r--BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip32.pngbin1753 -> 0 bytes
-rw-r--r--BKUOnline/pom.xml22
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java1
-rw-r--r--BKUOnline/src/main/webapp/SLRequestForm.html40
-rw-r--r--BKUOnline/src/main/webapp/applet.jsp13
-rw-r--r--BKUOnline/src/main/webapp/index.html3
-rw-r--r--BKUOnline/src/main/webapp/js/deployJava_orig.js725
-rw-r--r--BKUViewer/pom.xml15
-rw-r--r--BKUViewer/src/main/java/at/gv/egiz/bku/text/TextValidator.java38
-rw-r--r--BKUViewer/src/test/java/at/gv/egiz/bku/text/TestTextValidator.java121
-rw-r--r--bkucommon/pom.xml10
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/viewer/ResourceFontLoader.java61
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java23
-rw-r--r--pom.xml1
49 files changed, 1983 insertions, 499 deletions
diff --git a/BKUApplet/pom.xml b/BKUApplet/pom.xml
index 397c5670..4172517b 100644
--- a/BKUApplet/pom.xml
+++ b/BKUApplet/pom.xml
@@ -21,6 +21,7 @@
</goals>
<configuration>
<includeGroupIds>at.gv.egiz</includeGroupIds>
+ <!-- don't include transitive dependency BKUFonts [runtime] from BKUCommonGUI -->
<excludeTransitive>true</excludeTransitive>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<excludes>META-INF\/</excludes>
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 6346b7f4..7a15f7a5 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
@@ -16,6 +16,7 @@
*/
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;
@@ -25,6 +26,8 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.net.ssl.HttpsURLConnection;
import javax.swing.JApplet;
import javax.swing.JPanel;
@@ -34,6 +37,7 @@ import org.apache.commons.logging.LogFactory;
import at.gv.egiz.bku.gui.BKUGUIFacade;
import at.gv.egiz.bku.gui.BKUGUIImpl;
+import at.gv.egiz.bku.gui.viewer.FontProvider;
import at.gv.egiz.stal.service.STALPortType;
import at.gv.egiz.stal.service.STALService;
import java.applet.AppletContext;
@@ -46,289 +50,287 @@ import javax.xml.namespace.QName;
* Note: all swing code is executed by the event dispatch thread (see
* BKUGUIFacade)
*/
-public class BKUApplet extends JApplet {
-
- private static final long serialVersionUID = 1L;
-
- private static Log log = LogFactory.getLog(BKUApplet.class);
- /**
- * Applet parameter keys
- */
- public static final String GUI_STYLE = "GuiStyle";
- public final static String LOCALE = "Locale";
- public final static String WSDL_URL = "WSDL_URL";
- public static final String HASHDATA_DISPLAY = "HashDataDisplay";
- public final static String HASHDATA_URL = "HashDataURL";
- public final static String HELP_URL = "HelpURL";
- public final static String SESSION_ID = "SessionID";
- public static final String BACKGROUND_IMG = "Background";
- 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";
- /**
- * STAL WSDL namespace and service name
- */
- public static final String STAL_WSDL_NS = "http://www.egiz.gv.at/wsdl/stal";
- public static final String STAL_SERVICE = "STALService";
- /**
- * Dummy session id, used if no sessionId parameter is provided
- */
- protected static final String TEST_SESSION_ID = "TestSession";
-
- static {
- if (log.isTraceEnabled()) {
- log.trace("enabling webservice communication dump");
- System
- .setProperty(
- "com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump",
- "true");
- }
- }
-
- /**
- * STAL
- */
- protected AppletBKUWorker worker;
- protected Thread workerThread;
-
- /*
- * (non-Javadoc)
- *
- * @see java.applet.Applet#getParameterInfo()
- */
- @Override
- public String[][] getParameterInfo() {
- return new String[][] {
- { WSDL_URL, "url",
- "URL of the WSDL of the MOCCA server side STAL" },
- { REDIRECT_URL, "url",
- "URL to redirect the browser to when finished" },
- { REDIRECT_TARGET, "frame target",
- "name of the target frame for redirection when finished" },
- { LOCALE, "locale",
- "locale for UI localization (optional, default: system default)" },
- { GUI_STYLE, "simple, advanced, tiny",
- "GUI style (optional, default: simple)" },
- { BACKGROUND_COLOR, "#hhhhhh",
- "background color, e.g. '#333333' (optional, default: look and feel dependend)" },
- { BACKGROUND_IMG, "url",
- "URL of a background image for the GUI (optional, default: no image)" },
- { HELP_URL, "url",
- "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");
- log.trace("Called init()");
-
- HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory
- .getInstance());
-
- String locale = getParameter(LOCALE);
- if (locale != null) {
- this.setLocale(new Locale(locale));
- }
- log.trace("default locale: " + Locale.getDefault());
- log.debug("setting locale: " + getLocale());
-
- BKUGUIFacade.Style guiStyle;
- String guiStyleParam = getParameter(GUI_STYLE);
- if ("advanced".equals(guiStyleParam)) {
- guiStyle = BKUGUIFacade.Style.advanced;
- } else if ("tiny".equals(guiStyleParam)) {
- guiStyle = BKUGUIFacade.Style.tiny;
- } else {
- guiStyle = BKUGUIFacade.Style.simple;
- }
- log.debug("setting gui-style: " + guiStyle);
-
- URL backgroundImgURL = null;
- try {
- backgroundImgURL = getURLParameter(BACKGROUND_IMG, null);
- log.debug("setting background: " + backgroundImgURL);
- } catch (MalformedURLException ex) {
- 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");
- }
-
- SwitchFocusListener switchFocusListener = new SwitchFocusListener(
- getAppletContext(), "focusToBrowser()");
-
- // 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
- // different java plugins.
- JPanel contentPanel = new JPanel();
- getContentPane().add(contentPanel);
-
- String backgroundColor = getParameter(BACKGROUND_COLOR);
- if (backgroundColor != null && backgroundColor.startsWith("#")) {
- try {
- Color color = new Color(Integer.parseInt(backgroundColor
- .substring(1), 16));
- log.debug("setting background color to " + color);
- contentPanel.setBackground(color);
- } catch (NumberFormatException e) {
- log.debug("failed to set background color '" + backgroundColor
- + "'");
- }
- }
-
- BKUGUIFacade gui = createGUI(contentPanel, getLocale(), guiStyle,
- backgroundImgURL, helpListener, switchFocusListener);
-
- worker = createBKUWorker(this, gui);
- }
-
- @Override
- public void start() {
- log.trace("Called start()");
- workerThread = new Thread(worker);
- workerThread.start();
- }
-
- @Override
- public void stop() {
- log.trace("Called stop()");
- if ((workerThread != null) && (workerThread.isAlive())) {
- workerThread.interrupt();
- }
- }
-
- @Override
- public void destroy() {
- log.trace("Called destroy()");
- }
-
- // ///////////////////////////////////////////////////////////////////////////
- // factory methods for subclasses to inject different components
- // ///////////////////////////////////////////////////////////////////////////
-
- protected BKUGUIFacade createGUI(Container contentPane, Locale locale,
- Style guiStyle, URL backgroundImgURL,
- AbstractHelpListener helpListener,
- SwitchFocusListener switchFocusListener) {
- return new BKUGUIImpl(contentPane, locale, guiStyle, backgroundImgURL,
- helpListener, switchFocusListener);
- }
-
- protected AppletBKUWorker createBKUWorker(BKUApplet applet, BKUGUIFacade gui) {
- return new AppletBKUWorker(applet, gui);
- }
-
- // ///////////////////////////////////////////////////////////////////////////
- // callback for BKUWorker to allow extension
- // ///////////////////////////////////////////////////////////////////////////
-
- /**
- * Callback for BKUWorker to allow extension
- *
- * @return
- * @throws java.net.MalformedURLException
- */
- public STALPortType getSTALPort() throws MalformedURLException {
- URL wsdlURL = getURLParameter(WSDL_URL, null);
- log.debug("setting STAL WSDL: " + wsdlURL);
- QName endpointName = new QName(STAL_WSDL_NS, STAL_SERVICE);
- STALService stal = new STALService(wsdlURL, endpointName);
- return stal.getSTALPort();
- }
-
- /**
- * Callback for BKUWorker to allow extension (TODO STALPort could know its
- * STALTranslator)
- *
- * @return
- * @throws java.net.MalformedURLException
- */
- public STALTranslator getSTALTranslator() {
- return new STALTranslator();
- }
-
- /**
- * Callback for BKUWorker to keep applet context out of BKUWorker
- *
- * @return
- * @throws java.net.MalformedURLException
- */
- protected void sendRedirect(String sessionId) {
- try {
- AppletContext ctx = getAppletContext();
- if (ctx == null) {
- 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 + " ...");
- ctx.showDocument(redirectURL);
- } else {
- log.info("Done. Redirecting to " + redirectURL + " (target="
- + redirectTarget + ") ...");
- ctx.showDocument(redirectURL, redirectTarget);
- }
- } catch (MalformedURLException ex) {
- log.warn("Failed to redirect: " + ex.getMessage(), ex);
- // gui.showErrorDialog(errorMsg, okListener, actionCommand)
- }
- }
-
- public void getFocusFromBrowser() {
-
- worker.getFocusFromBrowser();
- }
-
- // ///////////////////////////////////////////////////////////////////////////
- // utility methods
- // ///////////////////////////////////////////////////////////////////////////
-
- protected URL getURLParameter(String paramKey, String sessionId)
- throws MalformedURLException {
- String urlParam = getParameter(paramKey);
- if (urlParam != null && !"".equals(urlParam)) {
- URL codebase = getCodeBase();
- try {
- URL url;
- if (codebase.getProtocol().equalsIgnoreCase("file")) {
- // for debugging in appletrunner
- url = new URL(urlParam);
- } else {
- if (sessionId != null) {
- urlParam = urlParam + ";jsessionid=" + sessionId;
- }
- url = new URL(codebase, urlParam);
- }
- return url;
- } catch (MalformedURLException ex) {
- log.error("applet paremeter " + urlParam
- + " is not a valid URL: " + ex.getMessage());
- throw ex;
- }
- } else {
- log.error("applet paremeter " + paramKey + " not set");
- throw new MalformedURLException(paramKey + " not set");
- }
- }
-
+public class BKUApplet extends JApplet {
+
+ private static final long serialVersionUID = 1L;
+ private static Log log = LogFactory.getLog(BKUApplet.class);
+ /**
+ * Applet parameter keys
+ */
+ public static final String GUI_STYLE = "GuiStyle";
+ public final static String LOCALE = "Locale";
+ public final static String WSDL_URL = "WSDL_URL";
+ public static final String HASHDATA_DISPLAY = "HashDataDisplay";
+ public final static String HASHDATA_URL = "HashDataURL";
+ public final static String HELP_URL = "HelpURL";
+ public final static String SESSION_ID = "SessionID";
+ public static final String BACKGROUND_IMG = "Background";
+ 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";
+ /**
+ * STAL WSDL namespace and service name
+ */
+ public static final String STAL_WSDL_NS = "http://www.egiz.gv.at/wsdl/stal";
+ public static final String STAL_SERVICE = "STALService";
+ /**
+ * Dummy session id, used if no sessionId parameter is provided
+ */
+ protected static final String TEST_SESSION_ID = "TestSession";
+
+ static {
+ if (log.isTraceEnabled()) {
+ log.trace("enabling webservice communication dump");
+ System.setProperty(
+ "com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump",
+ "true");
+ }
+ }
+ /**
+ * STAL
+ */
+ protected AppletBKUWorker worker;
+ protected Thread workerThread;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.applet.Applet#getParameterInfo()
+ */
+ @Override
+ public String[][] getParameterInfo() {
+ return new String[][]{
+ {WSDL_URL, "url",
+ "URL of the WSDL of the MOCCA server side STAL"},
+ {REDIRECT_URL, "url",
+ "URL to redirect the browser to when finished"},
+ {REDIRECT_TARGET, "frame target",
+ "name of the target frame for redirection when finished"},
+ {LOCALE, "locale",
+ "locale for UI localization (optional, default: system default)"},
+ {GUI_STYLE, "simple, advanced, tiny",
+ "GUI style (optional, default: simple)"},
+ {BACKGROUND_COLOR, "#hhhhhh",
+ "background color, e.g. '#333333' (optional, default: look and feel dependend)"},
+ {BACKGROUND_IMG, "url",
+ "URL of a background image for the GUI (optional, default: no image)"},
+ {HELP_URL, "url",
+ "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");
+ log.trace("Called init()");
+ showStatus("Initializing MOCCA applet");
+
+ HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory.getInstance());
+
+ String locale = getParameter(LOCALE);
+ if (locale != null) {
+ this.setLocale(new Locale(locale));
+ }
+ log.trace("default locale: " + Locale.getDefault());
+ log.debug("setting locale: " + getLocale());
+
+ BKUGUIFacade.Style guiStyle;
+ String guiStyleParam = getParameter(GUI_STYLE);
+ if ("advanced".equals(guiStyleParam)) {
+ guiStyle = BKUGUIFacade.Style.advanced;
+ } else if ("tiny".equals(guiStyleParam)) {
+ guiStyle = BKUGUIFacade.Style.tiny;
+ } else {
+ guiStyle = BKUGUIFacade.Style.simple;
+ }
+ log.debug("setting gui-style: " + guiStyle);
+
+ URL backgroundImgURL = null;
+ try {
+ backgroundImgURL = getURLParameter(BACKGROUND_IMG, null);
+ log.debug("setting background: " + backgroundImgURL);
+ } catch (MalformedURLException ex) {
+ 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");
+ }
+
+ SwitchFocusListener switchFocusListener = new SwitchFocusListener(
+ getAppletContext(), "focusToBrowser()");
+
+ // 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
+ // different java plugins.
+ JPanel contentPanel = new JPanel();
+ getContentPane().add(contentPanel);
+
+ String backgroundColor = getParameter(BACKGROUND_COLOR);
+ if (backgroundColor != null && backgroundColor.startsWith("#")) {
+ try {
+ Color color = new Color(Integer.parseInt(backgroundColor.substring(1), 16));
+ log.debug("setting background color to " + color);
+ contentPanel.setBackground(color);
+ } catch (NumberFormatException e) {
+ log.debug("failed to set background color '" + backgroundColor + "'");
+ }
+ }
+
+ try {
+ URLFontLoader fontProvider = new URLFontLoader(getCodeBase());
+ fontProvider.loadInBackground();
+ BKUGUIFacade gui = createGUI(contentPanel, getLocale(), guiStyle,
+ backgroundImgURL, fontProvider, helpListener, switchFocusListener);
+
+ worker = createBKUWorker(this, gui);
+ } catch (MalformedURLException ex) {
+ log.fatal("failed to load font provider URL", ex);
+ System.err.println("invalid font provider URL " + ex.getMessage());
+ }
+ }
+
+ @Override
+ public void 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");
+ }
+ }
+
+ @Override
+ public void stop() {
+ log.trace("Called stop()");
+ showStatus("Stopping MOCCA applet");
+ if ((workerThread != null) && (workerThread.isAlive())) {
+ workerThread.interrupt();
+ }
+ }
+
+ @Override
+ public void destroy() {
+ log.trace("Called destroy()");
+ }
+
+ // ///////////////////////////////////////////////////////////////////////////
+ // factory methods for subclasses to inject different components
+ // ///////////////////////////////////////////////////////////////////////////
+ protected BKUGUIFacade createGUI(Container contentPane, Locale locale,
+ Style guiStyle, URL backgroundImgURL,
+ FontProvider fontProvider, AbstractHelpListener helpListener,
+ SwitchFocusListener switchFocusListener) {
+ return new BKUGUIImpl(contentPane, locale, guiStyle, backgroundImgURL,
+ fontProvider, helpListener, switchFocusListener);
+ }
+
+ protected AppletBKUWorker createBKUWorker(BKUApplet applet, BKUGUIFacade gui) {
+ return new AppletBKUWorker(applet, gui);
+ }
+
+ // ///////////////////////////////////////////////////////////////////////////
+ // callback for BKUWorker to allow extension
+ // ///////////////////////////////////////////////////////////////////////////
+ /**
+ * Callback for BKUWorker to allow extension
+ *
+ * @return
+ * @throws java.net.MalformedURLException
+ */
+ public STALPortType getSTALPort() throws MalformedURLException {
+ URL wsdlURL = getURLParameter(WSDL_URL, null);
+ log.debug("setting STAL WSDL: " + wsdlURL);
+ QName endpointName = new QName(STAL_WSDL_NS, STAL_SERVICE);
+ STALService stal = new STALService(wsdlURL, endpointName);
+ return stal.getSTALPort();
+ }
+
+ /**
+ * Callback for BKUWorker to allow extension (TODO STALPort could know its
+ * STALTranslator)
+ *
+ * @return
+ * @throws java.net.MalformedURLException
+ */
+ public STALTranslator getSTALTranslator() {
+ return new STALTranslator();
+ }
+
+ /**
+ * Callback for BKUWorker to keep applet context out of BKUWorker
+ *
+ * @return
+ * @throws java.net.MalformedURLException
+ */
+ protected void sendRedirect(String sessionId) {
+ try {
+ AppletContext ctx = getAppletContext();
+ if (ctx == null) {
+ 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 + " ...");
+ ctx.showDocument(redirectURL);
+ } else {
+ log.info("Done. Redirecting to " + redirectURL + " (target=" + redirectTarget + ") ...");
+ ctx.showDocument(redirectURL, redirectTarget);
+ }
+ } catch (MalformedURLException ex) {
+ log.warn("Failed to redirect: " + ex.getMessage(), ex);
+ // gui.showErrorDialog(errorMsg, okListener, actionCommand)
+ }
+ }
+
+ public void getFocusFromBrowser() {
+
+ worker.getFocusFromBrowser();
+ }
+
+ // ///////////////////////////////////////////////////////////////////////////
+ // utility methods
+ // ///////////////////////////////////////////////////////////////////////////
+ protected URL getURLParameter(String paramKey, String sessionId)
+ throws MalformedURLException {
+ String urlParam = getParameter(paramKey);
+ if (urlParam != null && !"".equals(urlParam)) {
+ URL codebase = getCodeBase();
+ try {
+ URL url;
+ if (codebase.getProtocol().equalsIgnoreCase("file")) {
+ // for debugging in appletrunner
+ url = new URL(urlParam);
+ } else {
+ if (sessionId != null) {
+ urlParam = urlParam + ";jsessionid=" + sessionId;
+ }
+ url = new URL(codebase, urlParam);
+ }
+ return url;
+ } catch (MalformedURLException ex) {
+ log.error("applet paremeter " + urlParam + " is not a valid URL: " + ex.getMessage());
+ throw ex;
+ }
+ } else {
+ log.error("applet paremeter " + paramKey + " not set");
+ throw new MalformedURLException(paramKey + " not set");
+ }
+ }
}
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
new file mode 100644
index 00000000..f914aed7
--- /dev/null
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/viewer/URLFontLoader.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+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;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class URLFontLoader extends SwingWorker<Font, Object> implements FontProvider {
+
+ protected static final Log log = LogFactory.getLog(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() + " setting font load URL: " + fontURL);
+ }
+ }
+
+ public void loadInBackground() {
+ if (log.isDebugEnabled()) {
+ log.debug(Thread.currentThread() + " scheduling font loading in background: " + fontURL);
+ }
+ this.execute();
+ }
+
+ @Override
+ protected Font doInBackground() throws MalformedURLException, FontFormatException, IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Thread.currentThread() + " loading font in background...");
+ }
+ return Font.createFont(Font.TRUETYPE_FONT, fontURL.openStream());
+ }
+
+ /**
+ * waits for loadInBackground to finish
+ * @return the font loaded in loadInbackground
+ * @throws Exception
+ */
+ @Override
+ public Font getFont() throws FontProviderException {
+ log.debug(Thread.currentThread() + " get font");
+ try {
+ return get();
+ } catch (InterruptedException ex) {
+ log.error("font loader interrupted");
+// Thread.currentThread().interrupt();
+ 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());
+ }
+ }
+}
diff --git a/BKUApplet/src/test/resources/appletTest.html b/BKUApplet/src/test/resources/appletTest.html
index 4a768f91..d1a0f6e2 100644
--- a/BKUApplet/src/test/resources/appletTest.html
+++ b/BKUApplet/src/test/resources/appletTest.html
@@ -15,20 +15,25 @@
limitations under the License.
-->
<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>MOCCA Applet</title>
+ <link rel="shortcut icon" href="img/chip16.ico" type="image/x-icon">
+ </head>
<body>
- <center>
- <applet code="at.gv.egiz.bku.online.applet.BKUApplet.class"
- archive="../BKUApplet-1.0.5-SNAPSHOT.jar, commons-logging.jar , iaik_jce_me4se.jar"
- width=152 height=145>
- <param name="GuiStyle" value="tiny"/>
- <param name="Locale" value="ja_JA"/>
- <!--param name="Background" value="jar:file:/home/clemens/workspace/mocca/BKUApplet/target/BKUApplet-1.0-SNAPSHOT.jar!/images/help.png"/-->
- <!--param name="Background" value="http://localhost:3495/img/BackgroundChipperling.png"/-->
- <param name="WSDL_URL" value="https://danu.gv.at:3496/stal?wsdl"/>
- <param name="HelpURL" value="http://apps.egiz.gv.at/bkuonline/help/"/>
- <param name="SessionId" value="TestSession"/>
- <param name="RedirectURL" value="http://localhost:3495/bkuResult"/>
- </applet>
- </center>
+ <applet code="at.gv.egiz.bku.online.applet.BKUApplet.class"
+ archive="../BKUApplet-1.2.8-SNAPSHOT.jar, commons-logging.jar , iaik_jce_me4se.jar"
+ width=190 height=130 name="moccaapplet" id="moccaapplet">
+ <param name="GuiStyle" value="simple"/>
+ <param name="Locale" value="ja_JA"/>
+ <!--param name="Background" value="jar:file:/home/clemens/workspace/mocca/BKUApplet/target/BKUApplet-1.0-SNAPSHOT.jar!/images/help.png"/-->
+ <!--param name="Background" value="http://localhost:3495/img/BackgroundChipperling.png"/-->
+ <param name="BackgroundColor" value="#ff0000"/>
+ <param name="WSDL_URL" value="https://danu.gv.at:3496/stal?wsdl"/>
+ <param name="HelpURL" value="http://apps.egiz.gv.at/bkuonline/help/"/>
+ <param name="SessionId" value="TestSession"/>
+ <param name="RedirectURL" value="http://localhost:3495/bkuResult"/>
+ <param name="RedirectTarget" value="_parent"/>
+ </applet>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/ActivationApplet.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/ActivationApplet.java
index 5bab2ef8..4f2f1331 100644
--- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/ActivationApplet.java
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/ActivationApplet.java
@@ -21,6 +21,7 @@ import at.gv.egiz.bku.gui.ActivationGUI;
import at.gv.egiz.bku.gui.BKUGUIFacade;
import at.gv.egiz.bku.gui.SwitchFocusListener;
import at.gv.egiz.bku.gui.BKUGUIFacade.Style;
+import at.gv.egiz.bku.gui.viewer.FontProvider;
import at.gv.egiz.bku.online.applet.BKUApplet;
import at.gv.egiz.bku.smccstal.AbstractSMCCSTAL;
import at.gv.egiz.bku.smccstal.CardMgmtRequestHandler;
@@ -85,8 +86,9 @@ public class ActivationApplet extends BKUApplet {
Locale locale,
Style guiStyle,
URL backgroundImgURL,
+ FontProvider fontProvider,
AbstractHelpListener helpListener,
SwitchFocusListener switchFocusListener) {
- return new ActivationGUI(contentPane, locale, guiStyle, backgroundImgURL, helpListener, switchFocusListener);
+ return new ActivationGUI(contentPane, locale, guiStyle, backgroundImgURL, fontProvider, helpListener, switchFocusListener);
}
}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementApplet.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementApplet.java
index 055e9c31..bf323969 100644
--- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementApplet.java
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementApplet.java
@@ -21,6 +21,7 @@ import at.gv.egiz.bku.gui.BKUGUIFacade;
import at.gv.egiz.bku.gui.PINManagementGUI;
import at.gv.egiz.bku.gui.PINManagementGUIFacade;
import at.gv.egiz.bku.gui.SwitchFocusListener;
+import at.gv.egiz.bku.gui.viewer.FontProvider;
import java.awt.Container;
import java.net.URL;
import java.util.Locale;
@@ -41,9 +42,10 @@ public class PINManagementApplet extends BKUApplet {
Locale locale,
BKUGUIFacade.Style guiStyle,
URL backgroundImgURL,
+ FontProvider fontProvider,
AbstractHelpListener helpListener,
SwitchFocusListener switchFocusListener) {
- return new PINManagementGUI(contentPane, locale, guiStyle, backgroundImgURL, helpListener, switchFocusListener);
+ return new PINManagementGUI(contentPane, locale, guiStyle, backgroundImgURL, fontProvider, helpListener, switchFocusListener);
}
@Override
diff --git a/BKUCommonGUI/pom.xml b/BKUCommonGUI/pom.xml
index 9fecb661..feefa18b 100644
--- a/BKUCommonGUI/pom.xml
+++ b/BKUCommonGUI/pom.xml
@@ -21,6 +21,13 @@
<version>1.2.8-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
+ <!-- see BKUFonts.pom
+ <dependency>
+ <groupId>at.gv.egiz</groupId>
+ <artifactId>BKUFonts</artifactId>
+ <version>1.0</version>
+ <scope>runtime</scope>
+ </dependency-->
</dependencies>
<build>
<plugins>
@@ -33,15 +40,4 @@
</plugin>
</plugins>
</build>
- <!--build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build-->
</project> \ No newline at end of file
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java
index e83502a8..8df4bd72 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java
@@ -17,6 +17,8 @@
package at.gv.egiz.bku.gui;
+import at.gv.egiz.bku.gui.viewer.FontProviderException;
+import at.gv.egiz.bku.gui.viewer.FontProvider;
import at.gv.egiz.smcc.PINSpec;
import at.gv.egiz.stal.HashDataInput;
import java.awt.Color;
@@ -73,6 +75,7 @@ public class BKUGUIImpl implements BKUGUIFacade {
protected HelpKeyListener helpKeyListener;
protected SwitchFocusFocusListener switchFocusKeyListener;
protected SecureViewerDialog secureViewer;
+ protected FontProvider fontProvider;
protected Container contentPane;
protected ResourceBundle messages;
@@ -115,8 +118,9 @@ public class BKUGUIImpl implements BKUGUIFacade {
*/
public BKUGUIImpl(Container contentPane,
Locale locale,
- Style guiStyle,
+ Style guiStyle,
URL background,
+ FontProvider fontProvider,
ActionListener helpListener,
SwitchFocusListener switchFocusListener) {
this.contentPane = contentPane;
@@ -139,7 +143,8 @@ public class BKUGUIImpl implements BKUGUIFacade {
registerHelpListener(helpListener);
registerSwitchFocusListener(switchFocusListener);
-
+
+ this.fontProvider = fontProvider;
createGUI(background);
}
@@ -1386,7 +1391,12 @@ public class BKUGUIImpl implements BKUGUIFacade {
@Override
public void run() {
- showSecureViewer(dataToBeSigned.get(0));
+ try {
+ showSecureViewer(dataToBeSigned.get(0));
+ } catch (FontProviderException ex) {
+ log.error("failed to display secure viewer", ex);
+ showErrorDialog(ERR_VIEWER, new Object[] {ex.getMessage()}, backListener, backCommand);
+ }
}
});
@@ -1407,12 +1417,12 @@ public class BKUGUIImpl implements BKUGUIFacade {
* @param saveListener
* @param saveCommand
*/
- private void showSecureViewer(HashDataInput dataToBeSigned) {
+ private void showSecureViewer(HashDataInput dataToBeSigned) throws FontProviderException {
log.debug("show secure viewer [" + Thread.currentThread().getName() + "]");
if (secureViewer == null) {
secureViewer = new SecureViewerDialog(null, messages,
- helpMouseListener.getActionListener());
+ fontProvider, helpMouseListener.getActionListener());
// workaround for [#439]
// avoid AlwaysOnTop at least in applet, otherwise make secureViewer AlwaysOnTop since MOCCA Dialog (JFrame created in LocalSTALFactory) is always on top.
@@ -1485,7 +1495,12 @@ public class BKUGUIImpl implements BKUGUIFacade {
int selectionIdx = lsm.getMinSelectionIndex();
if (selectionIdx >= 0) {
final HashDataInput selection = signedReferences.get(selectionIdx);
- showSecureViewer(selection);
+ try {
+ showSecureViewer(selection);
+ } catch (FontProviderException ex) {
+ log.error("failed to display secure viewer", ex);
+ showErrorDialog(ERR_VIEWER, new Object[] {ex.getMessage()}, backListener, backCommand);
+ }
}
}
});
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUIcons.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUIcons.java
new file mode 100644
index 00000000..92d6897b
--- /dev/null
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUIcons.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import java.awt.Image;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import javax.imageio.ImageIO;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class BKUIcons {
+
+ protected static final Log log = LogFactory.getLog(BKUIcons.class);
+
+ /** 16x16, 24x24, 32x32, 48x48, 128x128 pixels */
+ public static final ArrayList<Image> icons = new ArrayList<Image>();
+
+ static {
+ String[] iconResources = new String[] {
+ "/at/gv/egiz/bku/gui/chip16.png",
+ "/at/gv/egiz/bku/gui/chip24.png",
+ "/at/gv/egiz/bku/gui/chip32.png",
+ "/at/gv/egiz/bku/gui/chip48.png",
+ "/at/gv/egiz/bku/gui/chip128.png" };
+ for (String ir : iconResources) {
+ URL resource = BKUIcons.class.getResource(ir);
+ if (ir != null) {
+ try {
+ icons.add(ImageIO.read(resource));
+ } catch (IOException ex) {
+ log.warn("failed to load mocca icon " + ir, ex);
+ }
+ }
+ }
+ }
+}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SecureViewerDialog.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SecureViewerDialog.java
index ef70f94b..1883fce5 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SecureViewerDialog.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SecureViewerDialog.java
@@ -16,6 +16,7 @@
*/
package at.gv.egiz.bku.gui;
+import at.gv.egiz.bku.gui.viewer.FontProvider;
import at.gv.egiz.stal.HashDataInput;
import java.awt.Container;
import java.awt.Cursor;
@@ -53,9 +54,12 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.LayoutStyle;
import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.text.DefaultEditorKit;
import javax.swing.text.Document;
import javax.swing.text.EditorKit;
import javax.swing.text.StyledEditorKit;
+import javax.swing.text.html.HTMLEditorKit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -65,16 +69,20 @@ import org.apache.commons.logging.LogFactory;
*/
public class SecureViewerDialog extends JDialog implements ActionListener {
- public static final String PLAINTEXT_FONT = "Monospaced";
+ /** don't import BKUFonts in order not to load BKUFonts.jar
+ * BKUApplet includes BKUFonts as runtime dependency only, the jar is copied to the applet dir in BKUOnline with dependency-plugin
+ * BKUViewer has compile dependency BKUFonts, transitive in BKUOnline and BKULocal
+ */
+ public static final String PLAINTEXT_FONT_RESOURCE = "DejaVuSansMono.ttf";
public static final Dimension VIEWER_DIMENSION = new Dimension(600, 400);
protected static final Log log = LogFactory.getLog(SecureViewerDialog.class);
-
// private static SecureViewerDialog dialog;
protected ResourceBundle messages;
protected JEditorPane viewer;
protected JLabel viewerLabel;
protected JScrollPane scrollPane;
protected HashDataInput content; //remember for save dialog
+ protected FontProvider fontProvider;
/**
* Create and display a modal SecureViewer dialog.
@@ -97,10 +105,12 @@ public class SecureViewerDialog extends JDialog implements ActionListener {
// dialog.setVisible(true);
// }
public SecureViewerDialog(Frame owner, ResourceBundle messages,
-// ActionListener saveListener, String saveCommand,
- ActionListener helpListener) {
+ // ActionListener saveListener, String saveCommand,
+ FontProvider fontProvider, ActionListener helpListener) {
super(owner, messages.getString(BKUGUIFacade.WINDOWTITLE_VIEWER), true);
+ this.setIconImages(BKUIcons.icons);
this.messages = messages;
+ this.fontProvider = fontProvider;
initContentPane(VIEWER_DIMENSION,
createViewerPanel(helpListener),
@@ -135,7 +145,8 @@ public class SecureViewerDialog extends JDialog implements ActionListener {
private JPanel createViewerPanel(final ActionListener helpListener) {
viewer = new JEditorPane();
viewer.setEditable(false);
-
+ viewer.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
+
scrollPane = new JScrollPane();
JPanel viewerPanel = new JPanel();
@@ -167,31 +178,29 @@ public class SecureViewerDialog extends JDialog implements ActionListener {
});
helpLabel.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent arg0) {
-
- if(arg0.getKeyCode() == KeyEvent.VK_ENTER) {
- ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, BKUGUIFacade.HELP_HASHDATAVIEWER);
- helpListener.actionPerformed(e);
- }
+ @Override
+ public void keyPressed(KeyEvent arg0) {
+
+ if (arg0.getKeyCode() == KeyEvent.VK_ENTER) {
+ ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, BKUGUIFacade.HELP_HASHDATAVIEWER);
+ helpListener.actionPerformed(e);
}
- });
-
+ }
+ });
+
helpLabel.addFocusListener(new FocusAdapter() {
-
- @Override
- public void focusGained(FocusEvent e) {
-
- helpLabel.setIcon(new ImageIcon(getClass().getResource(BKUGUIFacade.HELP_IMG_FOCUS)));
- }
-
- @Override
- public void focusLost(FocusEvent e) {
-
- helpLabel.setIcon(new ImageIcon(getClass().getResource(BKUGUIFacade.HELP_IMG)));
- }
-
-
+
+ @Override
+ public void focusGained(FocusEvent e) {
+
+ helpLabel.setIcon(new ImageIcon(getClass().getResource(BKUGUIFacade.HELP_IMG_FOCUS)));
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+
+ helpLabel.setIcon(new ImageIcon(getClass().getResource(BKUGUIFacade.HELP_IMG)));
+ }
});
helpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
@@ -216,9 +225,10 @@ public class SecureViewerDialog extends JDialog implements ActionListener {
* @param hashDataInput
*/
- public void setContent(HashDataInput hashDataInput) {
+ public void setContent(HashDataInput hashDataInput) { //throws FontProviderException {
this.content = null;
+ viewer.setText(null);
String mimeType = hashDataInput.getMimeType();
if (mimeType == null) {
@@ -228,20 +238,21 @@ public class SecureViewerDialog extends JDialog implements ActionListener {
// loads editorkit for text/plain if unrecognized
viewer.setContentType(mimeType);
- if ("text/plain".equals(mimeType)) {
- viewer.setEditorKit(new StyledEditorKit());
- viewer.setFont(new Font(PLAINTEXT_FONT, viewer.getFont().getStyle(), viewer.getFont().getSize()));
-// } else if ("text/html".equals(mimeType)) {
-// viewer.setEditorKit(new RestrictedHTMLEditorKit());
- } else if ("application/xhtml+xml".equals(mimeType)) {
- viewer.setContentType("text/html");
- }
+ try {
+
+ if ("text/plain".equals(mimeType)) {
+ viewer.setEditorKit(new StyledEditorKit());
+ viewer.setFont(fontProvider.getFont().deriveFont(Font.PLAIN, viewer.getFont().getSize()));
+ } else if ("application/xhtml+xml".equals(mimeType)) {
+ viewer.setEditorKit(new HTMLEditorKit());
+ //reset font if fontprovider font was set before (TODO also html font from fontprovider)
+ viewer.setFont(new Font("Dialog", Font.PLAIN, viewer.getFont().getSize())); //UIManager.getFont("Label.font"));
+ }
- EditorKit editorKit = viewer.getEditorKit();
- Document document = editorKit.createDefaultDocument();
-// document.putProperty("IgnoreCharsetDirective", new Boolean(true));
+ EditorKit editorKit = viewer.getEditorKit();
+ Document document = editorKit.createDefaultDocument();
+ // document.putProperty("IgnoreCharsetDirective", new Boolean(true));
- try {
Charset cs = (hashDataInput.getEncoding() == null) ? Charset.forName("UTF-8") : Charset.forName(hashDataInput.getEncoding());
log.debug("secure viewer encoding: " + cs.toString());
@@ -252,11 +263,14 @@ public class SecureViewerDialog extends JDialog implements ActionListener {
this.content = hashDataInput;
+// } catch (Exception ex) // fontProvider
// } catch (IllegalCharsetNameException ex) {
// } catch (UnsupportedCharsetException ex) {
+// } catch (FontProviderException ex) {
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
String p = messages.getString(BKUGUIFacade.ERR_VIEWER);
+ viewer.setContentType("text/plain");
viewer.setText(MessageFormat.format(p, ex.getMessage()));
}
viewer.setCaretPosition(0);
@@ -280,7 +294,7 @@ public class SecureViewerDialog extends JDialog implements ActionListener {
closeButton.setText(messages.getString(BKUGUIFacade.BUTTON_CLOSE));
closeButton.setActionCommand("close");
closeButton.addActionListener(this);
-
+
JButton saveButton = new JButton();
saveButton.setText(messages.getString(BKUGUIFacade.BUTTON_SAVE));
saveButton.setActionCommand("save");
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProvider.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProvider.java
new file mode 100644
index 00000000..8fb815b0
--- /dev/null
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProvider.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui.viewer;
+
+import java.awt.Font;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public interface FontProvider {
+
+ /** will be replaced by more sophisticated font selection mechanism
+ * (see java.awt.Font int/String constants) */
+ String SANSMONO_FONT_RESOURCE = "DejaVuLGCSansMono.ttf";
+
+ /**
+ *
+ * @return
+ * @throws InterruptedException
+ * @throws FileNotFoundException if remote font file cannot be retrieved
+ */
+ Font getFont() throws FontProviderException;
+
+}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProviderException.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProviderException.java
new file mode 100644
index 00000000..5a6a277e
--- /dev/null
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/viewer/FontProviderException.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui.viewer;
+
+/**
+ * Encapsulates the reason why a font could not be loaded.
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class FontProviderException extends Exception {
+
+ public FontProviderException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+}
diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
index a96b835f..b458a214 100644
--- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
@@ -86,7 +86,7 @@ error.test=<html>Fehler1 {0} - Fehler2 {1}</html>
error.card.locked=<html>B\u00FCrgerkarte ist gesperrt</html>
error.card.notactivated=<html>Die B\u00FCrgerkarte ist nicht aktiviert</html>
error.pin.timeout=<html>Zeit\u00FCberschreitung bei Eingabe der PIN</html>
-error.viewer=Der Inhalt kann nicht dargestellt werden: {0}
+error.viewer=<html>Der Inhalt kann nicht dargestellt werden: {0}
error.external.link=<html>Externer Link {0} wird nicht ge\u00F6ffnet</html>
error.config=<html>Fehlerhafte Konfiguration des Systems: {0}</html>
diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
index c795b3fa..22b9095c 100644
--- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
@@ -84,7 +84,7 @@ error.test=<html>Error1 {0} - Error2 {1}</html>
error.card.locked=<html>Citizen card is locked</html>
error.card.notactivated=<html>Citizen card not activated</html>
error.pin.timeout=<html>Timeout during PIN entry</html>
-error.viewer=Failed to display contents: {0}
+error.viewer=<html>Failed to display contents: {0}
error.external.link=<html>Cannot open external link {0}</html>
error.config=<html>Incorrect system configuration: {0}</html>
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip128.png b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/chip128.png
index c36d8079..c36d8079 100644
--- a/BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip128.png
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/chip128.png
Binary files differ
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip16.png b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/chip16.png
index 96b580e9..96b580e9 100644
--- a/BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip16.png
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/chip16.png
Binary files differ
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip24.png b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/chip24.png
index efd6dbeb..efd6dbeb 100644
--- a/BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip24.png
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/chip24.png
Binary files differ
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip48.png b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/chip48.png
index 491fbcac..491fbcac 100644
--- a/BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip48.png
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/chip48.png
Binary files differ
diff --git a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java
index 9f1cb612..fdd58850 100644
--- a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java
+++ b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java
@@ -41,7 +41,7 @@ public class BKUGUITest {
Container contentPane = testFrame.getContentPane();
// contentPane.setPreferredSize(new Dimension(170, 150));
contentPane.setPreferredSize(new Dimension(290, 190));
- BKUGUIFacade gui = new BKUGUIImpl(contentPane, null, BKUGUIFacade.Style.advanced, null, null, null);
+ BKUGUIFacade gui = new BKUGUIImpl(contentPane, null, BKUGUIFacade.Style.advanced, null, new DummyFontLoader(), null, null);
BKUGUIWorker worker = new BKUGUIWorker();
worker.init(gui);
testFrame.pack();
diff --git a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/DummyFontLoader.java b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/DummyFontLoader.java
new file mode 100644
index 00000000..87d67adc
--- /dev/null
+++ b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/DummyFontLoader.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.bku.gui.viewer.FontProviderException;
+import at.gv.egiz.bku.gui.viewer.FontProvider;
+import java.awt.Font;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class DummyFontLoader implements FontProvider {
+
+ @Override
+ public Font getFont() throws FontProviderException {
+ return new Font("monospaced", Font.PLAIN, 10);
+ }
+
+}
diff --git a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/SecureViewerDialogTest.java b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/SecureViewerDialogTest.java
new file mode 100644
index 00000000..fc8dcd96
--- /dev/null
+++ b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/SecureViewerDialogTest.java
@@ -0,0 +1,165 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.stal.impl.ByteArrayHashDataInput;
+import java.awt.Font;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ResourceBundle;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ *
+ * @author clemens
+ */
+@Ignore
+public class SecureViewerDialogTest {
+
+ static SecureViewerDialog secureViewer;
+ static ResourceBundle messages;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ messages = ResourceBundle.getBundle("at/gv/egiz/bku/gui/Messages");
+ secureViewer = new SecureViewerDialog(null, messages, new DummyFontLoader(), null);
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+
+ @Test
+ @Ignore
+ public void testLatin1Supplement() throws UnsupportedEncodingException, FileNotFoundException, IOException {
+// StringBuilder data = new StringBuilder();
+// data.append("\nhttp://www.unicode.org/charts/PDF/U0080.pdf\n");
+// for (int i = 0x0080; i <= 0x00ff; i++) {
+// data.append((char) i);
+// }
+// System.out.println(data.toString());
+ BufferedInputStream bis = new BufferedInputStream(new FileInputStream("/home/clemens/IAIK/MOCCA/encoding/test_iso-8859-1.txt"));
+ byte[] bytes = new byte[bis.available()];
+ bis.read(bytes);
+ String s = new String(bytes, "iso-8859-1");
+ System.out.println("read iso-8859-1 bytes " + s);
+
+ secureViewer.setContent(new ByteArrayHashDataInput(s.getBytes("UTF-8"), "id-1", "text/plain", "iso-8859-1"));
+
+ }
+
+ @Test
+ @Ignore
+ public void testGreek() throws UnsupportedEncodingException {
+// Font fm = new Font(Font.MONOSPACED, Font.PLAIN, 10);
+ Font fm = new Font("Lucida Sans Typewriter", Font.PLAIN, 18); //GothicBBB-MediumH", Font.PLAIN, 10);
+ System.out.println(fm.getFontName() + ", " + fm.getPSName() + ", " + fm);
+
+ StringBuilder data = new StringBuilder();
+ data.append("\nhttp://www.unicode.org/charts/PDF/U0370.pdf\n");
+ for (int i = 0x0370; i <= 0x03ff; i++) {
+ if (!fm.canDisplay((char) i)) {
+ System.out.println("cannot display " + Integer.toHexString(i) );
+ }
+ data.append((char) i);
+ }
+
+ System.out.println(data.toString());
+ secureViewer.setContent(new ByteArrayHashDataInput(data.toString().getBytes("UTF-8"), "id-1", "text/plain", "UTF-8"));
+
+ }
+
+ /**
+ * Test of setContent method, of class SecureViewerDialog.
+ */
+ @Test
+// @Ignore
+ public void testCyrillic() throws UnsupportedEncodingException {
+
+ StringBuilder data = new StringBuilder("\n");
+
+ int[] mocca = new int[] {0x041c, 0x04a8, 0x0480, 0x0480, 0x0466 };
+
+ for (int i = 0; i < mocca.length; i++) {
+ data.append((char) mocca[i]);
+ }
+ data.append(" goes cyrillic\n");
+
+ data.append("\nCyrillic - http://www.unicode.org/charts/PDF/U0400.pdf\n");
+ for (int i = 0x0400; i <= 0x04ff; i++) {
+// System.out.printf("%c%04x=%c\t", (i & 7) == 0 ? '\n' : '\0', i, (char)i);
+// System.out.print((char) i);
+ data.append((char)i);
+ }
+
+ data.append("\n\nCyrillic Supplement - http://www.unicode.org/charts/PDF/U0500.pdf\n");
+ for (int i = 0x0500; i <= 0x0525; i++) {
+// System.out.printf("%c%04x=%c\t", (i & 7) == 0 ? '\n' : '\0', i, (char)i);
+// System.out.print((char) i);
+ data.append((char) i);
+ }
+
+ for (int i = 0; i < data.length(); i++) {
+ char c = data.charAt(i);
+ if (c >= '\u0400' && c <= '\u0525') {
+ System.out.println(c + "\tcyrillic");
+ } else if (c < '\u007f') {
+ System.out.println(c + "\tlatin");
+ } else {
+ System.out.println(c + "\tunknown");
+ }
+ }
+
+ System.out.println(data.toString());
+
+// char[] cyrillicChars = new char[] {(char) 0x0411, (char) 0x0444};
+// System.out.println(new String(cyrillicChars)); // + ": " + SMCCHelper.toString(cyrillicBytes));
+// byte[] cyrillicBytes = new byte[] {(byte) 0x11, (byte) 0x04, (byte) 0x0444};
+// System.out.println(new String(cyrillicBytes, "UTF-8") + ": " + SMCCHelper.toString(cyrillicBytes));
+
+// String encoding = "cp1252";
+// String data = "öäü߀";
+// byte[] bytes = data.getBytes(encoding);
+// System.out.println(data + "\t" + SMCCHelper.toString(bytes));
+// byte[] bytes2 = data.getBytes("cp1252");
+// System.out.println(data + "\t" + SMCCHelper.toString(bytes2));
+
+ secureViewer.setContent(new ByteArrayHashDataInput(data.toString().getBytes("UTF-8"), "id-1", "text/plain", "UTF-8"));
+
+ System.out.println("\n\n=============================\n");
+//
+//// int[] mocca = new int[] {0x0428, 0x0429, 0x04a8, 0x04e8, 0x047a, 0x042d, 0x042d, 0x0421, 0x0421, 0x04d0, 0x0466 };
+// int[] mocca = new int[] {0x0429, 0x04a8, 0x0480, 0x0480, 0x0466 };
+ for (int i = 0; i < mocca.length; i++) {
+ System.out.print((char) mocca[i]);
+ }
+// for (int i = 0; i < mocca.length; i++) {
+// System.out.printf(" 0x%04x", mocca[i]);
+// }
+//
+ System.out.println("\n=============================\n");
+
+ }
+
+
+} \ No newline at end of file
diff --git a/BKUFonts/pom.xml b/BKUFonts/pom.xml
new file mode 100644
index 00000000..a798f5d1
--- /dev/null
+++ b/BKUFonts/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>bku</artifactId>
+ <groupId>at.gv.egiz</groupId>
+ <version>1.2.8-SNAPSHOT</version>
+ </parent>
+ <groupId>at.gv.egiz</groupId>
+ <artifactId>BKUFonts</artifactId>
+ <version>1.0</version>
+ <name>BKUFonts</name>
+ <description>
+ This module is used in validator(s) and viewer and is a direct dependency of
+ - BKUViewer (attention, this is the validator!)
+ TextValidator depends on the fonts. (compile scope, make available for BKULocal/Online TextValidator)
+ (TextValidator should rather use a FontProvider)
+ - BKUOnline:
+ - direct/provided if jar inclusion in applet dir, but do not enforce inclusion as WEB-INF/lib
+ - transitive from BKUViewer if unpack-fonts to applet dir
+ - removed the BKUCommonGUI (runtime; propagate dependency to BKUApplet):
+ no real dependency: BKUCommonGUI contains SecureFontProvider interface only
+ (which does not state how fonts are loaded); implementations should depend no BKUFonts
+ (ResourceFontLoader in BKULocal depends on the fonts, however URLFontLoader in BKUApplet doesn't.
+ BKUOnline however depends on BKUFonts for providing the fonts as web-resource for the applet)
+
+
+ at.gv.egiz.bku.text.TextValidator and xxx.LocalFontProvider load fonts from classpath,
+ resource name must be known, TODO: encapsulate resource loading (FontProvider constants?)
+
+ at.gv.egiz.bku.online.applet.URLFontLoader loads (unpacked) font files from applet codebase,
+ resource names _must_ be known since applet has no BKUFonts dependency
+
+ </description>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/fonts</directory>
+ </resource>
+ </resources>
+ </build>
+</project>
diff --git a/BKUFonts/src/main/fonts/DejaVuLGCSans.ttf b/BKUFonts/src/main/fonts/DejaVuLGCSans.ttf
new file mode 100644
index 00000000..cae5a48b
--- /dev/null
+++ b/BKUFonts/src/main/fonts/DejaVuLGCSans.ttf
Binary files differ
diff --git a/BKUFonts/src/main/fonts/DejaVuLGCSansMono.ttf b/BKUFonts/src/main/fonts/DejaVuLGCSansMono.ttf
new file mode 100644
index 00000000..21647753
--- /dev/null
+++ b/BKUFonts/src/main/fonts/DejaVuLGCSansMono.ttf
Binary files differ
diff --git a/BKUFonts/src/main/fonts/DejaVuLGCSerif.ttf b/BKUFonts/src/main/fonts/DejaVuLGCSerif.ttf
new file mode 100644
index 00000000..4b3bf2e6
--- /dev/null
+++ b/BKUFonts/src/main/fonts/DejaVuLGCSerif.ttf
Binary files differ
diff --git a/BKUFonts/src/main/fonts/LICENSE b/BKUFonts/src/main/fonts/LICENSE
new file mode 100644
index 00000000..254e2cc4
--- /dev/null
+++ b/BKUFonts/src/main/fonts/LICENSE
@@ -0,0 +1,99 @@
+Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
+Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
+
+Bitstream Vera Fonts Copyright
+------------------------------
+
+Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
+a trademark of Bitstream, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of the fonts accompanying this license ("Fonts") and associated
+documentation files (the "Font Software"), to reproduce and distribute the
+Font Software, including without limitation the rights to use, copy, merge,
+publish, distribute, and/or sell copies of the Font Software, and to permit
+persons to whom the Font Software is furnished to do so, subject to the
+following conditions:
+
+The above copyright and trademark notices and this permission notice shall
+be included in all copies of one or more of the Font Software typefaces.
+
+The Font Software may be modified, altered, or added to, and in particular
+the designs of glyphs or characters in the Fonts may be modified and
+additional glyphs or characters may be added to the Fonts, only if the fonts
+are renamed to names not containing either the words "Bitstream" or the word
+"Vera".
+
+This License becomes null and void to the extent applicable to Fonts or Font
+Software that has been modified and is distributed under the "Bitstream
+Vera" names.
+
+The Font Software may be sold as part of a larger software package but no
+copy of one or more of the Font Software typefaces may be sold by itself.
+
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
+TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
+FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
+ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
+FONT SOFTWARE.
+
+Except as contained in this notice, the names of Gnome, the Gnome
+Foundation, and Bitstream Inc., shall not be used in advertising or
+otherwise to promote the sale, use or other dealings in this Font Software
+without prior written authorization from the Gnome Foundation or Bitstream
+Inc., respectively. For further information, contact: fonts at gnome dot
+org.
+
+Arev Fonts Copyright
+------------------------------
+
+Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the fonts accompanying this license ("Fonts") and
+associated documentation files (the "Font Software"), to reproduce
+and distribute the modifications to the Bitstream Vera Font Software,
+including without limitation the rights to use, copy, merge, publish,
+distribute, and/or sell copies of the Font Software, and to permit
+persons to whom the Font Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright and trademark notices and this permission notice
+shall be included in all copies of one or more of the Font Software
+typefaces.
+
+The Font Software may be modified, altered, or added to, and in
+particular the designs of glyphs or characters in the Fonts may be
+modified and additional glyphs or characters may be added to the
+Fonts, only if the fonts are renamed to names not containing either
+the words "Tavmjong Bah" or the word "Arev".
+
+This License becomes null and void to the extent applicable to Fonts
+or Font Software that has been modified and is distributed under the
+"Tavmjong Bah Arev" names.
+
+The Font Software may be sold as part of a larger software package but
+no copy of one or more of the Font Software typefaces may be sold by
+itself.
+
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
+TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
+
+Except as contained in this notice, the name of Tavmjong Bah shall not
+be used in advertising or otherwise to promote the sale, use or other
+dealings in this Font Software without prior written authorization
+from Tavmjong Bah. For further information, contact: tavmjong @ free
+. fr.
+
+$Id: LICENSE 2133 2007-11-28 02:46:28Z lechimp $
diff --git a/BKUFonts/src/main/fonts/META-INF/services/at.gv.egiz.bku.gui.SecureFontProvider b/BKUFonts/src/main/fonts/META-INF/services/at.gv.egiz.bku.gui.SecureFontProvider
new file mode 100644
index 00000000..c9bf2059
--- /dev/null
+++ b/BKUFonts/src/main/fonts/META-INF/services/at.gv.egiz.bku.gui.SecureFontProvider
@@ -0,0 +1,3 @@
+Serif DejaVuLGCSerif.ttf
+Sans DejaVuLGCSans.ttf
+SansMono DejaVuLGCSansMono.ttf
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java
index 1a1426a5..37f30340 100644
--- a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java
@@ -16,14 +16,13 @@
*/
package at.gv.egiz.bku.gui;
-import at.gv.egiz.bku.gui.*;
+import at.gv.egiz.bku.gui.viewer.FontProvider;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.event.ActionListener;
import java.net.URL;
import java.text.MessageFormat;
import java.util.Locale;
-import java.util.ResourceBundle;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
@@ -50,9 +49,10 @@ public class ActivationGUI extends CardMgmtGUI implements ActivationGUIFacade {
Locale locale,
Style guiStyle,
URL backgroundImgURL,
+ FontProvider fontProvider,
AbstractHelpListener helpListener,
SwitchFocusListener switchFocusListener) {
- super(contentPane, locale, guiStyle, backgroundImgURL, helpListener, switchFocusListener);
+ super(contentPane, locale, guiStyle, backgroundImgURL, fontProvider, helpListener, switchFocusListener);
progressBar = new JProgressBar();
}
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java
index 68b2a2ba..98f44d55 100644
--- a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java
@@ -17,7 +17,7 @@
package at.gv.egiz.bku.gui;
-import at.gv.egiz.bku.gui.*;
+import at.gv.egiz.bku.gui.viewer.FontProvider;
import java.awt.Container;
import java.net.URL;
import java.util.Locale;
@@ -38,9 +38,10 @@ public class CardMgmtGUI extends BKUGUIImpl {
Locale locale,
Style guiStyle,
URL backgroundImgURL,
+ FontProvider fontProvider,
AbstractHelpListener helpListener,
SwitchFocusListener switchFocusListener) {
- super(contentPane, locale, guiStyle, backgroundImgURL, helpListener, switchFocusListener);
+ super(contentPane, locale, guiStyle, backgroundImgURL, fontProvider, helpListener, switchFocusListener);
}
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java
index 12f032d8..6699554e 100644
--- a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java
@@ -17,6 +17,7 @@
package at.gv.egiz.bku.gui;
+import at.gv.egiz.bku.gui.viewer.FontProvider;
import at.gv.egiz.smcc.PINSpec;
import java.awt.Container;
import java.awt.Cursor;
@@ -58,9 +59,10 @@ public class PINManagementGUI extends CardMgmtGUI implements PINManagementGUIFac
Locale locale,
Style guiStyle,
URL backgroundImgURL,
+ FontProvider fontProvider,
AbstractHelpListener helpListener,
SwitchFocusListener switchFocusListener) {
- super(contentPane, locale, guiStyle, backgroundImgURL, helpListener, switchFocusListener);
+ super(contentPane, locale, guiStyle, backgroundImgURL, fontProvider, helpListener, switchFocusListener);
}
@Override
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java
index 297173d9..f99bcfd1 100644
--- a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java
@@ -17,7 +17,6 @@
package at.gv.egiz.bku.gui;
-import at.gv.egiz.bku.gui.*;
import at.gv.egiz.smcc.PINSpec;
import java.awt.event.ActionListener;
import java.util.Map;
diff --git a/BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/ActivationGuiTest.java b/BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/ActivationGuiTest.java
index fd562a21..cb05e5f1 100644
--- a/BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/ActivationGuiTest.java
+++ b/BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/ActivationGuiTest.java
@@ -21,7 +21,6 @@
package at.gv.egiz.bku.gui;
-import at.gv.egiz.bku.gui.*;
import java.awt.Container;
import java.awt.Dimension;
import javax.swing.JFrame;
@@ -42,7 +41,7 @@ public class ActivationGuiTest {
Container contentPane = testFrame.getContentPane();
contentPane.setPreferredSize(new Dimension(152, 145));
// contentPane.setPreferredSize(new Dimension(300, 190));
- ActivationGUIFacade gui = new ActivationGUI(contentPane, null, BKUGUIFacade.Style.tiny, null, null, null);
+ ActivationGUIFacade gui = new ActivationGUI(contentPane, null, BKUGUIFacade.Style.tiny, null, new DummyFontLoader(), null, null);
BKUGUIWorker worker = new BKUGUIWorker();
worker.init(gui);
testFrame.pack();
diff --git a/BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java b/BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java
index 74ea8952..b01abe72 100644
--- a/BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java
+++ b/BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java
@@ -20,7 +20,6 @@
*/
package at.gv.egiz.bku.gui;
-import at.gv.egiz.bku.gui.*;
import at.gv.egiz.smcc.PINSpec;
import at.gv.egiz.stal.HashDataInput;
import at.gv.egiz.stal.impl.ByteArrayHashDataInput;
diff --git a/BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/DummyFontLoader.java b/BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/DummyFontLoader.java
new file mode 100644
index 00000000..87d67adc
--- /dev/null
+++ b/BKUGuiExt/src/test/java/at/gv/egiz/bku/gui/DummyFontLoader.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.bku.gui.viewer.FontProviderException;
+import at.gv.egiz.bku.gui.viewer.FontProvider;
+import java.awt.Font;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class DummyFontLoader implements FontProvider {
+
+ @Override
+ public Font getFont() throws FontProviderException {
+ return new Font("monospaced", Font.PLAIN, 10);
+ }
+
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSTALFactory.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSTALFactory.java
index 65a0d5ae..44322a07 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSTALFactory.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSTALFactory.java
@@ -16,33 +16,23 @@
*/
package at.gv.egiz.bku.local.stal;
+import at.gv.egiz.bku.viewer.ResourceFontLoader;
import java.awt.Dimension;
import java.awt.Toolkit;
-import java.awt.event.WindowEvent;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Locale;
import at.gv.egiz.bku.gui.BKUGUIFacade;
-import at.gv.egiz.bku.gui.BKUGUIImpl;
+import at.gv.egiz.bku.gui.BKUIcons;
import at.gv.egiz.bku.gui.PINManagementGUI;
import at.gv.egiz.bku.gui.PINManagementGUIFacade;
import at.gv.egiz.bku.local.gui.GUIProxy;
import at.gv.egiz.bku.local.gui.LocalHelpListener;
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.STALFactory;
-import java.awt.Image;
-import java.awt.Window;
-import java.awt.event.WindowAdapter;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.imageio.ImageIO;
-import javax.swing.ImageIcon;
import javax.swing.JFrame;
-import javax.swing.JRootPane;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -56,25 +46,6 @@ public class LocalSTALFactory implements STALFactory {
protected static final Log log = LogFactory.getLog(LocalSTALFactory.class);
protected static final Dimension PREFERRED_SIZE = new Dimension(318, 200);
- protected static ArrayList<Image> icons = new ArrayList<Image>();
- static {
- String[] iconResources = new String[] {
- "/at/gv/egiz/bku/gui/chip16.png",
- "/at/gv/egiz/bku/gui/chip24.png",
- "/at/gv/egiz/bku/gui/chip32.png",
- "/at/gv/egiz/bku/gui/chip48.png",
- "/at/gv/egiz/bku/gui/chip128.png" };
- for (String ir : iconResources) {
- URL resource = LocalSTALFactory.class.getResource(ir);
- if (ir != null) {
- try {
- icons.add(ImageIO.read(resource));
- } catch (IOException ex) {
- log.warn("failed to set ui dialog icon", ex);
- }
- }
- }
- }
protected String helpURL;
protected Locale locale;
@@ -91,7 +62,7 @@ public class LocalSTALFactory implements STALFactory {
}
// [#439] make mocca dialog alwaysOnTop
dialog.setAlwaysOnTop(true);
- dialog.setIconImages(icons);
+ dialog.setIconImages(BKUIcons.icons);
dialog.setUndecorated(true);
// dialog.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
// dialog.addWindowListener(new WindowAdapter() {
@@ -120,6 +91,7 @@ public class LocalSTALFactory implements STALFactory {
dialog.getLocale(),
BKUGUIFacade.Style.advanced,
null,
+ new ResourceFontLoader(),
helpListener,
null);
BKUGUIFacade proxy = (BKUGUIFacade) GUIProxy.newInstance(gui, dialog, new Class[] { PINManagementGUIFacade.class} );
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip32.png b/BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip32.png
deleted file mode 100644
index e7efb020..00000000
--- a/BKULocal/src/main/resources/at/gv/egiz/bku/gui/chip32.png
+++ /dev/null
Binary files differ
diff --git a/BKUOnline/pom.xml b/BKUOnline/pom.xml
index 408ce195..3d504a8d 100644
--- a/BKUOnline/pom.xml
+++ b/BKUOnline/pom.xml
@@ -128,6 +128,15 @@
<version>1.2.8-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
+ <!--
+ | Transitive dependency from BKUViewer,
+ | set excludeTransitive=false in unpack-fonts
+ <dependency>
+ <groupId>at.gv.egiz</groupId>
+ <artifactId>BKUFonts</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency-->
<dependency>
<groupId>iaik</groupId>
<artifactId>iaik_jce_me4se</artifactId>
@@ -160,6 +169,19 @@
</configuration>
</execution>
<execution>
+ <id>unpack-fonts</id>
+ <goals>
+ <goal>unpack-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/${project.build.finalName}/applet</outputDirectory>
+ <includeGroupIds>at.gv.egiz</includeGroupIds>
+ <includeArtifactIds>BKUFonts</includeArtifactIds>
+ <excludes>META-INF/,LICENSE</excludes>
+ <excludeTransitive>false</excludeTransitive>
+ </configuration>
+ </execution>
+ <execution>
<id>copy-certificates</id>
<goals>
<!-- unpack does not work with release:prepare -->
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
index 9a9bd444..a2447ab7 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
@@ -33,7 +33,6 @@ import at.gv.egiz.stalx.service.translator.STALXTranslationHandler;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Locale;
import javax.xml.bind.JAXBElement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/BKUOnline/src/main/webapp/SLRequestForm.html b/BKUOnline/src/main/webapp/SLRequestForm.html
index f705a0cb..24a88a1e 100644
--- a/BKUOnline/src/main/webapp/SLRequestForm.html
+++ b/BKUOnline/src/main/webapp/SLRequestForm.html
@@ -20,7 +20,7 @@
<title>Security-Layer v1.2 Request Formular</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="img/chip16.ico" type="image/x-icon">
- <script language="JavaScript">
+ <script language="JavaScript" type="text/javascript">
<!--
function setAppletDimension(width, height)
{
@@ -34,13 +34,10 @@
//-->
</script>
<style type="text/css" media="all">@import "css/main.css";</style>
-
- </head>
- <body>
- <h1>Security-Layer v1.2 Request Formular</h1>
<style type="text/css">
fieldset {
padding: 1em;
+ margin: 1em;
font: 80%/ 1 sans-serif;
background-color: #F2EFE9;
padding-left: 5em;
@@ -72,6 +69,9 @@
}
</style>
+ </head>
+ <body>
+ <h1>Security-Layer v1.2 Request Formular</h1>
<p>
<form action="./http-security-layer-request" method="Post"
enctype="application/x-www-form-urlencoded" name="slform">
@@ -110,7 +110,7 @@
<sl:KeyboxIdentifier>SecureSignatureKeypair</sl:KeyboxIdentifier>
<sl:DataObjectInfo Structure="enveloping">
<sl:DataObject>
- <sl:XMLContent>Ich bin ein einfacher Text.</sl:XMLContent>
+ <sl:XMLContent>Ich bin ein einfacher Text. llöäü߀</sl:XMLContent>
</sl:DataObject>
<sl:TransformsInfo>
<sl:FinalDataMetaInfo>
@@ -120,7 +120,27 @@
</sl:DataObjectInfo>
<sl:DataObjectInfo Structure="enveloping">
<sl:DataObject>
- <sl:XMLContent><html xmlns="http://www.w3.org/1999/xhtml"><head><title>TestXHTML</title><style/></head><body><p>Ich bin ein einfacher Text.</p></body></html></sl:XMLContent>
+ <sl:XMLContent>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>TestXHTML</title>
+ <style type="text/css" media="screen">
+ .heading { font-size: large; font-weight: bold; }
+ .content1 { }
+ .content2 { font-style: italic; }
+ .content3 { font-family: serif; }
+ .footer { font-size: small; }
+ </style>
+ </head>
+ <body>
+ <h3 class="heading">Heading3 large bold llöäü߀</h3>
+ <p class="content1">Ich bin ein einfacher Text. llöäü߀</p>
+ <p class="content2">Ich bin ein einfacher Text. llöäü߀</p>
+ <p class="content3">Ich bin ein einfacher Text. llöäü߀</p>
+ <p class="footer">Ich bin ein einfacher Text. llöäü߀</p>
+ </body>
+</html>
+ </sl:XMLContent>
</sl:DataObject>
<sl:TransformsInfo>
<sl:FinalDataMetaInfo>
@@ -145,7 +165,8 @@
</sl10:BinaryFileParameters>
</sl10:InfoboxUpdateRequest>
-->
-
+ </fieldset>
+ <fieldset><legend>Request Parameters</legend>
<p>
<label for="appletGuiStyle">GUI Style</label>
<input type="radio" name="appletGuiStyle" value="tiny" onclick="setAppletDimension(152, 145)">tiny
@@ -185,8 +206,9 @@
name="StylesheetURL" value="" id="StylesheetURL"></p>
<p>
-->
+
</fieldset>
- <fieldset class="submit"><input type="submit" class="submit"></fieldset>
+ <fieldset class="submit"><input type="submit" class="submit"/></fieldset>
</form>
</body>
diff --git a/BKUOnline/src/main/webapp/applet.jsp b/BKUOnline/src/main/webapp/applet.jsp
index 31f3362b..df0b3ca5 100644
--- a/BKUOnline/src/main/webapp/applet.jsp
+++ b/BKUOnline/src/main/webapp/applet.jsp
@@ -72,14 +72,13 @@
%>
<body id="appletpage" style="width:<%=width%>px" onFocus="focusToApplet()">
- <script>
+ <script type="text/javascript">
// avoid selection of applet before it is completely loaded
var allowSelectionByJS = false;
if (!deployJava.versionCheck('1.6.0_04+')) {
- document
- .write('<p>Diese Anwendung benötigt Version 6 Update 4 oder höher der <a href="" onclick="deployJava.installLatestJRE();">Java&trade; Laufzeitumgebung</a>.</p>');
+ document.write('<p>Diese Anwendung benötigt Version 6 Update 4 oder höher der <a href="" onclick="deployJava.installLatestJRE();">Java&trade; Laufzeitumgebung</a>.</p>');
} else {
// to enable applet caching, remove AppletDispatcher servlet,
// change codebase to 'applet',
@@ -105,14 +104,8 @@
RedirectURL : '../bkuResult',
RedirectTarget: '_parent'
};
- var version = '1.6.0_04';
- deployJava.runApplet(attributes, parameters, version);
-
-
+ deployJava.runApplet(attributes, parameters, '1.6.0_04');
}
-
-
-
</script>
</body>
diff --git a/BKUOnline/src/main/webapp/index.html b/BKUOnline/src/main/webapp/index.html
index 5bc01297..b39dafb7 100644
--- a/BKUOnline/src/main/webapp/index.html
+++ b/BKUOnline/src/main/webapp/index.html
@@ -22,6 +22,7 @@
<link rel="shortcut icon" href="img/chip16.ico" type="image/x-icon">
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script src="js/deployJava.js" type="text/javascript"></script>
+ <!--script src="http://java.com/js/deployJava.js" type="text/javascript"></script-->
</head>
<body>
<div id="animDiv" class="box">
@@ -46,7 +47,7 @@
<p>
<h1>MOCCA Web Start</h1>
<p>
- <script>
+ <script type="text/javascript">
var url="webstart/mocca.jnlp"
deployJava.createWebStartLaunchButton(url, "1.6")
</script></p>
diff --git a/BKUOnline/src/main/webapp/js/deployJava_orig.js b/BKUOnline/src/main/webapp/js/deployJava_orig.js
new file mode 100644
index 00000000..316fa278
--- /dev/null
+++ b/BKUOnline/src/main/webapp/js/deployJava_orig.js
@@ -0,0 +1,725 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Sun Microsystems nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Added by EGIZ:
+ * This file contains workarounds to
+ * [#423] Firefox 3.0.11 bug #498132 causes applet loading failure
+ * (lines 95-99)
+ * [#424] Web Start loading via java plugin (Sun deployment script) fails on WinXP/Vista
+ * (lines 501-506)
+ *
+ * features:
+ * [#425] Disable WebStart Launch Button for MacOS
+ * (lines 492-504)
+ *
+ */
+
+/*
+ * deployJava.js
+ *
+ * This file is part of the Deployment Toolkit. It provides functions for web
+ * pages to detect the presence of a JRE, install the latest JRE, and easily run
+ * applets or Web Start programs. Usage guide may be found at http://<TBD>/.
+ *
+ * The "live" copy of this file may be found at
+ * http://java.com/js/deployJava.js.
+ * You are encouraged to link directly to the live copy of the file.
+ *
+ * @version @(#)deployJava.js XXXXX
+ */
+
+var deployJava={
+ debug:null,
+
+ myInterval:null,
+ preInstallJREList:null,
+ returnPage:null,
+ brand:null,
+ locale:null,
+ installType:null,
+
+ EAInstallEnabled:false,
+ EarlyAccessURL:null,
+
+ // GetJava page
+ getJavaURL:'http://java.sun.com/webapps/getjava/BrowserRedirect?host=java.com',
+
+ // Apple redirect page
+ appleRedirectPage:'http://www.apple.com/support/downloads/',
+ oldMimeType:'application/npruntime-scriptable-plugin;DeploymentToolkit',
+ mimeType:'application/java-deployment-toolkit',
+ launchButtonPNG:'http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png',
+
+ getJREs:function(){
+ var list=new Array();
+ if(deployJava.isPluginInstalled()){
+ var plugin=deployJava.getPlugin();
+ var VMs=plugin.jvms;
+ for(var i=0;i<VMs.getLength();i++){
+ list[i]=VMs.get(i).version;
+ }
+ }else{
+ var browser=deployJava.getBrowser();
+
+ if(browser=='MSIE'){
+ if(deployJava.testUsingActiveX('1.8.0')){
+ list[0]='1.8.0';
+ }else if(deployJava.testUsingActiveX('1.7.0')){
+ list[0]='1.7.0';
+ }else if(deployJava.testUsingActiveX('1.6.0')){
+ list[0]='1.6.0';
+ }else if(deployJava.testUsingActiveX('1.5.0')){
+ list[0]='1.5.0';
+ }else if(deployJava.testUsingActiveX('1.4.2')){
+ list[0]='1.4.2';
+ }else if(deployJava.testForMSVM()){
+ list[0]='1.1';
+ }
+ }
+ else if(browser=='Netscape Family'){
+ if(deployJava.testUsingMimeTypes('1.8')){
+ list[0]='1.8.0';
+ }else if(deployJava.testUsingMimeTypes('1.7')){
+ list[0]='1.7.0';
+ }else if(deployJava.testUsingMimeTypes('1.6')){
+ list[0]='1.6.0';
+ }else if(deployJava.testUsingMimeTypes('1.5')){
+ list[0]='1.5.0';
+ }else if(deployJava.testUsingMimeTypes('1.4.2')){
+ list[0]='1.4.2';
+ }
+ }else if(browser=='Safari'){
+ if(deployJava.testUsingPluginsArray('1.8.0')){
+ list[0]='1.8.0';
+ }else if(deployJava.testUsingPluginsArray('1.7.0')){
+ list[0]='1.7.0';
+ }else if(deployJava.testUsingPluginsArray('1.6.0')){
+ list[0]='1.6.0';
+ }else if(deployJava.testUsingPluginsArray('1.5.0')){
+ list[0]='1.5.0';
+ }else if(deployJava.testUsingPluginsArray('1.4.2')){
+ list[0]='1.4.2';
+ }
+ }
+ }
+
+ if(deployJava.debug){
+ for(var i=0;i<list.length;++i){
+ alert('We claim to have detected Java SE '+list[i]);
+ }
+ }
+
+ return list;
+ },
+
+ installJRE:function(requestVersion){
+ var ret=false;
+ if(deployJava.isPluginInstalled()){
+ if(deployJava.getPlugin().installJRE(requestVersion)){
+ deployJava.refresh();
+ if(deployJava.returnPage!=null){
+ document.location=deployJava.returnPage;
+ }
+ return true;
+ }else{
+ return false;
+ }
+ }else{
+ return deployJava.installLatestJRE();
+ }
+ },
+
+ installLatestJRE:function(){
+ if(deployJava.isPluginInstalled()){
+ if(deployJava.getPlugin().installLatestJRE()){
+ deployJava.refresh();
+ if(deployJava.returnPage!=null){
+ document.location=deployJava.returnPage;
+ }
+ return true;
+ }else{
+ return false;
+ }
+ }else{
+ var browser=deployJava.getBrowser();
+ var platform=navigator.platform.toLowerCase();
+ if((deployJava.EAInstallEnabled=='true') &&
+ (platform.indexOf('win')!=-1) &&
+ (deployJava.EarlyAccessURL!=null)) {
+
+ deployJava.preInstallJREList=deployJava.getJREs();
+ if(deployJava.returnPage!=null){
+ deployJava.myInterval=
+ setInterval("deployJava.poll()",3000);
+ }
+
+ location.href=deployJava.EarlyAccessURL;
+ return false;
+ }else{
+ if(browser=='MSIE'){
+ return deployJava.IEInstall();
+ }else if((browser=='Netscape Family')&&
+ (platform.indexOf('win32')!=-1)){
+ return deployJava.FFInstall();
+ }else{
+ location.href=deployJava.getJavaURL+
+ ((deployJava.returnPage!=null)?
+ ('&returnPage='+deployJava.returnPage):'')+
+ ((deployJava.locale!=null)?
+ ('&locale='+deployJava.locale):'')+
+ ((deployJava.brand!=null)?
+ ('&brand='+deployJava.brand):'');
+ }
+ return false;
+ }
+ }
+ },
+
+ runApplet:function(attributes,parameters,minimumVersion){
+ if(minimumVersion=='undefined'||minimumVersion==null){
+ minimumVersion='1.1';
+ }
+
+ var regex="^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
+
+ var matchData=minimumVersion.match(regex);
+
+ if(deployJava.returnPage==null){
+ deployJava.returnPage=document.location;
+ }
+
+ if(matchData!=null){
+ var browser=deployJava.getBrowser();
+ if((browser!='?')&&(browser!='Safari')){
+ if(deployJava.versionCheck(minimumVersion+'+')){
+ deployJava.writeAppletTag(attributes,parameters);
+ }else if(deployJava.installJRE(minimumVersion+'+')){
+ deployJava.refresh();
+ location.href=document.location;
+ deployJava.writeAppletTag(attributes,parameters);
+ }
+ }else{
+ deployJava.writeAppletTag(attributes,parameters);
+ }
+ }else{
+ if(deployJava.debug){
+ alert('Invalid minimumVersion argument to runApplet():'+
+ minimumVersion);
+ }
+ }
+ },
+
+ writeAppletTag:function(attributes,parameters){
+ var s='<'+'applet ';
+ for(var attribute in attributes){
+ s+=(' '+attribute+'="'+attributes[attribute]+'"');
+ }
+ s+='>';
+ document.write(s);
+
+ if(parameters!='undefined'&&parameters!=null){
+ var codebaseParam=false;
+ for(var parameter in parameters){
+ if(parameter=='codebase_lookup'){
+ codebaseParam=true;
+ }
+ s='<param name="'+parameter+'" value="'+
+ parameters[parameter]+'">';
+ document.write(s);
+ }
+ if(!codebaseParam){
+ document.write('<param name="codebase_lookup" value="false">');
+ }
+ }
+ document.write('<'+'/'+'applet'+'>');
+ },
+
+ versionCheck:function(versionPattern)
+
+ {
+ var index=0;
+ var regex="^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?(\\*|\\+)?$";
+
+ var matchData=versionPattern.match(regex);
+
+ if(matchData!=null){
+ var familyMatch=true;
+
+ var patternArray=new Array();
+
+ for(var i=1;i<matchData.length;++i){
+ if((typeof matchData[i]=='string')&&(matchData[i]!='')){
+ patternArray[index]=matchData[i];
+ index++;
+ }
+ }
+
+ if(patternArray[patternArray.length-1]=='+'){
+ familyMatch=false;
+ patternArray.length--;
+ }else{
+ if(patternArray[patternArray.length-1]=='*'){
+ patternArray.length--;
+ }
+ }
+
+ var list=deployJava.getJREs();
+ for(var i=0;i<list.length;++i){
+ if(deployJava.compareVersionToPattern(list[i],patternArray,
+ familyMatch)){
+ return true;
+ }
+ }
+
+ return false;
+ }else{
+ alert('Invalid versionPattern passed to versionCheck: '+
+ versionPattern);
+ return false;
+ }
+ },
+
+ isWebStartInstalled:function(minimumVersion){
+
+ var browser=deployJava.getBrowser();
+ if((browser=='?')||(browser=='Safari')){
+ return true;
+ }
+
+ if(minimumVersion=='undefined'||minimumVersion==null){
+ minimumVersion='1.4.2';
+ }
+
+ var retval=false;
+ var regex="^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
+ var matchData=minimumVersion.match(regex);
+
+ if(matchData!=null){
+ retval=deployJava.versionCheck(minimumVersion+'+');
+ }else{
+ if(deployJava.debug){
+ alert('Invalid minimumVersion argument to isWebStartInstalled(): '+minimumVersion);
+ }
+ retval=deployJava.versionCheck('1.4.2+');
+ }
+ return retval;
+ },
+
+ createWebStartLaunchButton:function(jnlp,minimumVersion){
+
+ if(deployJava.returnPage==null){
+ deployJava.returnPage=jnlp;
+ }
+ var url='javascript:'+'if (!deployJava.isWebStartInstalled(&quot;'+
+ minimumVersion+'&quot;)) {'+'if (deployJava.installLatestJRE()) {'+'if (deployJava.launch(&quot;'+jnlp+'&quot;)) {}'+'}'+'} else {'+'if (deployJava.launch(&quot;'+jnlp+'&quot;)) {}'+'}';document.write('<'+'a href="'+url+'" onMouseOver="window.status=\'\'; '+'return true;"><'+'img '+'src="'+deployJava.launchButtonPNG+'" '+'border="0" /><'+'/'+'a'+'>');
+ },
+
+ launch:function(jnlp){
+ if(deployJava.isPluginInstalled()){
+ return deployJava.getPlugin().launch(jnlp);
+ }else{
+ document.location=jnlp;return true;
+ }
+ },
+
+ isPluginInstalled:function(){
+ var plugin=deployJava.getPlugin();
+ if(plugin&&plugin.jvms){
+ return true;
+ }else{
+ return false;
+ }
+ },
+
+ isAutoUpdateEnabled:function(){
+ if(deployJava.isPluginInstalled()){
+ return deployJava.getPlugin().isAutoUpdateEnabled();
+ }
+ return false;
+ },
+
+ setAutoUpdateEnabled:function(){
+ if(deployJava.isPluginInstalled()){
+ return deployJava.getPlugin().setAutoUpdateEnabled();
+ }
+ return false;
+ },
+
+ setInstallerType:function(type){
+ deployJava.installType=type;
+ if(deployJava.isPluginInstalled()){
+ return deployJava.getPlugin().setInstallerType(type);
+ }
+ return false;
+ },
+
+ setAdditionalPackages:function(packageList){
+ if(deployJava.isPluginInstalled()){
+ return deployJava.getPlugin().setAdditionalPackages(
+ packageList);
+ }
+ return false;
+ },
+
+ setEarlyAccess:function(enabled){
+ deployJava.EAInstallEnabled=enabled;
+ },
+
+ isPlugin2:function(){
+ if(deployJava.isPluginInstalled()){
+ if(deployJava.versionCheck('1.6.0_10+')){
+ try{
+ return deployJava.getPlugin().isPlugin2();
+ }catch(err){
+
+ }
+ }
+ }
+ return false;
+ },
+
+
+ getPlugin:function(){
+ deployJava.refresh();
+ var ret=document.getElementById('deployJavaPlugin');
+ return ret;
+ },
+
+ compareVersionToPattern:function(version,patternArray,familyMatch){
+ var regex="^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
+ var matchData=version.match(regex);
+
+ if(matchData!=null){
+ var index=0;
+ var result=new Array();
+
+ for(var i=1;i<matchData.length;++i){
+ if((typeof matchData[i]=='string')&&(matchData[i]!=''))
+ {
+ result[index]=matchData[i];
+ index++;
+ }
+ }
+
+ var l=Math.min(result.length,patternArray.length);
+
+ if(familyMatch){
+ for(var i=0;i<l;++i){
+ if(result[i]!=patternArray[i])return false;
+ }
+
+ return true;
+ }else{
+ for(var i=0;i<l;++i){
+ if(result[i]<patternArray[i]){
+ return false;
+ }else if(result[i]>patternArray[i]){
+ return true;
+ }
+ }
+
+ return true;
+ }
+ }else{
+ return false;
+ }
+ },
+
+
+ getBrowser:function(){
+ var browser=navigator.userAgent.toLowerCase();
+
+ if(deployJava.debug){
+ alert('userAgent -> '+browser);
+ }
+
+ if((navigator.vendor)&&
+ (navigator.vendor.toLowerCase().indexOf('apple')!=-1)&&
+ (browser.indexOf('safari')!=-1)){
+ if(deployJava.debug){
+ alert('We claim to have detected "Safari".');
+ }
+ return'Safari';
+ }else if(browser.indexOf('msie')!=-1){
+ if(deployJava.debug){
+ alert('We claim to have detected "IE".');
+ }
+ return'MSIE';
+ }else if((browser.indexOf('mozilla')!=-1)||
+ (browser.indexOf('firefox')!=-1)){
+ if(deployJava.debug){
+ alert('We claim to have detected a Netscape family browser.');
+ }
+ return'Netscape Family';
+ }else{
+ if(deployJava.debug){
+ alert('We claim to have failed to detect a browser.');
+ }
+ return'?';
+ }
+ },
+
+
+ testUsingActiveX:function(version){
+ var objectName='JavaWebStart.isInstalled.'+version+'.0';
+
+ if(!ActiveXObject){
+ if(deployJava.debug){
+ alert('Browser claims to be IE, but no ActiveXObject object?');
+ }
+ return false;
+ }
+
+ try{
+ return(new ActiveXObject(objectName)!=null);
+ }catch(exception){
+ return false;
+ }
+ },
+
+
+ testForMSVM:function(){
+ var clsid='{08B0E5C0-4FCB-11CF-AAA5-00401C608500}';
+
+ if(typeof oClientCaps!='undefined'){
+ var v=oClientCaps.getComponentVersion(clsid,"ComponentID");
+ if((v=='')||(v=='5,0,5000,0')){
+ return false;
+ }else{
+ return true;
+ }
+ }else{
+ return false;
+ }
+ },
+
+
+ testUsingMimeTypes:function(version){
+ if(!navigator.mimeTypes){
+ if(deployJava.debug){
+ alert('Browser claims to be Netscape family, but no mimeTypes[] array?');
+ }
+ return false;
+ }
+
+ for(var i=0;i<navigator.mimeTypes.length;++i){
+ s=navigator.mimeTypes[i].type;
+ var m=s.match(/^application\/x-java-applet\x3Bversion=(1\.8|1\.7|1\.6|1\.5|1\.4\.2)$/);
+ if(m!=null){
+ if(deployJava.compareVersions(m[1],version)){
+ return true;
+ }
+ }
+ }
+ return false;
+ },
+
+
+ testUsingPluginsArray:function(version){
+ if((!navigator.plugins)||(!navigator.plugins.length)){
+ return false;
+ }
+ var platform=navigator.platform.toLowerCase();
+ for(var i=0;i<navigator.plugins.length;++i){
+ s=navigator.plugins[i].description;
+
+ if(s.search(/^Java Switchable Plug-in (Cocoa)/)!=-1){
+ if(deployJava.compareVersions("1.5.0",version)){
+ return true;
+ }
+ }else if(s.search(/^Java/)!=-1){
+ if(platform.indexOf('win')!=-1){
+ if(deployJava.compareVersions("1.5.0",version)||deployJava.compareVersions("1.6.0",version)){
+ return true;
+ }
+ }
+ }
+ }
+ if(deployJava.compareVersions("1.5.0",version)){
+ return true;
+ }
+ return false;
+ },
+
+ IEInstall:function(){
+
+ location.href=deployJava.getJavaURL+
+ ((deployJava.returnPage!=null)?
+ ('&returnPage='+deployJava.returnPage):'')+
+ ((deployJava.locale!=null)?
+ ('&locale='+deployJava.locale):'')+
+ ((deployJava.brand!=null)?('&brand='+deployJava.brand):'')+
+ ((deployJava.installType!=null)?
+ ('&type='+deployJava.installType):'');
+ return false;
+ },
+
+ done:function(name,result){
+ },
+
+ FFInstall:function(){
+
+ location.href=deployJava.getJavaURL+
+ ((deployJava.returnPage!=null)?
+ ('&returnPage='+deployJava.returnPage):'')+
+ ((deployJava.locale!=null)?
+ ('&locale='+deployJava.locale):'')+
+ ((deployJava.brand!=null)?('&brand='+deployJava.brand):'')+
+ ((deployJava.installType!=null)?
+ ('&type='+deployJava.installType):'');
+ return false;
+ },
+
+ compareVersions:function(installed,required){
+
+ var a=installed.split('.');
+ var b=required.split('.');
+
+ for(var i=0;i<a.length;++i){
+ a[i]=Number(a[i]);
+ }
+ for(var i=0;i<b.length;++i){
+ b[i]=Number(b[i]);
+ }
+ if(a.length==2){
+ a[2]=0;
+ }
+
+ if(a[0]>b[0])return true;
+ if(a[0]<b[0])return false;
+
+ if(a[1]>b[1])return true;
+ if(a[1]<b[1])return false;
+
+ if(a[2]>b[2])return true;
+ if(a[2]<b[2])return false;
+
+ return true;
+ },
+
+
+ enableAlerts:function(){
+ deployJava.debug=true;
+ },
+
+ poll:function(){
+
+ deployJava.refresh();
+ var postInstallJREList=deployJava.getJREs();
+
+ if((deployJava.preInstallJREList.length==0)&&
+ (postInstallJREList.length!=0)){
+ clearInterval(deployJava.myInterval);
+ if(deployJava.returnPage!=null){
+ location.href=deployJava.returnPage;
+ };
+ }
+
+ if((deployJava.preInstallJREList.length!=0)&&
+ (postInstallJREList.length!=0)&&
+ (deployJava.preInstallJREList[0]!=postInstallJREList[0])){
+ clearInterval(deployJava.myInterval);
+ if(deployJava.returnPage!=null){
+ location.href=deployJava.returnPage;
+ }
+ }
+
+ },
+
+ writePluginTag:function(){
+ var browser=deployJava.getBrowser();
+ if(browser=='MSIE'){
+ document.write('<'+
+ 'object classid="clsid:CAFEEFAC-DEC7-0000-0000-ABCDEFFEDCBA" '+
+ 'id="deployJavaPlugin" width="0" height="0">'+
+ '<'+'/'+'object'+'>');
+ }else if(browser=='Netscape Family'){
+ deployJava.writeEmbedTag();
+ }
+ },
+
+ refresh:function(){
+ navigator.plugins.refresh(false);var browser=deployJava.getBrowser();if(browser=='Netscape Family'){
+ var plugin=document.getElementById('deployJavaPlugin');if(plugin==null){
+ deployJava.writeEmbedTag();
+ }
+ }
+ },
+
+ writeEmbedTag:function(){
+ var written=false;if(navigator.mimeTypes!=null){
+ for(var i=0;i<navigator.mimeTypes.length;i++){
+ if(navigator.mimeTypes[i].type==deployJava.mimeType){
+ if(navigator.mimeTypes[i].enabledPlugin){
+ document.write('<'+'embed id="deployJavaPlugin" type="'+
+ deployJava.mimeType+'" hidden="true" />');written=true;
+ }
+ }
+ }
+ if(!written)for(var i=0;i<navigator.mimeTypes.length;i++){
+ if(navigator.mimeTypes[i].type==deployJava.oldMimeType){
+ if(navigator.mimeTypes[i].enabledPlugin){
+ document.write('<'+'embed id="deployJavaPlugin" type="'+
+ deployJava.oldMimeType+'" hidden="true" />');
+ }
+ }
+ }
+ }
+ },
+
+ do_initialize:function(){
+ deployJava.writePluginTag();
+ if(deployJava.locale==null){
+ var loc=null;
+
+ if(loc==null)try{
+ loc=navigator.userLanguage;
+ }catch(err){}
+
+ if(loc==null)try{
+ loc=navigator.systemLanguage;
+ }catch(err){}
+
+ if(loc==null)try{
+ loc=navigator.language;
+ }catch(err){}
+
+ if(loc!=null){
+ loc.replace("-","_")
+ deployJava.locale=loc;
+ }
+ }
+ }
+
+ };
+ deployJava.do_initialize();
+
diff --git a/BKUViewer/pom.xml b/BKUViewer/pom.xml
index 24605880..579d12f0 100644
--- a/BKUViewer/pom.xml
+++ b/BKUViewer/pom.xml
@@ -39,13 +39,10 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>at.gv.egiz</groupId>
+ <artifactId>BKUFonts</artifactId>
+ <version>1.0</version>
+ </dependency>
</dependencies>
- <!--build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId> <configuration>
- <skip>true</skip> </configuration> </plugin>
- </plugins>
- </build-->
-</project> \ No newline at end of file
+</project>
diff --git a/BKUViewer/src/main/java/at/gv/egiz/bku/text/TextValidator.java b/BKUViewer/src/main/java/at/gv/egiz/bku/text/TextValidator.java
index 485aa727..dee8ff2e 100644
--- a/BKUViewer/src/main/java/at/gv/egiz/bku/text/TextValidator.java
+++ b/BKUViewer/src/main/java/at/gv/egiz/bku/text/TextValidator.java
@@ -16,20 +16,21 @@
*/
package at.gv.egiz.bku.text;
+import at.gv.egiz.bku.gui.viewer.FontProviderException;
+import at.gv.egiz.bku.viewer.ResourceFontLoader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.UnsupportedCharsetException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import at.gv.egiz.bku.viewer.ValidationException;
import at.gv.egiz.bku.viewer.Validator;
+import java.awt.Font;
public class TextValidator implements Validator {
@@ -37,7 +38,13 @@ public class TextValidator implements Validator {
* Logging facility.
*/
protected static Log log = LogFactory.getLog(TextValidator.class);
-
+
+ protected Font viewerFont;
+
+ public TextValidator() throws FontProviderException {
+ viewerFont = new ResourceFontLoader().getFont();
+ }
+
private void invalid(char c) throws ValidationException {
log.info("Invalid character (0x" + Integer.toHexString(c) + ") found.");
// TODO: localize
@@ -68,30 +75,7 @@ public class TextValidator implements Validator {
cb.flip();
for (int i = 0; i < l; i++) {
c = cb.get();
- if (c < '\u0020') {
- // C0 Controls and Basic Latin (0x000C-0x000D)
- if (c > '\r') invalid(c); if (c >= '\u000C') continue;
- // C0 Controls and Basic Latin (0x0009-0x000A)
- if (c > '\n') invalid(c); if (c >= '\t') continue;
- invalid(c);
- } else {
- // C0 Controls and Basic Latin (0x0020-0x007E)
- if (c <= '\u007E') continue;
- // C1 Controls and Latin-1 Supplement (0x00A1-0x00FF)
- if (c < '\u00A1') invalid(c); if (c <= '\u00FF') continue;
- // Latin Extended-A (0x0100-0x017F)
- if (c < '\u0100') invalid(c); if (c <= '\u017F') continue;
- // EURO Sign
- if (c == '\u20AC') continue;
- // Spacing Modifier Letters
- if (c == '\u02C7') continue;
- if (c == '\u02D8') continue;
- if (c == '\u02D9') continue;
- if (c == '\u02DB') continue;
- if (c == '\u02DD') continue;
- if (c == '\u2015') continue;
- invalid(c);
- }
+ if (!viewerFont.canDisplay(c)) invalid(c);
}
}
cb.clear();
diff --git a/BKUViewer/src/test/java/at/gv/egiz/bku/text/TestTextValidator.java b/BKUViewer/src/test/java/at/gv/egiz/bku/text/TestTextValidator.java
index 7137911d..8db459e7 100644
--- a/BKUViewer/src/test/java/at/gv/egiz/bku/text/TestTextValidator.java
+++ b/BKUViewer/src/test/java/at/gv/egiz/bku/text/TestTextValidator.java
@@ -1,19 +1,19 @@
/*
-* Copyright 2008 Federal Chancellery Austria and
-* Graz University of Technology
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package at.gv.egiz.bku.text;
import static org.junit.Assert.*;
@@ -35,7 +35,7 @@ import at.gv.egiz.bku.viewer.ValidatorFactory;
public class TestTextValidator {
public static byte[] generateText(String encoding) throws UnsupportedEncodingException {
-
+
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(bos, encoding));
@@ -45,11 +45,15 @@ public class TestTextValidator {
writer.write(c);
}
writer.write("\n");
- writer.write("C0 Controls and Basic Latin 0x000C-0x000D");
+ // errata: don't include FORM FEED (0x000C)
+ writer.write("C0 Controls and Basic Latin 0x000D");
writer.write("\n");
- for (char c = '\f'; c <= '\r'; c++) {
- writer.write(c);
- }
+
+// for (char c = '\f'; c <= '\r'; c++) {
+// writer.write(c);
+// }
+
+ writer.write("\r");
writer.write("\n");
writer.write("C0 Controls and Basic Latin 0x0020-0x007E");
writer.write("\n");
@@ -97,23 +101,23 @@ public class TestTextValidator {
writer.write("\n");
writer.write("\u20AC");
writer.flush();
-
+
return bos.toByteArray();
-
+
}
-
+
public void testTextValidation(String encoding) throws ValidationException, UnsupportedEncodingException {
-
+
Validator validator = ValidatorFactory.newValidator("text/plain");
-
+
assertNotNull(validator);
InputStream is = new ByteArrayInputStream(generateText(encoding));
-
+
assertNotNull(is);
-
+
validator.validate(is, encoding);
-
+
}
@Test
@@ -151,5 +155,64 @@ public class TestTextValidator {
public void testISO8859_15() throws ValidationException, UnsupportedEncodingException {
testTextValidation("ISO-8859-15");
}
-
+
+ @Test
+ public void testPerformance() throws UnsupportedEncodingException, ValidationException {
+ Validator validator = ValidatorFactory.newValidator("text/plain");
+
+ assertNotNull(validator);
+
+ //!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљњћќѝўџҐґҒғҔҕҖҗҘҙҚқҰұҲҳӀӁӂӃӄӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹ
+
+ StringBuilder data = new StringBuilder();
+ //LATIN
+ for (int i = 0x0021; i <= 0x007e; i++) {
+ data.append((char) i);
+ }
+ //LATIN supplement
+ for (int i = 0x00A1; i <= 0x00FF; i++) {
+ data.append((char) i);
+ }
+ //GREEK
+ for (int i = 0x038e; i <= 0x03a1; i++) {
+ data.append((char) i);
+ }
+ for (int i = 0x03a3; i <= 0x03ce; i++) {
+ data.append((char) i);
+ }
+ for (int i = 0x03d0; i <= 0x03e1; i++) {
+ data.append((char) i);
+ }
+ //CYRILLIC
+ for (int i = 0x0400; i <= 0x045f; i++) {
+ data.append((char) i);
+ }
+ for (int i = 0x0490; i <= 0x049b; i++) {
+ data.append((char) i);
+ }
+ for (int i = 0x04b0; i <= 0x04b3; i++) {
+ data.append((char) i);
+ }
+ for (int i = 0x04c0; i <= 0x04c4; i++) {
+ data.append((char) i);
+ }
+ for (int i = 0x04d0; i <= 0x04f9; i++) {
+ data.append((char) i);
+ }
+
+ StringBuilder aLotOfData = new StringBuilder();
+ for (int i = 0; i < 1000; i++) {
+ aLotOfData.append('\n');
+ aLotOfData.append(data);
+ }
+ String aLotOfText = aLotOfData.toString();
+ System.out.println("validating " + aLotOfText.length() + " weird characters: " + aLotOfText);
+
+ InputStream is = new ByteArrayInputStream(aLotOfText.getBytes("UTF-8"));
+
+ assertNotNull(is);
+
+ validator.validate(is, "UTF-8");
+
+ }
}
diff --git a/bkucommon/pom.xml b/bkucommon/pom.xml
index bb696fba..e878f155 100644
--- a/bkucommon/pom.xml
+++ b/bkucommon/pom.xml
@@ -49,13 +49,19 @@
<dependency>
<groupId>at.gv.egiz</groupId>
<artifactId>utils</artifactId>
- <version>1.2.8-SNAPSHOT</version>
+ <version>${version}</version>
</dependency>
<dependency>
<groupId>at.gv.egiz</groupId>
<artifactId>STALExt</artifactId>
- <version>1.2.8-SNAPSHOT</version>
+ <version>${version}</version>
</dependency>
+ <!-- bkucommon implements default FontProvider (ResourceFontLoader) -->
+ <dependency>
+ <groupId>at.gv.egiz</groupId>
+ <artifactId>BKUCommonGUI</artifactId>
+ <version>${version}</version>
+ </dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ResourceFontLoader.java b/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ResourceFontLoader.java
new file mode 100644
index 00000000..8cab581d
--- /dev/null
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ResourceFontLoader.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.viewer;
+
+import at.gv.egiz.bku.gui.viewer.FontProviderException;
+import at.gv.egiz.bku.gui.viewer.FontProvider;
+import java.awt.Font;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Loads font(s) as classpath resource.
+ * Loaded fonts are shared within all instances in this VM (classloader)
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class ResourceFontLoader implements FontProvider {
+
+ public static final String FONT_RESOURCE = "DejaVuLGCSansMono.ttf";
+
+ protected final static Log log = LogFactory.getLog(ResourceFontLoader.class);
+
+ /** TextValidator and (local) SecureViewerDialog (see LocalStalFactory) use ResourceFontLoader, load resource only once */
+ protected static Font font;
+
+ /**
+ *
+ * @return
+ * @throws FontProviderException encapsulating FontFormatException (if resource doesn't contain the plain format)
+ * or IOException (if resource cannot be retrieved)
+ */
+ @Override
+ public Font getFont() throws FontProviderException {
+ if (font == null) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("loading " + getClass().getClassLoader().getResource(FONT_RESOURCE));
+ }
+ font = Font.createFont(Font.PLAIN, getClass().getClassLoader().getResourceAsStream(FONT_RESOURCE));
+ } catch (Exception ex) {
+ log.error("failed to load font", ex);
+ throw new FontProviderException("failed to load font", ex);
+ }
+ }
+ log.trace("font resource loaded");
+ return font;
+ }
+}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java
index e16a261e..ad9bf6bb 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java
@@ -17,6 +17,8 @@
package at.gv.egiz.bku.viewer;
import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
@@ -108,14 +110,25 @@ public class ValidatorFactory {
return null;
}
-
+
+ /**
+ *
+ * @throws InvocationTargetException if className's (nullary) constructor throws exception
+ */
private Validator createValidatorInstance(String className)
throws ClassNotFoundException, InstantiationException,
- IllegalAccessException {
-
+ IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
try {
- Class<?> implClass = classLoader.loadClass(className);
- return (Validator) implClass.newInstance();
+ Constructor<?> implConstructor = classLoader.loadClass(className).getConstructor((Class[])null);
+ return (Validator) implConstructor.newInstance((Object[])null);
+ } catch (InvocationTargetException ex) {
+ //ex from constructor
+ log.error("Failed to initialize validator class '" + className + "': " + ex.getCause().getMessage(), ex.getCause());
+ throw ex;
+ } catch (NoSuchMethodException ex) {
+ log.error("Validator class '" + className + "' has no nullary constructor", ex);
+ throw ex;
} catch (ClassNotFoundException e) {
log.error("Validator class '" + className + "' not found.", e);
throw e;
diff --git a/pom.xml b/pom.xml
index e1b6843b..34fcfaa1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,6 +28,7 @@
<module>BKUGuiExt</module>
<module>smccSTALExt</module>
<!--module>BKUWebStartPackage</module-->
+ <module>BKUFonts</module>
</modules>
<developers>
<developer>