From f8db5af9c94285c4946bdf38407fe15ed1b7f818 Mon Sep 17 00:00:00 2001 From: tkellner Date: Mon, 2 Apr 2012 16:38:59 +0000 Subject: * Save certificates to local file system * Show cardreader and smartcard information for Webstart and Applet version git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1042 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../bku/online/applet/GETCertificateApplet.java | 61 ++++ .../bku/online/applet/GETCertificateBKUWorker.java | 100 +++++++ .../egiz/bku/online/applet/HardwareInfoApplet.java | 59 ++++ .../bku/online/applet/HardwareInfoBKUWorker.java | 100 +++++++ .../java/at/gv/egiz/bku/gui/GetCertificateGUI.java | 216 +++++++++++++++ .../gv/egiz/bku/gui/GetCertificateGUIFacade.java | 51 ++++ .../at/gv/egiz/bku/gui/GetHardwareInfoGUI.java | 306 +++++++++++++++++++++ .../gv/egiz/bku/gui/GetHardwareInfoGUIFacade.java | 43 +++ .../gv/egiz/bku/gui/ActivationMessages.properties | 12 + .../egiz/bku/gui/ActivationMessages_de.properties | 12 + .../at/gv/egiz/bku/local/stal/LocalBKUWorker.java | 6 + .../local/stal/LocalGETCertificateSTALFactory.java | 136 +++++++++ .../stal/LocalGetHardwareInfoSTALFactory.java | 136 +++++++++ .../bku/local/webapp/GETCertificateServlet.java | 133 +++++++++ .../bku/local/webapp/GetHardwareInfoServlet.java | 133 +++++++++ BKULocal/src/main/webapp/WEB-INF/web.xml | 17 +- .../egiz/bku/online/webapp/MoccaParameterBean.java | 3 +- BKUOnline/src/main/webapp/SLRequestForm.html | 4 +- BKUOnline/src/main/webapp/applet.jsp | 8 + .../egiz/bku/webstart/GetCertificateInvoker.java | 76 +++++ .../gv/egiz/bku/webstart/HardwareInfoInvoker.java | 76 +++++ .../java/at/gv/egiz/bku/webstart/Launcher.java | 18 ++ .../bku/webstart/gui/BKUControllerInterface.java | 4 + .../at/gv/egiz/bku/webstart/gui/MOCCAIcon.java | 53 +++- .../at/gv/egiz/bku/webstart/messages.properties | 9 +- .../at/gv/egiz/bku/webstart/messages_de.properties | 8 +- .../at/gv/egiz/stal/ext/GETCertificateRequest.java | 35 +++ .../gv/egiz/stal/ext/GETCertificateResponse.java | 35 +++ .../gv/egiz/stal/ext/GETHardwareInfoRequest.java | 35 +++ .../gv/egiz/stal/ext/GETHardwareInfoResponse.java | 35 +++ .../at/gv/egiz/smcc/AbstractSignatureCard.java | 6 + smcc/src/main/java/at/gv/egiz/smcc/SWCard.java | 4 + .../main/java/at/gv/egiz/smcc/SignatureCard.java | 2 + .../java/at/gv/egiz/smcc/AbstractSMCCSTALTest.java | 8 +- .../bku/smccstal/GETCertificateRequestHandler.java | 129 +++++++++ .../smccstal/GETHardwareInfoRequestHandler.java | 106 +++++++ 36 files changed, 2156 insertions(+), 19 deletions(-) create mode 100644 BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/GETCertificateApplet.java create mode 100644 BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/GETCertificateBKUWorker.java create mode 100644 BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/HardwareInfoApplet.java create mode 100644 BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/HardwareInfoBKUWorker.java create mode 100644 BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetCertificateGUI.java create mode 100644 BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetCertificateGUIFacade.java create mode 100644 BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetHardwareInfoGUI.java create mode 100644 BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetHardwareInfoGUIFacade.java create mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalGETCertificateSTALFactory.java create mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalGetHardwareInfoSTALFactory.java create mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/GETCertificateServlet.java create mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/GetHardwareInfoServlet.java create mode 100644 BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/GetCertificateInvoker.java create mode 100644 BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/HardwareInfoInvoker.java create mode 100644 STALExt/src/main/java/at/gv/egiz/stal/ext/GETCertificateRequest.java create mode 100644 STALExt/src/main/java/at/gv/egiz/stal/ext/GETCertificateResponse.java create mode 100644 STALExt/src/main/java/at/gv/egiz/stal/ext/GETHardwareInfoRequest.java create mode 100644 STALExt/src/main/java/at/gv/egiz/stal/ext/GETHardwareInfoResponse.java create mode 100644 smccSTALExt/src/main/java/at/gv/egiz/bku/smccstal/GETCertificateRequestHandler.java create mode 100644 smccSTALExt/src/main/java/at/gv/egiz/bku/smccstal/GETHardwareInfoRequestHandler.java diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/GETCertificateApplet.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/GETCertificateApplet.java new file mode 100644 index 00000000..4a46f397 --- /dev/null +++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/GETCertificateApplet.java @@ -0,0 +1,61 @@ +/* + * 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.online.applet; + +import java.awt.Container; +import java.net.URL; +import java.util.Locale; + +import at.gv.egiz.bku.gui.BKUGUIFacade; +import at.gv.egiz.bku.gui.GetCertificateGUI; +import at.gv.egiz.bku.gui.GetCertificateGUIFacade; +import at.gv.egiz.bku.gui.HelpListener; +import at.gv.egiz.bku.gui.SwitchFocusListener; +import at.gv.egiz.bku.gui.viewer.FontProvider; + +/** +* +* @author Thomas Lenz +*/ + +public class GETCertificateApplet extends BKUApplet { + + private static final long serialVersionUID = 1L; + + @Override + protected BKUGUIFacade createGUI(Container contentPane, Locale locale, + BKUGUIFacade.Style guiStyle, URL backgroundImgURL, + FontProvider fontProvider, HelpListener helpListener, + SwitchFocusListener switchFocusListener) { + return new GetCertificateGUI(contentPane, locale, + backgroundImgURL, fontProvider, helpListener, + switchFocusListener); + } + + @Override + protected AppletBKUWorker createBKUWorker(BKUApplet applet, BKUGUIFacade gui) { + return new GETCertificateBKUWorker(applet, (GetCertificateGUIFacade) gui); + } + +} diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/GETCertificateBKUWorker.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/GETCertificateBKUWorker.java new file mode 100644 index 00000000..5b04e28b --- /dev/null +++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/GETCertificateBKUWorker.java @@ -0,0 +1,100 @@ +/* + * 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.online.applet; + +import java.util.Collections; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.bku.gui.BKUGUIFacade; +import at.gv.egiz.bku.gui.GetCertificateGUIFacade; +import at.gv.egiz.bku.smccstal.GETCertificateRequestHandler; +import at.gv.egiz.stal.ErrorResponse; +import at.gv.egiz.stal.InfoboxReadRequest; +import at.gv.egiz.stal.QuitRequest; +import at.gv.egiz.stal.STALResponse; +import at.gv.egiz.stal.SignRequest; +import at.gv.egiz.stal.ext.GETCertificateRequest; +import at.gv.egiz.stal.ext.GETCertificateResponse; + +/** +* +* @author Thomas Lenz +*/ + +public class GETCertificateBKUWorker extends AppletBKUWorker { + + private final Logger log = LoggerFactory.getLogger(GETCertificateBKUWorker.class); + + public GETCertificateBKUWorker(BKUApplet applet, GetCertificateGUIFacade gui) { + super(applet, gui); + removeRequestHandler(InfoboxReadRequest.class); + removeRequestHandler(SignRequest.class); + addRequestHandler(GETCertificateRequest.class, new GETCertificateRequestHandler()); + } + + @Override + public void run() { + gui.showMessageDialog(BKUGUIFacade.TITLE_WELCOME, + BKUGUIFacade.MESSAGE_WELCOME); + + try { + + List responses = handleRequest(Collections.singletonList(new GETCertificateRequest())); + handleRequest(Collections.singletonList(new QuitRequest())); + + if (responses.size() == 1) { + STALResponse response = responses.get(0); + if (response instanceof GETCertificateResponse) { + log.debug("GET certificate dialog terminated."); + } else if (response instanceof ErrorResponse) { + log.debug("GET certificate dialog terminated with error."); + } else { + throw new RuntimeException("Invalid STAL response: " + response.getClass().getName()); + } + } else { + throw new RuntimeException("invalid number of STAL responses: " + responses.size()); + } + + } catch (RuntimeException ex) { + log.error(ex.getMessage()); + Throwable cause = ex.getCause(); + if (cause != null) { // && cause instanceof InterruptedException) { + log.info(cause.getMessage()); + } + showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, null); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + showErrorDialog(BKUGUIFacade.ERR_UNKNOWN_WITH_PARAM, ex); + } finally { + if (signatureCard != null) { + signatureCard.disconnect(false); + } + } + + applet.sendRedirect(); + } +} diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/HardwareInfoApplet.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/HardwareInfoApplet.java new file mode 100644 index 00000000..18397613 --- /dev/null +++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/HardwareInfoApplet.java @@ -0,0 +1,59 @@ +/* + * 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.online.applet; + +import java.awt.Container; +import java.net.URL; +import java.util.Locale; + +import at.gv.egiz.bku.gui.BKUGUIFacade; +import at.gv.egiz.bku.gui.GetHardwareInfoGUI; +import at.gv.egiz.bku.gui.GetHardwareInfoGUIFacade; +import at.gv.egiz.bku.gui.HelpListener; +import at.gv.egiz.bku.gui.SwitchFocusListener; +import at.gv.egiz.bku.gui.viewer.FontProvider; + +/** +* +* @author Thomas Lenz +*/ + +public class HardwareInfoApplet extends BKUApplet { + private static final long serialVersionUID = 1L; + + @Override + protected BKUGUIFacade createGUI(Container contentPane, Locale locale, + BKUGUIFacade.Style guiStyle, URL backgroundImgURL, + FontProvider fontProvider, HelpListener helpListener, + SwitchFocusListener switchFocusListener) { + return new GetHardwareInfoGUI(contentPane, locale, + backgroundImgURL, fontProvider, helpListener, + switchFocusListener); + } + + @Override + protected AppletBKUWorker createBKUWorker(BKUApplet applet, BKUGUIFacade gui) { + return new HardwareInfoBKUWorker(applet, (GetHardwareInfoGUIFacade) gui); + } +} diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/HardwareInfoBKUWorker.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/HardwareInfoBKUWorker.java new file mode 100644 index 00000000..bfa4d71e --- /dev/null +++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/HardwareInfoBKUWorker.java @@ -0,0 +1,100 @@ +/* + * 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.online.applet; + +import java.util.Collections; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.bku.gui.BKUGUIFacade; +import at.gv.egiz.bku.gui.GetHardwareInfoGUIFacade; +import at.gv.egiz.bku.smccstal.GETHardwareInfoRequestHandler; +import at.gv.egiz.stal.ErrorResponse; +import at.gv.egiz.stal.InfoboxReadRequest; +import at.gv.egiz.stal.QuitRequest; +import at.gv.egiz.stal.STALResponse; +import at.gv.egiz.stal.SignRequest; +import at.gv.egiz.stal.ext.GETHardwareInfoRequest; +import at.gv.egiz.stal.ext.GETHardwareInfoResponse; + +/** +* +* @author Thomas Lenz +*/ + +public class HardwareInfoBKUWorker extends AppletBKUWorker { + private final Logger log = LoggerFactory.getLogger(HardwareInfoBKUWorker.class); + + public HardwareInfoBKUWorker(BKUApplet applet, GetHardwareInfoGUIFacade gui) { + super(applet, gui); + removeRequestHandler(InfoboxReadRequest.class); + removeRequestHandler(SignRequest.class); + addRequestHandler(GETHardwareInfoRequest.class, new GETHardwareInfoRequestHandler()); + } + + @Override + public void run() { + gui.showMessageDialog(BKUGUIFacade.TITLE_WELCOME, + BKUGUIFacade.MESSAGE_WELCOME); + + try { + + List responses = handleRequest(Collections.singletonList(new GETHardwareInfoRequest())); + handleRequest(Collections.singletonList(new QuitRequest())); + + if (responses.size() == 1) { + STALResponse response = responses.get(0); + if (response instanceof GETHardwareInfoResponse) { + log.debug("hardware-info dialog terminated."); + } else if (response instanceof ErrorResponse) { + log.debug("hardware-info dialog terminated with error."); + } else { + throw new RuntimeException("Invalid STAL response: " + response.getClass().getName()); + } + } else { + throw new RuntimeException("invalid number of STAL responses: " + responses.size()); + } + + } catch (RuntimeException ex) { + log.error(ex.getMessage()); + Throwable cause = ex.getCause(); + if (cause != null) { // && cause instanceof InterruptedException) { + log.info(cause.getMessage()); + } + showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, null); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + showErrorDialog(BKUGUIFacade.ERR_UNKNOWN_WITH_PARAM, ex); + } finally { + if (signatureCard != null) { + signatureCard.disconnect(false); + } + } + + applet.sendRedirect(); + } + +} diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetCertificateGUI.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetCertificateGUI.java new file mode 100644 index 00000000..3fb0bde4 --- /dev/null +++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetCertificateGUI.java @@ -0,0 +1,216 @@ +/* + * 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.gui; + +import java.awt.Container; +import java.awt.event.ActionListener; +import java.io.File; +import java.net.URL; +import java.text.MessageFormat; +import java.util.Locale; + +import javax.swing.GroupLayout; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.LayoutStyle; +import javax.swing.SwingUtilities; +import javax.swing.filechooser.FileFilter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.bku.gui.viewer.FontProvider; + +/** +* +* @author Thomas Lenz +*/ + +public class GetCertificateGUI extends CardMgmtGUI implements + GetCertificateGUIFacade { + + private final Logger log = LoggerFactory.getLogger(GetCertificateGUI.class); + + protected JButton getSimCertButton; + protected JButton getQualCertButton; + + public GetCertificateGUI(Container contentPane, Locale locale, + URL backgroundImgURL, FontProvider fontProvider, + HelpListener helpListener, SwitchFocusListener switchFocusListener) { + super(contentPane, locale, Style.advanced, backgroundImgURL, fontProvider, + helpListener, switchFocusListener); + + + } + + @Override + public void showGETCertificateDialog(final ActionListener certificateListener, + final String showGetQualCert, final String showGetSimCert, + final ActionListener cancelListener, final String cancelCmd) { + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + titleLabel.setText(getMessage(TITLE_GETCERTIFICATE)); + + getSimCertButton = new JButton(); + getSimCertButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle()& ~java.awt.Font.BOLD)); + getSimCertButton.setText(getMessage(BUTTON_SIM_CERT)); + getSimCertButton.setActionCommand(showGetSimCert); + getSimCertButton.addActionListener(certificateListener); + getSimCertButton.setEnabled(true); + + getQualCertButton = new JButton(); + getQualCertButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle()& ~java.awt.Font.BOLD)); + getQualCertButton.setText(getMessage(BUTTON_QUAL_CERT)); + getQualCertButton.setActionCommand(showGetQualCert); + getQualCertButton.addActionListener(certificateListener); + getQualCertButton.setEnabled(true); + + cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle()& ~java.awt.Font.BOLD)); + cancelButton.setText(getMessage(BUTTON_CLOSE)); + cancelButton.setActionCommand(cancelCmd); + cancelButton.addActionListener(cancelListener); + cancelButton.setEnabled(true); + + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + //--------------------------------------------------------------------------------------------------------- + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.CENTER) + .addGroup(mainPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() + .addComponent(getQualCertButton, GroupLayout.DEFAULT_SIZE, + GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(12)) + .addGroup(GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup() + .addGap(1) + .addComponent(getSimCertButton, GroupLayout.DEFAULT_SIZE, + getQualCertButton.getSize().width, Short.MAX_VALUE) + .addContainerGap()))) + ); + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(getSimCertButton, GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(getQualCertButton, GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE) + )); + + mainPanel.setLayout(mainPanelLayout); + //--------------------------------------------------------------------------------------------------------- + + + GroupLayout.ParallelGroup buttonHorizontal = buttonPanelLayout + .createParallelGroup(GroupLayout.Alignment.CENTER) + .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); + + GroupLayout.Group buttonVertical = buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(cancelButton); + + buttonPanelLayout.setHorizontalGroup(buttonHorizontal); + buttonPanelLayout.setVerticalGroup(buttonVertical); + + + + if (windowCloseAdapter != null) { + windowCloseAdapter.registerListener(cancelListener, cancelCmd); + } + + contentPanel.validate(); + + resize(); + } + }); + } + + @Override + public void resize() { + + log.debug("Resizing Get-Certificate Applet ..."); + + float factor = getResizeFactor(); + + if (getQualCertButton != null) { + + getQualCertButton.setFont(getQualCertButton.getFont().deriveFont( + (float) (baseFontSize * factor))); + + } + + if (getSimCertButton != null) { + + getSimCertButton.setFont(getSimCertButton.getFont().deriveFont( + (float) (baseFontSize * factor))); + + } + + + super.resize(); + } + + public File showSaveDialog(String defaultfilename) { + + + JFileChooser filechooser = new JFileChooser(); + + filechooser.setMultiSelectionEnabled(false); + filechooser.setDialogTitle(getMessage(TITEL_FILESAVE)); + filechooser.setSelectedFile(new File(defaultfilename)); + filechooser.setFileFilter( new FileFilter() + { + @Override public boolean accept( File f ) + { + return f.isDirectory() || + f.getName().toLowerCase().endsWith( ".cer" ); + } + @Override public String getDescription() + { + return getMessage(FILE_TYPE_NAME); + } + } ); + + int state = filechooser.showSaveDialog(contentPane); + + if (state == JFileChooser.APPROVE_OPTION) { + return filechooser.getSelectedFile(); + + } else { + log.info("Save certificate dialog canceled"); + return null; + } + } + +} diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetCertificateGUIFacade.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetCertificateGUIFacade.java new file mode 100644 index 00000000..b327f385 --- /dev/null +++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetCertificateGUIFacade.java @@ -0,0 +1,51 @@ +/* + * 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.gui; + +import java.awt.event.ActionListener; +import java.io.File; + +/** +* +* @author Thomas Lenz +*/ + +public interface GetCertificateGUIFacade extends BKUGUIFacade { + + public static final String BUTTON_SIM_CERT = "button.simple.certificate"; + public static final String BUTTON_QUAL_CERT = "button.qualified.certificate"; + public static final String FILE_TYPE_NAME = "file.certificate"; + public static final String TITEL_FILESAVE = "title.certificate.save"; + public static final String TITLE_GETCERTIFICATE = "title.get.certificate"; + + public static final String FILENAME_QUAL_CERT = "qualified.cer"; + public static final String FILENAME_SIM_CERT = "simple.cer"; + + + public void showGETCertificateDialog(ActionListener certificateListener, String showGetQualCert, + String showGetSimCert, ActionListener cancelListener, String cancelCmd); + + public File showSaveDialog(String defaultfilename); + +} diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetHardwareInfoGUI.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetHardwareInfoGUI.java new file mode 100644 index 00000000..1088545d --- /dev/null +++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetHardwareInfoGUI.java @@ -0,0 +1,306 @@ +/* + * 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.gui; + +import java.awt.Container; +import java.awt.Font; +import java.awt.event.ActionListener; +import java.net.URL; +import java.util.Locale; + +import javax.swing.GroupLayout; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.LayoutStyle.ComponentPlacement; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import javax.swing.border.TitledBorder; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.bku.gui.viewer.FontProvider; + +/** +* +* @author Thomas Lenz +*/ + +public class GetHardwareInfoGUI extends CardMgmtGUI implements + GetHardwareInfoGUIFacade { + + private final Logger log = LoggerFactory.getLogger(GetHardwareInfoGUI.class); + + protected JLabel lblTyp; + protected JLabel lblAtr; + protected JLabel lblNewLabel; + protected JLabel lblNewLabel_1; + protected JLabel lblNewLabel_2; + protected JPanel cardpanel; + protected JPanel readerpanel; + protected TitledBorder readerpanel_border; + protected TitledBorder cardpanel_border; + + + public GetHardwareInfoGUI(Container contentPane, Locale locale, + URL backgroundImgURL, FontProvider fontProvider, + HelpListener helpListener, SwitchFocusListener switchFocusListener) { + super(contentPane, locale, Style.advanced, backgroundImgURL, fontProvider, + helpListener, switchFocusListener); + } + + + @Override + public void showHardwareInfoDialog(final ActionListener hardwareinfolistener, final String backcmd, + final String showcardreadername, final String showsmartcardname, + final String showsmartcardATR) { + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + headerPanel.removeAll(); + mainPanel.removeAll(); + buttonPanel.removeAll(); + + backButton.setFont(backButton.getFont().deriveFont(backButton.getFont().getStyle()& ~java.awt.Font.BOLD)); + backButton.setText(getMessage(BUTTON_BACK)); + backButton.setActionCommand(backcmd); + backButton.addActionListener(hardwareinfolistener); + backButton.setEnabled(true); + + //------------------------------------------------------------------------------------ + + readerpanel_border = new TitledBorder(null, getMessage(LABEL_CARDREADER), TitledBorder.LEADING, TitledBorder.TOP, null, null); + readerpanel_border.setTitleFont(readerpanel_border.getTitleFont().deriveFont( + readerpanel_border.getTitleFont().getStyle() + & java.awt.Font.BOLD)); + readerpanel = new JPanel(); + readerpanel.setBorder(readerpanel_border); + + + + cardpanel_border = new TitledBorder(null, getMessage(LABEL_SMARTCARD), TitledBorder.LEADING, TitledBorder.TOP, null, null); + cardpanel_border.setTitleFont(cardpanel_border.getTitleFont().deriveFont( + cardpanel_border.getTitleFont().getStyle() + & java.awt.Font.BOLD)); + cardpanel = new JPanel(); + cardpanel.setBorder(cardpanel_border); + cardpanel.setFont(cardpanel.getFont().deriveFont( + cardpanel.getFont().getStyle() + & java.awt.Font.BOLD)); + + GroupLayout gl_contentPane = new GroupLayout(mainPanel); + gl_contentPane.setHorizontalGroup( + gl_contentPane.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(gl_contentPane.createSequentialGroup() + .addContainerGap() + .addGroup(gl_contentPane.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(cardpanel, GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE) + .addComponent(readerpanel, GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE))) + ); + gl_contentPane.setVerticalGroup( + gl_contentPane.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(gl_contentPane.createSequentialGroup() + .addComponent(readerpanel, GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE) + .addGap(8) + .addComponent(cardpanel, GroupLayout.PREFERRED_SIZE, 89, Short.MAX_VALUE) + .addContainerGap()) + ); + + lblTyp = new JLabel(getMessage(LABEL_SMARTCARD_TYPE)); + lblTyp.setFont(lblTyp.getFont().deriveFont( + lblTyp.getFont().getStyle() + & java.awt.Font.BOLD)); + + + lblAtr = new JLabel(getMessage(LABEL_SMARTCARD_ATR)); + lblAtr.setFont(lblAtr.getFont().deriveFont( + lblAtr.getFont().getStyle() + & java.awt.Font.BOLD)); + + lblNewLabel_1 = new JLabel(showsmartcardname); + lblNewLabel_1.setFont(lblNewLabel_1.getFont().deriveFont( + lblNewLabel_1.getFont().getStyle() + & ~java.awt.Font.BOLD)); + + + lblNewLabel_2 = new JLabel(makeATRString(showsmartcardATR, 40)); + lblNewLabel_2.setVerticalAlignment(SwingConstants.CENTER); + lblNewLabel_2.setFont(lblNewLabel_2.getFont().deriveFont( + lblNewLabel_2.getFont().getStyle() + & ~java.awt.Font.BOLD)); + + GroupLayout gl_cardpanel = new GroupLayout(cardpanel); + gl_cardpanel.setHorizontalGroup( + gl_cardpanel.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(gl_cardpanel.createSequentialGroup() + .addContainerGap() + .addGroup(gl_cardpanel.createParallelGroup(GroupLayout.Alignment.TRAILING) + .addComponent(lblTyp, GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE) + .addComponent(lblAtr, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addGroup(gl_cardpanel.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(lblNewLabel_1, GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE) + .addComponent(lblNewLabel_2, GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE))) + ); + gl_cardpanel.setVerticalGroup( + gl_cardpanel.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(gl_cardpanel.createSequentialGroup() + .addGroup(gl_cardpanel.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addGroup(gl_cardpanel.createSequentialGroup() + .addGap(2) + .addComponent(lblTyp, GroupLayout.DEFAULT_SIZE, 21, Short.MAX_VALUE)) + .addComponent(lblNewLabel_1, GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)) + .addPreferredGap(ComponentPlacement.RELATED) + .addGroup(gl_cardpanel.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(lblNewLabel_2, GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE) + .addGroup(gl_cardpanel.createSequentialGroup() + .addComponent(lblAtr, GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE) + .addGap(6))) + .addGap(3)) + ); + cardpanel.setLayout(gl_cardpanel); + + lblNewLabel = new JLabel(showcardreadername); + lblNewLabel.setVerticalAlignment(SwingConstants.CENTER); + lblNewLabel.setFont(lblNewLabel.getFont().deriveFont( + lblNewLabel.getFont().getStyle() + & ~java.awt.Font.BOLD)); + + GroupLayout gl_readerpanel = new GroupLayout(readerpanel); + gl_readerpanel.setHorizontalGroup( + gl_readerpanel.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(gl_readerpanel.createSequentialGroup() + .addContainerGap() + .addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 276, Short.MAX_VALUE)) + ); + gl_readerpanel.setVerticalGroup( + gl_readerpanel.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(lblNewLabel, GroupLayout.DEFAULT_SIZE, 15, Short.MAX_VALUE) + ); + readerpanel.setLayout(gl_readerpanel); + mainPanel.setLayout(gl_contentPane); + + //------------------------------------------------------------------------------------ + + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + GroupLayout.ParallelGroup buttonHorizontal = buttonPanelLayout + .createParallelGroup(GroupLayout.Alignment.CENTER) + .addComponent(backButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); + + GroupLayout.Group buttonVertical = buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(backButton); + + + buttonPanelLayout.setHorizontalGroup(buttonHorizontal); + buttonPanelLayout.setVerticalGroup(buttonVertical); + + + if (windowCloseAdapter != null) { + windowCloseAdapter.registerListener(hardwareinfolistener, backcmd); + } + + contentPanel.validate(); + + resize(); + } + }); + } + + @Override + public void resize() { + + log.debug("Resizing Hardware-Info Applet ..."); + + float factor = getResizeFactor(); + + + if (lblTyp != null) { + lblTyp.setFont(lblTyp.getFont().deriveFont( + (float) ((baseFontSize - 2)* factor))); + } + + if (lblAtr != null) { + lblAtr.setFont(lblAtr.getFont().deriveFont( + (float) ((baseFontSize - 2)* factor))); + } + + if (lblNewLabel != null) { + lblNewLabel.setFont(lblNewLabel.getFont().deriveFont( + (float) ((baseFontSize - 2)* factor))); + } + + if (lblNewLabel_1 != null) { + lblNewLabel_1.setFont(lblNewLabel_1.getFont().deriveFont( + (float) ((baseFontSize - 2)* factor))); + } + + if (lblNewLabel_2 != null) { + lblNewLabel_2.setFont(lblNewLabel_2.getFont().deriveFont( + (float) ((baseFontSize - 2)* factor))); + } + + if (cardpanel_border != null) { + cardpanel_border.setTitleFont(cardpanel_border.getTitleFont().deriveFont( + (float) ((baseFontSize)* factor))); + } + + if (readerpanel_border != null) { + readerpanel_border.setTitleFont(readerpanel_border.getTitleFont().deriveFont( + (float) ((baseFontSize)* factor))); + } + + if (backButton != null) { + + backButton.setFont(backButton.getFont().deriveFont( + (float) (baseFontSize * factor))); + + } + + super.resize(); + } + + private String makeATRString(String ATR, int width) { + + String line = new String(); + + if (ATR.length() > width) { + + line = line.concat(""); + line = line.concat(ATR.substring(1, width)); + line = line.concat("
"); + line = line.concat(ATR.substring(width,ATR.length()-1)); + line = line.concat(""); + + return line; + } + else + return ATR; + } + +} diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetHardwareInfoGUIFacade.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetHardwareInfoGUIFacade.java new file mode 100644 index 00000000..c121417e --- /dev/null +++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/GetHardwareInfoGUIFacade.java @@ -0,0 +1,43 @@ +/* + * 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.gui; + +import java.awt.event.ActionListener; + +/** +* +* @author Thomas Lenz +*/ + +public interface GetHardwareInfoGUIFacade extends BKUGUIFacade { + + public static final String LABEL_CARDREADER = "label.hardwareinfo.cardreader"; + public static final String LABEL_SMARTCARD = "label.hardwareinfo.smartcard"; + public static final String LABEL_SMARTCARD_TYPE = "label.hardwareinfo.smartcard.type"; + public static final String LABEL_SMARTCARD_ATR = "label.hardwareinfo.smartcard.atr"; + + public void showHardwareInfoDialog(final ActionListener hardwareinfolistener, final String backcmd, final String showcardreadername, + final String showsmartcardname, final String showsmartcardATR); + +} diff --git a/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties b/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties index a5e582a1..eefd451b 100644 --- a/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties +++ b/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties @@ -29,6 +29,8 @@ title.activate.success=Success title.change.success=Success title.unblock.success=Success title.identity=Person Identity Link +title.certificate.save=Save certificate +title.get.certificate=Save certificates # removed message.* prefix to reuse keys as help keys pin.mgmt={0} PINs available @@ -69,11 +71,21 @@ label.puk={0} PUK: label.new.pin=New {0}: label.repeat.pin=Confirmation: +label.hardwareinfo.cardreader = Cardreader +label.hardwareinfo.smartcard = Smartcard +label.hardwareinfo.smartcard.type = Type: +label.hardwareinfo.smartcard.atr = ATR: + +file.certificate = Certificate + button.activate=Activate button.change=Change button.unblock=Unblock button.verify=Query +button.qualified.certificate = qualified certificate +button.simple.certificate = basic certificate + help.activation=help.activation help.pin.mgmt=help.pin.mgmt diff --git a/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages_de.properties b/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages_de.properties index 1935d31b..30a80e6f 100644 --- a/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages_de.properties +++ b/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages_de.properties @@ -35,6 +35,8 @@ identity.button=Abbrechen identity.firstname=Vorname identity.dateofbirth=Geburtsdatum identity.lastname=Nachname +title.certificate.save=Zertifikat speichern +title.get.certificate=Zertifikate speichern # removed message.* prefix to reuse keys as help keys pin.mgmt=Die Karte verf\u00FCgt \u00FCber {0} PINs @@ -69,11 +71,21 @@ label.puk={0} PUK: label.new.pin=Neue {0}: label.repeat.pin=Best\u00E4tigung: +label.hardwareinfo.cardreader = Kartenlesegerät +label.hardwareinfo.smartcard = Chipkarte +label.hardwareinfo.smartcard.type = Typ: +label.hardwareinfo.smartcard.atr = ATR: + +file.certificate = Zertifikat + button.activate=Aktivieren button.change=\u00C4ndern button.unblock=Entsperren button.verify=Abfragen +button.qualified.certificate = Qualifiziertes Zertifikat +button.simple.certificate = Einfaches Zertifikat + help.activation=help.activation help.pin.mgmt=help.pin.mgmt diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java index c41ac234..27a5d8ca 100644 --- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java @@ -26,6 +26,8 @@ package at.gv.egiz.bku.local.stal; import at.gv.egiz.bku.gui.BKUGUIFacade; import at.gv.egiz.bku.smccstal.AbstractBKUWorker; +import at.gv.egiz.bku.smccstal.GETCertificateRequestHandler; +import at.gv.egiz.bku.smccstal.GETHardwareInfoRequestHandler; import at.gv.egiz.bku.smccstal.PINManagementRequestHandler; import at.gv.egiz.bku.smccstal.PersonIdentityLinkRequestHandler; import at.gv.egiz.stal.QuitRequest; @@ -34,6 +36,8 @@ import at.gv.egiz.stal.STALResponse; import at.gv.egiz.stal.SignRequest; import at.gv.egiz.stal.ext.PersonIdentityLinkRequest; +import at.gv.egiz.stal.ext.GETCertificateRequest; +import at.gv.egiz.stal.ext.GETHardwareInfoRequest; import at.gv.egiz.stal.ext.PINManagementRequest; import java.util.List; import javax.swing.JFrame; @@ -53,6 +57,8 @@ public class LocalBKUWorker extends AbstractBKUWorker { new LocalSignRequestHandler(new LocalSecureViewer(gui))); addRequestHandler(PINManagementRequest.class, new PINManagementRequestHandler()); addRequestHandler(PersonIdentityLinkRequest.class, new PersonIdentityLinkRequestHandler()); + addRequestHandler(GETCertificateRequest.class, new GETCertificateRequestHandler()); + addRequestHandler(GETHardwareInfoRequest.class, new GETHardwareInfoRequestHandler()); } /** does not change container's visibility (use quit request to close) */ diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalGETCertificateSTALFactory.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalGETCertificateSTALFactory.java new file mode 100644 index 00000000..50c6c632 --- /dev/null +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalGETCertificateSTALFactory.java @@ -0,0 +1,136 @@ +/* + * 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.local.stal; + +import at.gv.egiz.bku.viewer.ResourceFontLoader; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Locale; + + +import at.gv.egiz.bku.gui.BKUGUIFacade; +import at.gv.egiz.bku.gui.BKUIcons; +import at.gv.egiz.bku.gui.GetCertificateGUI; +import at.gv.egiz.bku.gui.GetCertificateGUIFacade; +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 javax.swing.JFrame; + +import org.apache.commons.configuration.Configuration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** +* +* @author Thomas Lenz +*/ + +public class LocalGETCertificateSTALFactory implements STALFactory { + + private final Logger log = LoggerFactory.getLogger(LocalGETCertificateSTALFactory.class); + protected static final Dimension PREFERRED_SIZE = new Dimension(318, 200); + protected URL helpURL; + protected Locale locale; + + protected Configuration configuration; + + @Override + public STAL createSTAL() { + final LocalBKUWorker stal; + //http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html + // use undecorated JFrame instead of JWindow, + // which creates an invisible owning frame and therefore cannot getFocusInWindow() + JFrame dialog = new JFrame("Bürgerkarte"); + log.debug("AlwaysOnTop supported: {}.", dialog.isAlwaysOnTopSupported()); + // [#439] make mocca dialog alwaysOnTop + dialog.setAlwaysOnTop(true); + dialog.setIconImages(BKUIcons.icons); +// dialog.setUndecorated(true); +// dialog.getRootPane().setWindowDecorationStyle(JRootPane.NONE); + + if (locale != null) { + dialog.setLocale(locale); + } + LocalHelpListener helpListener = null; + if (helpURL != null) { + helpListener = new LocalHelpListener(helpURL, locale); + } else { + log.warn("No HELP URL configured, help system disabled."); + } + GetCertificateGUIFacade gui = new GetCertificateGUI(dialog.getContentPane(), + dialog.getLocale(), + null, + new ResourceFontLoader(), + helpListener, + null); + BKUGUIFacade proxy = (BKUGUIFacade) GUIProxy.newInstance(gui, dialog, new Class[] { GetCertificateGUIFacade.class, } ); + stal = new LocalBKUWorker(proxy, dialog); + dialog.setPreferredSize(PREFERRED_SIZE); + dialog.pack(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + Dimension frameSize = dialog.getSize(); + if (frameSize.height > screenSize.height) { + frameSize.height = screenSize.height; + } + if (frameSize.width > screenSize.width) { + frameSize.width = screenSize.width; + } + dialog.setLocation((screenSize.width - frameSize.width) / 2, + (screenSize.height - frameSize.height) / 2); + + return stal; + } + + @Override + public void setLocale(Locale locale) { + this.locale = locale; + } + + /** + * spring injects helpURL + * @param helpURL + * @throws MalformedURLException if helpURL is not a valid URL + */ + public void setHelpURL(String helpURL) throws MalformedURLException { + this.helpURL = new URL(helpURL); + } + + /** + * @return the configuration + */ + public Configuration getConfiguration() { + return configuration; + } + + /** + * @param configuration the configuration to set + */ + public void setConfiguration(Configuration configuration) { + this.configuration = configuration; + } +} diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalGetHardwareInfoSTALFactory.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalGetHardwareInfoSTALFactory.java new file mode 100644 index 00000000..1caccf6f --- /dev/null +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalGetHardwareInfoSTALFactory.java @@ -0,0 +1,136 @@ +/* + * 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.local.stal; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Locale; + +import javax.swing.JFrame; + +import org.apache.commons.configuration.Configuration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.bku.gui.BKUGUIFacade; +import at.gv.egiz.bku.gui.BKUIcons; +import at.gv.egiz.bku.gui.GetHardwareInfoGUI; +import at.gv.egiz.bku.gui.GetHardwareInfoGUIFacade; +import at.gv.egiz.bku.local.gui.GUIProxy; +import at.gv.egiz.bku.local.gui.LocalHelpListener; +import at.gv.egiz.bku.viewer.ResourceFontLoader; +import at.gv.egiz.stal.STAL; +import at.gv.egiz.stal.STALFactory; + +/** +* +* @author Thomas Lenz +*/ + +public class LocalGetHardwareInfoSTALFactory implements STALFactory { + + private final Logger log = LoggerFactory.getLogger(LocalGetHardwareInfoSTALFactory.class); + protected static final Dimension PREFERRED_SIZE = new Dimension(320, 270); + protected URL helpURL; + protected Locale locale; + + protected Configuration configuration; + + @Override + public STAL createSTAL() { + final LocalBKUWorker stal; + //http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html + // use undecorated JFrame instead of JWindow, + // which creates an invisible owning frame and therefore cannot getFocusInWindow() + JFrame dialog = new JFrame("Bürgerkarte"); + log.debug("AlwaysOnTop supported: {}.", dialog.isAlwaysOnTopSupported()); + // [#439] make mocca dialog alwaysOnTop + dialog.setAlwaysOnTop(true); + dialog.setIconImages(BKUIcons.icons); +// dialog.setUndecorated(true); +// dialog.getRootPane().setWindowDecorationStyle(JRootPane.NONE); + + if (locale != null) { + dialog.setLocale(locale); + } + LocalHelpListener helpListener = null; + if (helpURL != null) { + helpListener = new LocalHelpListener(helpURL, locale); + } else { + log.warn("No HELP URL configured, help system disabled."); + } + GetHardwareInfoGUIFacade gui = new GetHardwareInfoGUI(dialog.getContentPane(), + dialog.getLocale(), + null, + new ResourceFontLoader(), + helpListener, + null); + BKUGUIFacade proxy = (BKUGUIFacade) GUIProxy.newInstance(gui, dialog, new Class[] { GetHardwareInfoGUIFacade.class, } ); + stal = new LocalBKUWorker(proxy, dialog); + dialog.setPreferredSize(PREFERRED_SIZE); + dialog.pack(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + Dimension frameSize = dialog.getSize(); + if (frameSize.height > screenSize.height) { + frameSize.height = screenSize.height; + } + if (frameSize.width > screenSize.width) { + frameSize.width = screenSize.width; + } + dialog.setLocation((screenSize.width - frameSize.width) / 2, + (screenSize.height - frameSize.height) / 2); + + return stal; + } + + @Override + public void setLocale(Locale locale) { + this.locale = locale; + } + + /** + * spring injects helpURL + * @param helpURL + * @throws MalformedURLException if helpURL is not a valid URL + */ + public void setHelpURL(String helpURL) throws MalformedURLException { + this.helpURL = new URL(helpURL); + } + + /** + * @return the configuration + */ + public Configuration getConfiguration() { + return configuration; + } + + /** + * @param configuration the configuration to set + */ + public void setConfiguration(Configuration configuration) { + this.configuration = configuration; + } +} diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/GETCertificateServlet.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/GETCertificateServlet.java new file mode 100644 index 00000000..d23937f9 --- /dev/null +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/GETCertificateServlet.java @@ -0,0 +1,133 @@ +/* + * 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.local.webapp; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Collections; +import java.util.List; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.bku.local.stal.LocalGETCertificateSTALFactory; +import at.gv.egiz.stal.QuitRequest; +import at.gv.egiz.stal.STAL; +import at.gv.egiz.stal.STALResponse; +import at.gv.egiz.stal.ext.GETCertificateRequest; + +/** +* +* @author Thomas Lenz +*/ + +public class GETCertificateServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + private final Logger log = LoggerFactory.getLogger(GETCertificateServlet.class); + + LocalGETCertificateSTALFactory stalFactory; + + public GETCertificateServlet() { + log.debug("Constuctor: " + GETCertificateServlet.class); + stalFactory = new LocalGETCertificateSTALFactory(); + try { + stalFactory.setHelpURL("http://localhost:3495/help/"); + } catch (MalformedURLException e) { + log.info("Failed to set help URL.", e); + } + } + + /** + * Processes requests for both HTTP GET and POST methods. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + STAL getCerTificateSTAL = stalFactory.createSTAL(); + + List stalResps = getCerTificateSTAL.handleRequest(Collections.singletonList(new GETCertificateRequest())); + + log.debug("Received STAL reponse {}.", stalResps.get(0).getClass()); + + getCerTificateSTAL.handleRequest(Collections.singletonList(new QuitRequest())); + + String redirect = request.getParameter("redirect"); + if (redirect != null) { + String referer = request.getHeader("Referer"); + if (referer != null) { + redirect = new URL(new URL(referer), redirect).toExternalForm(); + } + response.sendRedirect(redirect); + } else { + response.setStatus(HttpServletResponse.SC_OK); + } + } + + // + /** + * Handles the HTTP GET method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + } +} diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/GetHardwareInfoServlet.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/GetHardwareInfoServlet.java new file mode 100644 index 00000000..dc7762a8 --- /dev/null +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/GetHardwareInfoServlet.java @@ -0,0 +1,133 @@ +/* + * 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.local.webapp; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Collections; +import java.util.List; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.bku.local.stal.LocalGetHardwareInfoSTALFactory; +import at.gv.egiz.stal.QuitRequest; +import at.gv.egiz.stal.STAL; +import at.gv.egiz.stal.STALResponse; +import at.gv.egiz.stal.ext.GETHardwareInfoRequest; + +/** +* +* @author Thomas Lenz +*/ + +public class GetHardwareInfoServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + private final Logger log = LoggerFactory.getLogger(GetHardwareInfoServlet.class); + + LocalGetHardwareInfoSTALFactory stalFactory; + + public GetHardwareInfoServlet() { + log.debug("Constuctor: " + GetHardwareInfoServlet.class); + stalFactory = new LocalGetHardwareInfoSTALFactory(); + try { + stalFactory.setHelpURL("http://localhost:3495/help/"); + } catch (MalformedURLException e) { + log.info("Failed to set help URL.", e); + } + } + + /** + * Processes requests for both HTTP GET and POST methods. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + STAL getHardwareInfoSTAL = stalFactory.createSTAL(); + + List stalResps = getHardwareInfoSTAL.handleRequest(Collections.singletonList(new GETHardwareInfoRequest())); + + log.debug("Received STAL reponse {}.", stalResps.get(0).getClass()); + + getHardwareInfoSTAL.handleRequest(Collections.singletonList(new QuitRequest())); + + String redirect = request.getParameter("redirect"); + if (redirect != null) { + String referer = request.getHeader("Referer"); + if (referer != null) { + redirect = new URL(new URL(referer), redirect).toExternalForm(); + } + response.sendRedirect(redirect); + } else { + response.setStatus(HttpServletResponse.SC_OK); + } + } + + // + /** + * Handles the HTTP GET method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP POST method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + } +} diff --git a/BKULocal/src/main/webapp/WEB-INF/web.xml b/BKULocal/src/main/webapp/WEB-INF/web.xml index 628bb044..41d5ab37 100644 --- a/BKULocal/src/main/webapp/WEB-INF/web.xml +++ b/BKULocal/src/main/webapp/WEB-INF/web.xml @@ -51,6 +51,14 @@ IdentityLinkServlet at.gv.egiz.bku.local.webapp.IdentityLinkServlet + + GETCertificateServlet + at.gv.egiz.bku.local.webapp.GETCertificateServlet + + + GETHardwareInfoServlet + at.gv.egiz.bku.local.webapp.GetHardwareInfoServlet + BKUServlet /http-security-layer-request @@ -60,7 +68,6 @@ /https-security-layer-request - PINManagementServlet /PINManagement @@ -69,6 +76,14 @@ IdentityLinkServlet /IdentityLink + + GETCertificateServlet + /GETCertificate + + + GETHardwareInfoServlet + /GETHardwareinfo + index.html index.htm diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java index b507ea70..e6a79e97 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java +++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java @@ -61,7 +61,8 @@ public class MoccaParameterBean { public static final String[] VALUES_APPLET_GUI_STYLE = new String[] {"tiny", "simple", "advanced"}; public static final String PARAM_APPLET_EXTENSION = "appletExtension"; - public static final String[] VALUES_APPLET_EXTENSION = new String[] {"pin", "activation", "identity"}; + public static final String[] VALUES_APPLET_EXTENSION = new String[] {"pin", "activation", + "getcertificate", "hardwareinfo", "identity"}; public static final String PARAM_LOCALE = "locale"; public static final Pattern PATTERN_LOCALE = Pattern.compile("[a-zA-Z][a-zA-Z](_[a-zA-Z][a-zA-Z]){0,2}"); diff --git a/BKUOnline/src/main/webapp/SLRequestForm.html b/BKUOnline/src/main/webapp/SLRequestForm.html index fb910264..cdfc4508 100644 --- a/BKUOnline/src/main/webapp/SLRequestForm.html +++ b/BKUOnline/src/main/webapp/SLRequestForm.html @@ -200,11 +200,13 @@

+

PIN Management Applet Identity Link Applet - + Get Certificate Applet + Hardwareinfo Applet