From 50f7be0c55da14e1b73c39aa18db9808949387bc Mon Sep 17 00:00:00 2001 From: tkellner Date: Mon, 2 Apr 2012 16:38:53 +0000 Subject: 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 --- .../egiz/bku/online/applet/IdentityLinkApplet.java | 59 +++++ .../bku/online/applet/IdentityLinkBKUWorker.java | 96 ++++++++ .../at/gv/egiz/bku/gui/PersonIdentityLinkGUI.java | 242 +++++++++++++++++++++ .../egiz/bku/gui/PersonIdentityLinkGUIFacade.java | 54 +++++ .../gv/egiz/bku/gui/ActivationMessages.properties | 7 + .../egiz/bku/gui/ActivationMessages_de.properties | 7 + .../at/gv/egiz/bku/local/stal/LocalBKUWorker.java | 3 + .../local/stal/LocalIdentityLinkSTALFactory.java | 134 ++++++++++++ .../egiz/bku/local/webapp/IdentityLinkServlet.java | 140 ++++++++++++ BKULocal/src/main/webapp/WEB-INF/web.xml | 8 + .../egiz/bku/online/webapp/MoccaParameterBean.java | 2 +- BKUOnline/src/main/webapp/SLRequestForm.html | 6 +- BKUOnline/src/main/webapp/applet.jsp | 4 + .../java/at/gv/egiz/bku/webstart/Launcher.java | 9 + .../bku/webstart/PersonIdentityLinkInvoker.java | 75 +++++++ .../bku/webstart/gui/BKUControllerInterface.java | 1 + .../at/gv/egiz/bku/webstart/gui/MOCCAIcon.java | 21 +- .../gv/egiz/bku/webstart/gui/StatusNotifier.java | 1 + .../at/gv/egiz/bku/webstart/messages.properties | 3 + .../at/gv/egiz/bku/webstart/messages_de.properties | 2 + smccSTALExt/pom.xml | 5 - .../egiz/bku/smccstal/IdentityLinkExtractor.java | 86 ++++++++ .../smccstal/PersonIdentityLinkRequestHandler.java | 117 ++++++++++ 23 files changed, 1072 insertions(+), 10 deletions(-) create mode 100644 BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/IdentityLinkApplet.java create mode 100644 BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/IdentityLinkBKUWorker.java create mode 100644 BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PersonIdentityLinkGUI.java create mode 100644 BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PersonIdentityLinkGUIFacade.java create mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalIdentityLinkSTALFactory.java create mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/IdentityLinkServlet.java create mode 100644 BKUWebStart/src/main/java/at/gv/egiz/bku/webstart/PersonIdentityLinkInvoker.java create mode 100644 smccSTALExt/src/main/java/at/gv/egiz/bku/smccstal/IdentityLinkExtractor.java create mode 100644 smccSTALExt/src/main/java/at/gv/egiz/bku/smccstal/PersonIdentityLinkRequestHandler.java 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 + */ +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 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 + */ +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 + */ +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=Unblock PIN title.activate.success=Success title.change.success=Success title.unblock.success=Success +title.identity=Person Identity Link # removed message.* prefix to reuse keys as help keys pin.mgmt={0} PINs available +identity.msg=The person identity link +identity.button=Cancel +identity.firstname=Firstname +identity.dateofbirth=Date Of Birth +identity.lastname=Lastname + # software pin-entry messages activate.pin=Enter and confirm {0} change.pin=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=PIN entsperren title.activate.success=Erfolg title.change.success=Erfolg title.unblock.success=Erfolg +title.identity=Personenbindung + +identity.msg=Informationen zur Personenbindung +identity.button=Abbrechen +identity.firstname=Vorname +identity.dateofbirth=Geburtsdatum +identity.lastname=Nachname # removed message.* prefix to reuse keys as help keys pin.mgmt=Die Karte verf\u00FCgt \u00FCber {0} PINs 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 + */ +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 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 { + log.info("processRequest: IdentityLinkServlet"); + STAL pinMgmtSTAL = stalFactory.createSTAL(); + List 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 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); + } +} 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 @@ PINManagementServlet at.gv.egiz.bku.local.webapp.PINManagementServlet + + IdentityLinkServlet + at.gv.egiz.bku.local.webapp.IdentityLinkServlet + BKUServlet /http-security-layer-request @@ -61,6 +65,10 @@ PINManagementServlet /PINManagement + + IdentityLinkServlet + /IdentityLink + 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 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 @@

- - PIN Management Applet + + PIN Management Applet + Identity Link Applet +