diff options
author | tkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2012-04-02 16:38:53 +0000 |
---|---|---|
committer | tkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2012-04-02 16:38:53 +0000 |
commit | 50f7be0c55da14e1b73c39aa18db9808949387bc (patch) | |
tree | d43e7d3dec5f79cef7ac876f796ad7092f3d4ae6 | |
parent | 5b9e4b3e9ed531689700b2e0f75907fd9281a042 (diff) | |
download | mocca-50f7be0c55da14e1b73c39aa18db9808949387bc.tar.gz mocca-50f7be0c55da14e1b73c39aa18db9808949387bc.tar.bz2 mocca-50f7be0c55da14e1b73c39aa18db9808949387bc.zip |
Person Identity Link Extension:
for Webstart and Applet version
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1040 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
23 files changed, 1072 insertions, 10 deletions
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/IdentityLinkApplet.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/IdentityLinkApplet.java new file mode 100644 index 00000000..08193603 --- /dev/null +++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/IdentityLinkApplet.java @@ -0,0 +1,59 @@ +/* + * 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.HelpListener; +import at.gv.egiz.bku.gui.PersonIdentityLinkGUI; +import at.gv.egiz.bku.gui.PersonIdentityLinkGUIFacade; +import at.gv.egiz.bku.gui.SwitchFocusListener; +import at.gv.egiz.bku.gui.viewer.FontProvider; + +/** + * + * @author Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> + */ +public class IdentityLinkApplet 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 PersonIdentityLinkGUI(contentPane, locale, + backgroundImgURL, fontProvider, helpListener, + switchFocusListener); + } + + @Override + protected AppletBKUWorker createBKUWorker(BKUApplet applet, BKUGUIFacade gui) { + return new IdentityLinkBKUWorker(applet, (PersonIdentityLinkGUIFacade) gui); + } +} diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/IdentityLinkBKUWorker.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/IdentityLinkBKUWorker.java new file mode 100644 index 00000000..5a76e935 --- /dev/null +++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/IdentityLinkBKUWorker.java @@ -0,0 +1,96 @@ +/* + * 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.PersonIdentityLinkGUIFacade; +import at.gv.egiz.bku.smccstal.PersonIdentityLinkRequestHandler; +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.PersonIdentityLinkRequest; +import at.gv.egiz.stal.ext.PersonIdentityLinkResponse; + +public class IdentityLinkBKUWorker extends AppletBKUWorker { + private final Logger log = LoggerFactory.getLogger(IdentityLinkBKUWorker.class); + + public IdentityLinkBKUWorker(BKUApplet applet, PersonIdentityLinkGUIFacade gui) { + super(applet, gui); + removeRequestHandler(InfoboxReadRequest.class); + removeRequestHandler(SignRequest.class); + addRequestHandler(PersonIdentityLinkRequest.class, new PersonIdentityLinkRequestHandler()); + } + + @Override + public void run() { + log.error("Identity Link IdentityLinkBKUWorker running."); + /*gui.showMessageDialog(BKUGUIFacade.TITLE_WELCOME, + BKUGUIFacade.MESSAGE_WELCOME);*/ + + try { + + List<STALResponse> responses = handleRequest(Collections.singletonList(new PersonIdentityLinkRequest())); + handleRequest(Collections.singletonList(new QuitRequest())); + + if (responses.size() == 1) { + STALResponse response = responses.get(0); + if (response instanceof PersonIdentityLinkResponse) { + log.info("Identity Link dialog terminated."); + } else if (response instanceof ErrorResponse) { + log.info("Identity Link 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/PersonIdentityLinkGUI.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PersonIdentityLinkGUI.java new file mode 100644 index 00000000..a17a9a0f --- /dev/null +++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PersonIdentityLinkGUI.java @@ -0,0 +1,242 @@ +/* + * 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.net.URL; +import java.text.MessageFormat; +import java.util.Locale; + +import javax.swing.GroupLayout; +import javax.swing.GroupLayout.Alignment; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.LayoutStyle; +import javax.swing.LayoutStyle.ComponentPlacement; +import javax.swing.SwingUtilities; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.bku.gui.viewer.FontProvider; + +/** + * Implements GUI for the person identity link informations + * + * @author Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> + */ +public class PersonIdentityLinkGUI extends CardMgmtGUI implements + PersonIdentityLinkGUIFacade { + + private final Logger log = LoggerFactory + .getLogger(PersonIdentityLinkGUI.class); + + protected JLabel mgmtLabel; + + protected JLabel firstNameLabel_description; + protected JLabel lastNameLabel_description; + protected JLabel birthdateLabel_description; + + protected JLabel firstNameLabel; + protected JLabel lastNameLabel; + protected JLabel birthdateLabel; + + protected JButton activateButton; + + public PersonIdentityLinkGUI(Container contentPane, Locale locale, URL backgroundImgURL, FontProvider fontProvider, + HelpListener helpListener, SwitchFocusListener switchFocusListener) { + super(contentPane, locale, Style.advanced, backgroundImgURL, fontProvider, + helpListener, switchFocusListener); + // TODO Auto-generated constructor stub + this.activateButton = new JButton(); + } + + @Override + public void showPersonIdentityLinkInformationDialog( + final ActionListener activateListener, + final String actionCommand, + final String firstName, + final String surName, + final String birthdate) { + log.debug("Scheduling Person Identity Link dialog."); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + log.debug("Show Person Identity Link dialog."); + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + mgmtLabel = new JLabel(); + mgmtLabel.setFont(mgmtLabel.getFont().deriveFont( + mgmtLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + + if (renderHeaderPanel) { + titleLabel.setText(getMessage(PersonIdentityLinkGUIFacade.TITLE_IDENITY)); + mgmtLabel.setText(getMessage(PersonIdentityLinkGUIFacade.MESSAGE_IDENITY)); + } else { + mgmtLabel.setText(getMessage(PersonIdentityLinkGUIFacade.TITLE_IDENITY)); + } + + activateButton.setFont(activateButton.getFont().deriveFont( + activateButton.getFont().getStyle() + & ~java.awt.Font.BOLD)); + activateButton.addActionListener(activateListener); + activateButton.setActionCommand(actionCommand); + + activateButton.setText(getMessage(PersonIdentityLinkGUIFacade.IDENTIFY_BUTTON)); + + firstNameLabel_description = new JLabel(); + firstNameLabel_description.setText(getMessage(PersonIdentityLinkGUIFacade.FIRSTNAME)); + lastNameLabel_description = new JLabel(); + lastNameLabel_description.setText(getMessage(PersonIdentityLinkGUIFacade.LASTNAME)); + + birthdateLabel_description = new JLabel(); + birthdateLabel_description.setText(getMessage(PersonIdentityLinkGUIFacade.DATEOFBIRTH)); + + + firstNameLabel = new JLabel(); + firstNameLabel.setText(firstName); + + firstNameLabel.setFont(firstNameLabel.getFont().deriveFont( + firstNameLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + + lastNameLabel = new JLabel(); + lastNameLabel.setText(surName); + + lastNameLabel.setFont(lastNameLabel.getFont().deriveFont( + lastNameLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + + birthdateLabel = new JLabel(); + birthdateLabel.setText(birthdate); + + birthdateLabel.setFont(birthdateLabel.getFont().deriveFont( + birthdateLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + + updateMethodToRunAtResize("at.gv.egiz.bku.gui.PersonIdentityLinkGUI", "renderContentAndButtons"); + + renderContentAndButtons(); + + cancelButton.requestFocus(); + contentPanel.validate(); + + if(windowCloseAdapter != null) + { + windowCloseAdapter.registerListener(activateListener, actionCommand); + } + + + + resize(); + } + + }); + } + + public void renderContentAndButtons() { + + // It is necessary to remove old components in order to ensure + // the correct rendering of the status table and the button panel + mainPanel.removeAll(); + buttonPanel.removeAll(); + + //JScrollPane pinStatusScrollPane = new JScrollPane(pinStatusTable); + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout + .createSequentialGroup().addComponent(mgmtLabel); + GroupLayout.Group messageVertical = mainPanelLayout + .createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(mgmtLabel); + + if (!renderHeaderPanel) { + + + messageHorizontal.addPreferredGap( + LayoutStyle.ComponentPlacement.UNRELATED, 0, + Short.MAX_VALUE).addComponent(switchFocusDummyLabel) + .addComponent(helpLabel); + messageVertical.addComponent(switchFocusDummyLabel).addComponent( + helpLabel); + } + + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + //.addContainerGap() + .addGroup(mainPanelLayout.createParallelGroup(Alignment.LEADING) + .addGroup(messageHorizontal) + .addGroup(mainPanelLayout.createSequentialGroup() + .addGroup(mainPanelLayout.createParallelGroup(Alignment.LEADING) + .addComponent(firstNameLabel_description) + .addComponent(lastNameLabel_description) + .addComponent(birthdateLabel_description)) + .addPreferredGap(ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(Alignment.LEADING) + .addComponent(firstNameLabel) + .addComponent(lastNameLabel) + .addComponent(birthdateLabel))))) + ); + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createParallelGroup(Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + //.addContainerGap() + .addGroup(messageVertical) + .addPreferredGap(ComponentPlacement.UNRELATED) + .addGroup(mainPanelLayout.createParallelGroup(Alignment.BASELINE) + .addComponent(firstNameLabel_description) + .addComponent(firstNameLabel)) + //.addPreferredGap(ComponentPlacement.UNRELATED) + .addGroup(mainPanelLayout.createParallelGroup(Alignment.BASELINE) + .addComponent(lastNameLabel_description) + .addComponent(lastNameLabel)) + //.addPreferredGap(ComponentPlacement.UNRELATED) + .addGroup(mainPanelLayout.createParallelGroup(Alignment.BASELINE) + .addComponent(birthdateLabel_description) + .addComponent(birthdateLabel))) + ); + + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + GroupLayout.SequentialGroup buttonHorizontal = buttonPanelLayout + .createSequentialGroup().addContainerGap( + GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(activateButton, GroupLayout.PREFERRED_SIZE, + buttonSize, GroupLayout.PREFERRED_SIZE); + + GroupLayout.Group buttonVertical = buttonPanelLayout + .createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(activateButton); + + buttonPanelLayout.setHorizontalGroup(buttonHorizontal); + buttonPanelLayout.setVerticalGroup(buttonVertical); + + } +} diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PersonIdentityLinkGUIFacade.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PersonIdentityLinkGUIFacade.java new file mode 100644 index 00000000..0c565c3a --- /dev/null +++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PersonIdentityLinkGUIFacade.java @@ -0,0 +1,54 @@ +/* + * 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 Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> + */ +public interface PersonIdentityLinkGUIFacade extends BKUGUIFacade { + + public static final String FIRSTNAME = "identity.firstname"; + public static final String DATEOFBIRTH = "identity.dateofbirth"; + public static final String LASTNAME = "identity.lastname"; + public static final String TITLE_IDENITY = "title.identity"; + + public static final String MESSAGE_IDENITY = "identity.msg"; + public static final String IDENTIFY_BUTTON = "identity.button"; + /** + * Currently dummy method to display anything ... + * + * @param firstName + * @param surName + */ + public void showPersonIdentityLinkInformationDialog( + ActionListener activateListener, + String actionCommand, + String firstName, + String surName, + String birthdate); +} 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 40c666ed..8da9a06c 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 @@ -28,9 +28,16 @@ title.unblock.pin=<html>Unblock PIN</html> title.activate.success=<html>Success</html> title.change.success=<html>Success</html> title.unblock.success=<html>Success</html> +title.identity=<html>Person Identity Link</html> # removed message.* prefix to reuse keys as help keys pin.mgmt=<html>{0} PINs available +identity.msg=<html>The person identity link +identity.button=<html>Cancel</html> +identity.firstname=<html>Firstname</html> +identity.dateofbirth=<html>Date Of Birth</html> +identity.lastname=<html>Lastname</html> + # software pin-entry messages activate.pin=<html>Enter and confirm {0} change.pin=<html>Enter and confirm {0} 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 f3491080..1935d31b 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 @@ -28,6 +28,13 @@ title.unblock.pin=<html>PIN entsperren</html> title.activate.success=<html>Erfolg</html> title.change.success=<html>Erfolg</html> title.unblock.success=<html>Erfolg</html> +title.identity=<html>Personenbindung</html> + +identity.msg=<html>Informationen zur Personenbindung +identity.button=<html>Abbrechen</html> +identity.firstname=<html>Vorname</html> +identity.dateofbirth=<html>Geburtsdatum</html> +identity.lastname=<html>Nachname</html> # removed message.* prefix to reuse keys as help keys pin.mgmt=<html>Die Karte verf\u00FCgt \u00FCber {0} PINs</html> 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 f9dab561..c41ac234 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 @@ -27,11 +27,13 @@ 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.PINManagementRequestHandler; +import at.gv.egiz.bku.smccstal.PersonIdentityLinkRequestHandler; import at.gv.egiz.stal.QuitRequest; import at.gv.egiz.stal.STALRequest; 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.PINManagementRequest; import java.util.List; import javax.swing.JFrame; @@ -50,6 +52,7 @@ public class LocalBKUWorker extends AbstractBKUWorker { addRequestHandler(SignRequest.class, new LocalSignRequestHandler(new LocalSecureViewer(gui))); addRequestHandler(PINManagementRequest.class, new PINManagementRequestHandler()); + addRequestHandler(PersonIdentityLinkRequest.class, new PersonIdentityLinkRequestHandler()); } /** does not change container's visibility (use quit request to close) */ diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalIdentityLinkSTALFactory.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalIdentityLinkSTALFactory.java new file mode 100644 index 00000000..c64f029c --- /dev/null +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalIdentityLinkSTALFactory.java @@ -0,0 +1,134 @@ +/* + * 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.PersonIdentityLinkGUI; +import at.gv.egiz.bku.gui.PersonIdentityLinkGUIFacade; +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; + +public class LocalIdentityLinkSTALFactory implements STALFactory { + + private final Logger log = LoggerFactory + .getLogger(LocalIdentityLinkSTALFactory.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."); + } + PersonIdentityLinkGUIFacade gui = new PersonIdentityLinkGUI(dialog.getContentPane(), + dialog.getLocale(), + null, + new ResourceFontLoader(), + helpListener, + null); + BKUGUIFacade proxy = (BKUGUIFacade) GUIProxy.newInstance(gui, dialog, new Class[] { PersonIdentityLinkGUIFacade.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/IdentityLinkServlet.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/IdentityLinkServlet.java new file mode 100644 index 00000000..31c78cb0 --- /dev/null +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/IdentityLinkServlet.java @@ -0,0 +1,140 @@ +/* + * 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.LocalIdentityLinkSTALFactory; +import at.gv.egiz.stal.QuitRequest; +import at.gv.egiz.stal.STAL; +import at.gv.egiz.stal.STALResponse; +import at.gv.egiz.stal.ext.PersonIdentityLinkRequest; + +/** + * IdentityLink BKU Worker for non-applet version + * + * @author Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> + */ +public class IdentityLinkServlet extends HttpServlet { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private final Logger log = LoggerFactory + .getLogger(IdentityLinkServlet.class); + + LocalIdentityLinkSTALFactory stalFactory; + + public IdentityLinkServlet() { + stalFactory = new LocalIdentityLinkSTALFactory(); + try { + stalFactory.setHelpURL("http://localhost:3495/help/"); + } catch (MalformedURLException e) { + log.info("Failed to set help URL.", e); + } + } + + /** + * Processes requests for both HTTP <code>GET</code> and <code>POST</code> + * 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 { + log.info("processRequest: IdentityLinkServlet"); + STAL pinMgmtSTAL = stalFactory.createSTAL(); + List<STALResponse> stalResps = pinMgmtSTAL.handleRequest(Collections.singletonList(new PersonIdentityLinkRequest())); + log.debug("Received STAL reponse {}.", stalResps.get(0).getClass()); + pinMgmtSTAL.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 <code>GET</code> 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 <code>POST</code> 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); + } +} diff --git a/BKULocal/src/main/webapp/WEB-INF/web.xml b/BKULocal/src/main/webapp/WEB-INF/web.xml index 5704e687..628bb044 100644 --- a/BKULocal/src/main/webapp/WEB-INF/web.xml +++ b/BKULocal/src/main/webapp/WEB-INF/web.xml @@ -47,6 +47,10 @@ <servlet-name>PINManagementServlet</servlet-name> <servlet-class>at.gv.egiz.bku.local.webapp.PINManagementServlet</servlet-class> </servlet> + <servlet> + <servlet-name>IdentityLinkServlet</servlet-name> + <servlet-class>at.gv.egiz.bku.local.webapp.IdentityLinkServlet</servlet-class> + </servlet> <servlet-mapping> <servlet-name>BKUServlet</servlet-name> <url-pattern>/http-security-layer-request</url-pattern> @@ -61,6 +65,10 @@ <servlet-name>PINManagementServlet</servlet-name> <url-pattern>/PINManagement</url-pattern> </servlet-mapping> + <servlet-mapping> + <servlet-name>IdentityLinkServlet</servlet-name> + <url-pattern>/IdentityLink</url-pattern> + </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> 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 33bf22bb..b507ea70 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,7 @@ 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"}; + public static final String[] VALUES_APPLET_EXTENSION = new String[] {"pin", "activation", "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 c9e85cfa..fb910264 100644 --- a/BKUOnline/src/main/webapp/SLRequestForm.html +++ b/BKUOnline/src/main/webapp/SLRequestForm.html @@ -201,8 +201,10 @@ <input value="de_AT" name="locale"/> </p> <p> - <label for="appletExtension">PIN Management</label> - <input type="checkbox" name="appletExtension" value="pin" onclick="setAppletDimension(295, 235)">PIN Management Applet + <label for="appletExtension">Extensions</label> + <input type="radio" name="appletExtension" value="pin" onclick="setAppletDimension(295, 235)">PIN Management Applet + <input type="radio" name="appletExtension" value="identity" onclick="setAppletDimension(295, 235)">Identity Link Applet + <!--<input type="checkbox" name="appletExtension" value="pin" onclick="setAppletDimension(295, 235)">PIN Management Applet--> </p> <!-- diff --git a/BKUOnline/src/main/webapp/applet.jsp b/BKUOnline/src/main/webapp/applet.jsp index de1e6bb9..bf657a9e 100644 --- a/BKUOnline/src/main/webapp/applet.jsp +++ b/BKUOnline/src/main/webapp/applet.jsp @@ -61,6 +61,10 @@ <c:set var="appletArchive" value="BKUAppletExt-single.jar"/> <c:set var="appletClass" value="at.gv.egiz.bku.online.applet.PINManagementApplet.class"/> </c:when> + <c:when test="${requestScope.moccaParam.extension == 'identity'}"> + <c:set var="appletArchive" value="BKUAppletExt-single.jar"/> + <c:set var="appletClass" value="at.gv.egiz.bku.online.applet.IdentityLinkApplet.class"/> + </c:when> <c:otherwise> <c:set var="appletArchive" value="BKUApplet-single.jar"/> <c:set var="appletClass" value="at.gv.egiz.bku.online.applet.BKUApplet.class"/> 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 f9500f8c..2719e990 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 @@ -65,12 +65,14 @@ public class Launcher implements BKUControllerInterface { public static final URL HTTPS_SECURITY_LAYER_URL; 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 HELP_URL; static { URL http = null; URL https = null; URL pin = null; + URL ident = null; URL cert = null; URL help = null; try { @@ -79,12 +81,14 @@ public class Launcher implements BKUControllerInterface { pin = new URL(http, "/PINManagement"); cert = new URL(http, "/ca.crt"); help = new URL(http, "/help/"); + ident = new URL(http, "/IdentityLink"); } catch (MalformedURLException ex) { log.error("Failed to create URL.", ex); } finally { HTTP_SECURITY_LAYER_URL = http; HTTPS_SECURITY_LAYER_URL = https; PIN_MANAGEMENT_URL = pin; + IDENTITY_LINK_URL = ident; INSTALL_CERT_URL = cert; HELP_URL = help; } @@ -307,4 +311,9 @@ public class Launcher implements BKUControllerInterface { public boolean setAutostart(boolean doAutostart) { return autostart.set(doAutostart); } + + @Override + public void personIdentityLink(Locale locale) { + new Thread(new PersonIdentityLinkInvoker(status)).start(); + } } diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/PersonIdentityLinkInvoker.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/PersonIdentityLinkInvoker.java new file mode 100644 index 00000000..249d7a15 --- /dev/null +++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/PersonIdentityLinkInvoker.java @@ -0,0 +1,75 @@ +/* + * 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 Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> + */ +public class PersonIdentityLinkInvoker implements Runnable { + + private static final Logger log = LoggerFactory.getLogger(PersonIdentityLinkInvoker.class); + + private StatusNotifier status; + + public PersonIdentityLinkInvoker(StatusNotifier status) { + this.status = status; + } + + @Override + public void run() { + HttpURLConnection connection = null; + try { + log.info("Connecting to: " + Launcher.IDENTITY_LINK_URL); + + connection = (HttpURLConnection) Launcher.IDENTITY_LINK_URL.openConnection(); + + connection.setRequestMethod("GET"); + connection.setReadTimeout(0); + connection.connect(); + + if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { + log.info("person identity link dialog returned"); + } else { + log.error("unexpected response from person identity link: " + connection.getResponseMessage()); + } + } catch (IOException ex) { + log.error("Failed to connect to person identity link", ex); + status.error(StatusNotifier.ERROR_IDENTITY_LINK); + } finally { + if (connection != null) { + connection.disconnect(); + } + } + } +} 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 a340c980..2d91f2f2 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 @@ -36,6 +36,7 @@ public interface BKUControllerInterface { public void pinManagement(Locale locale); + public void personIdentityLink(Locale locale); /** * Check if MOCCA Autostart is possible 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 64b94424..3c6fe6f0 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 @@ -57,11 +57,14 @@ 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"; /** action commands for tray menu */ private static enum COMMANDS { - SHUTDOWN_COMMAND, PIN_COMMAND, ABOUT_COMMAND, HELP_COMMAND, AUTOSTART_COMMAND + SHUTDOWN_COMMAND, PIN_COMMAND, ABOUT_COMMAND, + HELP_COMMAND, AUTOSTART_COMMAND, IDENTITYLINK_COMMAND }; private static final Logger log = LoggerFactory.getLogger(MOCCAIcon.class); @@ -104,6 +107,13 @@ 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); MenuItem pinItem = new MenuItem(messages.getString(LABEL_PIN)); pinItem.addActionListener(this); @@ -114,8 +124,10 @@ public class MOCCAIcon implements StatusNotifier, ActionListener, ItemListener { messages.getString(LABEL_ABOUT)); aboutItem.setActionCommand(COMMANDS.ABOUT_COMMAND.name()); aboutItem.addActionListener(this); - menu.add(aboutItem); + infoMenu.add(aboutItem); + menu.add(infoMenu); + menu.addSeparator(); Menu settingsMenu = new Menu(messages.getString(LABEL_SETTINGS)); @@ -232,6 +244,11 @@ public class MOCCAIcon implements StatusNotifier, ActionListener, ItemListener { controller.showHelp(messages.getLocale()); break; + case IDENTITYLINK_COMMAND: + log.debug("person identity link dialog requested via tray menu"); + controller.personIdentityLink(messages.getLocale()); + break; + default: log.error("unknown tray menu command: " + e.getActionCommand()); } diff --git a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/StatusNotifier.java b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/StatusNotifier.java index a089d0b3..b2ee60cb 100644 --- a/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/StatusNotifier.java +++ b/BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/gui/StatusNotifier.java @@ -49,6 +49,7 @@ public interface StatusNotifier { public static final String ERROR_BIND = "tray.error.bind"; public static final String ERROR_CONFIG = "tray.error.config"; public static final String ERROR_PIN = "tray.error.pin.connect"; + public static final String ERROR_IDENTITY_LINK = "tray.error.identity_link.connect"; public static final String ERROR_OPEN_URL = "tray.error.open.url"; diff --git a/BKUWebStart/src/main/resources/at/gv/egiz/bku/webstart/messages.properties b/BKUWebStart/src/main/resources/at/gv/egiz/bku/webstart/messages.properties index 2d92db03..6069874f 100644 --- a/BKUWebStart/src/main/resources/at/gv/egiz/bku/webstart/messages.properties +++ b/BKUWebStart/src/main/resources/at/gv/egiz/bku/webstart/messages.properties @@ -31,13 +31,16 @@ tray.error.start=failed to start CitizenCard environment tray.error.config=failed to initialize configuration, CitizenCard environment not started tray.error.bind=another service is using the address reserved for the CitizenCard environment tray.error.pin.connect=failed to connect to PIN management +tray.error.identity_link.connect=failed to connect to Person identity link tray.error.open.url=failed to open {0} tray.label.shutdown=Close tray.label.pin=PIN management tray.label.help=Help tray.label.about=About... tray.label.settings=Settings +tray.label.infomenu=Infos tray.label.autostart=Autostart +tray.label.identitylink=IdentityLink tray.tooltip.default=CitizenCard about.frame.title=CitizenCard about.title=<html>CitizenCard Environment diff --git a/BKUWebStart/src/main/resources/at/gv/egiz/bku/webstart/messages_de.properties b/BKUWebStart/src/main/resources/at/gv/egiz/bku/webstart/messages_de.properties index 44720f5f..a07abb63 100644 --- a/BKUWebStart/src/main/resources/at/gv/egiz/bku/webstart/messages_de.properties +++ b/BKUWebStart/src/main/resources/at/gv/egiz/bku/webstart/messages_de.properties @@ -38,6 +38,8 @@ tray.label.help=Hilfe tray.label.about=\u00DCber... tray.label.settings=Einstellungen tray.label.autostart=Autostart +tray.label.infomenu=Informationen +tray.label.identitylink=Personenbindung tray.tooltip.default=B\u00FCrgerkartenumgebung about.frame.title=B\u00FCrgerkarte about.title=<html>B\u00FCrgerkartenumgebung diff --git a/smccSTALExt/pom.xml b/smccSTALExt/pom.xml index 3eb1e059..03a27e2f 100644 --- a/smccSTALExt/pom.xml +++ b/smccSTALExt/pom.xml @@ -23,10 +23,5 @@ <artifactId>BKUGuiExt</artifactId> <version>${project.parent.version}</version> </dependency> - <dependency> - <groupId>at.gv.egiz</groupId> - <artifactId>utils</artifactId> - <version>${project.parent.version}</version> - </dependency> </dependencies> </project>
\ No newline at end of file diff --git a/smccSTALExt/src/main/java/at/gv/egiz/bku/smccstal/IdentityLinkExtractor.java b/smccSTALExt/src/main/java/at/gv/egiz/bku/smccstal/IdentityLinkExtractor.java new file mode 100644 index 00000000..b1aa9326 --- /dev/null +++ b/smccSTALExt/src/main/java/at/gv/egiz/bku/smccstal/IdentityLinkExtractor.java @@ -0,0 +1,86 @@ +/* + * 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.smccstal; + +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import iaik.me.asn1.ASN1; + +public class IdentityLinkExtractor { + + private static final Logger log = LoggerFactory.getLogger(IdentityLinkExtractor.class); + + private static ASN1 getPersonData(ASN1 identityLink) throws IOException + { + if(identityLink.getSize() > 4 ) + { + ASN1 data = identityLink.getElementAt(4).gvASN1(); + if(data.getTagClass() != 0) + { + log.error("CorporateBodyData currently not supported."); + return null; + } + return data; + } + else + { + log.error("IdentityLink ASN1 invalid size = " + identityLink.getSize()); + return null; + } + } + + public static String getPersonFirstName(ASN1 identityLink) throws IOException + { + ASN1 personData = getPersonData(identityLink); + if(personData != null) + { + return personData.getElementAt(1).gvString(); + } + return null; + } + + public static String getPersonLastName(ASN1 identityLink) throws IOException + { + ASN1 personData = getPersonData(identityLink); + if(personData != null) + { + return personData.getElementAt(2).gvString(); + } + return null; + } + + public static String getPersonDateOfBirth(ASN1 identityLink) throws IOException + { + ASN1 personData = getPersonData(identityLink); + if(personData != null) + { + return personData.getElementAt(3).gvString(); + } + return null; + } +} diff --git a/smccSTALExt/src/main/java/at/gv/egiz/bku/smccstal/PersonIdentityLinkRequestHandler.java b/smccSTALExt/src/main/java/at/gv/egiz/bku/smccstal/PersonIdentityLinkRequestHandler.java new file mode 100644 index 00000000..d8af52ee --- /dev/null +++ b/smccSTALExt/src/main/java/at/gv/egiz/bku/smccstal/PersonIdentityLinkRequestHandler.java @@ -0,0 +1,117 @@ +/* + * 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.smccstal; + +import iaik.me.asn1.ASN1; + +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.bku.gui.PINManagementGUIFacade; +import at.gv.egiz.bku.gui.PersonIdentityLinkGUIFacade; +import at.gv.egiz.bku.pin.gui.VerifyPINGUI; +import at.gv.egiz.smcc.SignatureCardException; +import at.gv.egiz.stal.ErrorResponse; +import at.gv.egiz.stal.STALRequest; +import at.gv.egiz.stal.STALResponse; +import at.gv.egiz.stal.ext.PersonIdentityLinkRequest; +import at.gv.egiz.stal.ext.PersonIdentityLinkResponse; + +/** + * + * @author Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> + */ +public class PersonIdentityLinkRequestHandler extends AbstractRequestHandler { + + private final static String IdentityInfoBox = "IdentityLink"; + + private final Logger log = LoggerFactory.getLogger(PersonIdentityLinkRequestHandler.class); + + //PersonIdentityLinkGUIFacade person_gui = (PersonIdentityLinkGUIFacade) this.gui; + + @Override + public boolean requireCard() { + return true; + } + + @Override + public STALResponse handleRequest(STALRequest request) + throws InterruptedException { + if(request instanceof PersonIdentityLinkRequest) + { + try + { + byte[] identity_asn1 = card.getInfobox(IdentityInfoBox, new VerifyPINGUI(gui), ""); + + ASN1 identity_object = new ASN1(identity_asn1); + + String firstname = IdentityLinkExtractor.getPersonFirstName(identity_object); + String lastname = IdentityLinkExtractor.getPersonLastName(identity_object); + String dateofBirth = IdentityLinkExtractor.getPersonDateOfBirth(identity_object); + + // TODO: correct error handling ... + PersonIdentityLinkGUIFacade person_gui = null; + + if(gui instanceof PersonIdentityLinkGUIFacade) + { + person_gui = (PersonIdentityLinkGUIFacade) gui; + } + + if(person_gui == null) + { + log.warn("Failed to cast gui to PersonIdentityLinkGUIFacade!"); + return new ErrorResponse(1000); + } + + person_gui.showPersonIdentityLinkInformationDialog(this, "ok_action", + firstname, + lastname, + dateofBirth); + + waitForAction(); + + return new PersonIdentityLinkResponse(); + } + catch(SignatureCardException ex) + { + log.error(ex.getMessage(), ex); + //gui.showErrorDialog(errorMsgKey, errorMsgParams) + //waitForAction(); + return new ErrorResponse(1000); + } catch (IOException ex) { + log.error(ex.getMessage(), ex); + //gui.showErrorDialog(errorMsgKey, errorMsgParams) + //waitForAction(); + return new ErrorResponse(1000); + } + } + else + { + log.error("Got unexpected STAL request: {}.", request); + return new ErrorResponse(1000); + } + } +} |