diff options
Diffstat (limited to 'BKUWebStart/src/main/java/at/gv')
5 files changed, 215 insertions, 12 deletions
diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/GetCertificateInvoker.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/GetCertificateInvoker.java new file mode 100644 index 00000000..888206a6 --- /dev/null +++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/GetCertificateInvoker.java @@ -0,0 +1,76 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint + * initiative of the Federal Chancellery Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + +package at.gv.egiz.bku.webstart; + +import java.io.IOException; +import java.net.HttpURLConnection; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.bku.webstart.gui.StatusNotifier; + +/** +* +* @author Thomas Lenz <thomas.lenz@iaik.tugraz.at> +*/ + +public class GetCertificateInvoker implements Runnable { + + private static final Logger log = LoggerFactory.getLogger(GetCertificateInvoker.class); + + StatusNotifier status; + + public GetCertificateInvoker(StatusNotifier status) { + this.status = status; + } + + @Override + public void run() { + HttpURLConnection connection = null; + try { + log.debug("Connecting to: " + Launcher.GETCERTIFICATE_URL); + + connection = (HttpURLConnection) Launcher.GETCERTIFICATE_URL.openConnection(); + + connection.setRequestMethod("GET"); + connection.setReadTimeout(0); + connection.connect(); + + if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { + log.debug("get-certificate dialog returned"); + } else { + log.error("unexpected response from get-certificate dialog: " + connection.getResponseMessage()); + } + } catch (IOException ex) { + log.error("Failed to connect to get-certificate dialog", ex); + status.error(StatusNotifier.ERROR_PIN); + } finally { + if (connection != null) { + connection.disconnect(); + } + } + } + +} diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/HardwareInfoInvoker.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/HardwareInfoInvoker.java new file mode 100644 index 00000000..6baabfe1 --- /dev/null +++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/HardwareInfoInvoker.java @@ -0,0 +1,76 @@ +/* + * Copyright 2012 by Graz University of Technology, Austria + * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint + * initiative of the Federal Chancellery Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + +package at.gv.egiz.bku.webstart; + +import java.io.IOException; +import java.net.HttpURLConnection; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.bku.webstart.gui.StatusNotifier; + +/** +* +* @author Thomas Lenz <thomas.lenz@iaik.tugraz.at> +*/ + +public class HardwareInfoInvoker implements Runnable { + + private static final Logger log = LoggerFactory.getLogger(HardwareInfoInvoker.class); + + StatusNotifier status; + + public HardwareInfoInvoker(StatusNotifier status) { + this.status = status; + } + + @Override + public void run() { + HttpURLConnection connection = null; + try { + log.debug("Connecting to: " + Launcher.HARDWAREINFO_URL); + + connection = (HttpURLConnection) Launcher.HARDWAREINFO_URL.openConnection(); + + connection.setRequestMethod("GET"); + connection.setReadTimeout(0); + connection.connect(); + + if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { + log.debug("hardware-info dialog returned"); + } else { + log.error("unexpected response from hardware-info dialog: " + connection.getResponseMessage()); + } + } catch (IOException ex) { + log.error("Failed to connect to hardware-info dialog", ex); + status.error(StatusNotifier.ERROR_PIN); + } finally { + if (connection != null) { + connection.disconnect(); + } + } + } + +} diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java index 2719e990..0e510e2f 100644 --- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java +++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/Launcher.java @@ -66,19 +66,25 @@ public class Launcher implements BKUControllerInterface { public static final URL INSTALL_CERT_URL; public static final URL PIN_MANAGEMENT_URL; public static final URL IDENTITY_LINK_URL; + public static final URL GETCERTIFICATE_URL; public static final URL HELP_URL; + public static final URL HARDWAREINFO_URL; static { URL http = null; URL https = null; URL pin = null; URL ident = null; + URL getcertificate = null; + URL hardwareinfo = null; URL cert = null; URL help = null; try { http = new URL("http://localhost:" + Integer.getInteger(Container.HTTPS_PORT_PROPERTY, 3495).intValue() + '/'); https = new URL("https://localhost:" + Integer.getInteger(Container.HTTPS_PORT_PROPERTY, 3496).intValue() + '/'); pin = new URL(http, "/PINManagement"); + getcertificate = new URL(http, "/GETCertificate"); + hardwareinfo = new URL(http, "/GETHardwareinfo"); cert = new URL(http, "/ca.crt"); help = new URL(http, "/help/"); ident = new URL(http, "/IdentityLink"); @@ -89,6 +95,8 @@ public class Launcher implements BKUControllerInterface { HTTPS_SECURITY_LAYER_URL = https; PIN_MANAGEMENT_URL = pin; IDENTITY_LINK_URL = ident; + GETCERTIFICATE_URL = getcertificate; + HARDWAREINFO_URL = hardwareinfo; INSTALL_CERT_URL = cert; HELP_URL = help; } @@ -316,4 +324,14 @@ public class Launcher implements BKUControllerInterface { public void personIdentityLink(Locale locale) { new Thread(new PersonIdentityLinkInvoker(status)).start(); } + + @Override + public void getCertificate(Locale locale) { + new Thread(new GetCertificateInvoker(status)).start(); + } + + @Override + public void hardwareInfo(Locale locale) { + new Thread(new HardwareInfoInvoker(status)).start(); + } } diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/BKUControllerInterface.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/BKUControllerInterface.java index 2d91f2f2..8c05f137 100644 --- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/BKUControllerInterface.java +++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/BKUControllerInterface.java @@ -35,9 +35,13 @@ public interface BKUControllerInterface { public void showHelp(Locale locale); public void pinManagement(Locale locale); + + public void getCertificate(Locale locale); public void personIdentityLink(Locale locale); + public void hardwareInfo(Locale locale); + /** * Check if MOCCA Autostart is possible * @return autostart possibility diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/MOCCAIcon.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/MOCCAIcon.java index 3c6fe6f0..f0b60877 100644 --- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/MOCCAIcon.java +++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/MOCCAIcon.java @@ -48,6 +48,8 @@ import org.slf4j.LoggerFactory; /** * @author clemenso * @author tkellner + * @author tlenz + * @author afitzek */ public class MOCCAIcon implements StatusNotifier, ActionListener, ItemListener { @@ -57,14 +59,17 @@ public class MOCCAIcon implements StatusNotifier, ActionListener, ItemListener { public static final String LABEL_ABOUT = "tray.label.about"; public static final String LABEL_SETTINGS = "tray.label.settings"; public static final String LABEL_AUTOSTART = "tray.label.autostart"; - public static final String LABEL_IDENTITYLINK = "tray.label.identitylink"; - public static final String LABEL_INFOMENU = "tray.label.infomenu"; public static final String TOOLTIP_DEFAULT = "tray.tooltip.default"; + public static final String LABEL_CARD = "tray.label.card"; + public static final String LABEL_GETCERTIFICATE = "tray.label.getcertificate"; + public static final String LABEL_INFO = "tray.label.info"; + public static final String LABEL_IDENTITYLINK = "tray.label.identitylink"; + public static final String LABEL_HARDWAREINFO = "tray.label.hardwareinfo"; /** action commands for tray menu */ private static enum COMMANDS { - SHUTDOWN_COMMAND, PIN_COMMAND, ABOUT_COMMAND, - HELP_COMMAND, AUTOSTART_COMMAND, IDENTITYLINK_COMMAND + SHUTDOWN_COMMAND, PIN_COMMAND, ABOUT_COMMAND, HELP_COMMAND, AUTOSTART_COMMAND, + GETCERTIFICATE_COMMAND, HARDWAREINFO_COMMAND, IDENTITYLINK_COMMAND }; private static final Logger log = LoggerFactory.getLogger(MOCCAIcon.class); @@ -107,19 +112,33 @@ public class MOCCAIcon implements StatusNotifier, ActionListener, ItemListener { helpItem.addActionListener(this); helpItem.setActionCommand(COMMANDS.HELP_COMMAND.name()); menu.add(helpItem); - - Menu infoMenu = new Menu(messages.getString(LABEL_INFOMENU)); - - MenuItem identityLinkItem = new MenuItem(messages.getString(LABEL_IDENTITYLINK)); - identityLinkItem.addActionListener(this); - identityLinkItem.setActionCommand(COMMANDS.IDENTITYLINK_COMMAND.name()); - infoMenu.add(identityLinkItem); + Menu cardMenu = new Menu(messages.getString(LABEL_CARD)); + menu.add(cardMenu); + MenuItem pinItem = new MenuItem(messages.getString(LABEL_PIN)); pinItem.addActionListener(this); pinItem.setActionCommand(COMMANDS.PIN_COMMAND.name()); - menu.add(pinItem); + cardMenu.add(pinItem); + + MenuItem getcertificateItem = new MenuItem(messages.getString(LABEL_GETCERTIFICATE)); + getcertificateItem.addActionListener(this); + getcertificateItem.setActionCommand(COMMANDS.GETCERTIFICATE_COMMAND.name()); + cardMenu.add(getcertificateItem); + + Menu infoMenu = new Menu(messages.getString(LABEL_INFO)); + menu.add(infoMenu); + MenuItem identitylinkItem = new MenuItem(messages.getString(LABEL_IDENTITYLINK)); + identitylinkItem.addActionListener(this); + identitylinkItem.setActionCommand(COMMANDS.IDENTITYLINK_COMMAND.name()); + infoMenu.add(identitylinkItem); + + MenuItem hardwareinfoItem = new MenuItem(messages.getString(LABEL_HARDWAREINFO)); + hardwareinfoItem.addActionListener(this); + hardwareinfoItem.setActionCommand(COMMANDS.HARDWAREINFO_COMMAND.name()); + infoMenu.add(hardwareinfoItem); + MenuItem aboutItem = new MenuItem( messages.getString(LABEL_ABOUT)); aboutItem.setActionCommand(COMMANDS.ABOUT_COMMAND.name()); @@ -239,6 +258,16 @@ public class MOCCAIcon implements StatusNotifier, ActionListener, ItemListener { controller.pinManagement(messages.getLocale()); break; + case GETCERTIFICATE_COMMAND: + log.debug("get-certificate dialog requested via tray menu"); + controller.getCertificate(messages.getLocale()); + break; + + case HARDWAREINFO_COMMAND: + log.debug("hardware-info dialog requested via tray menu"); + controller.hardwareInfo(messages.getLocale()); + break; + case HELP_COMMAND: log.debug("help page requested via tray menu"); controller.showHelp(messages.getLocale()); |