summaryrefslogtreecommitdiff
path: root/BKUAppletExt/src/main/java/at/gv
diff options
context:
space:
mode:
Diffstat (limited to 'BKUAppletExt/src/main/java/at/gv')
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java249
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUIFacade.java33
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java52
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java159
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java34
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusProvider.java32
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/ActivationApplet.java (renamed from BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/ext/BKUAppletExt.java)50
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementApplet.java50
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementBKUWorker.java112
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/CardMgmtRequestHandler.java48
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PINMgmtRequestHandler.java93
11 files changed, 881 insertions, 31 deletions
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java
new file mode 100644
index 00000000..8134ac5f
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java
@@ -0,0 +1,249 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.gui;
+
+import java.awt.Container;
+import java.awt.Cursor;
+import java.awt.event.ActionListener;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import javax.swing.GroupLayout;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JProgressBar;
+import javax.swing.LayoutStyle;
+import javax.swing.SwingUtilities;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class ActivationGUI extends CardMgmtGUI implements ActivationGUIFacade {
+
+ public static final String TITLE_ACTIVATION = "title.activation";
+ public static final String LABEL_ACTIVATION = "label.activation";
+ public static final String LABEL_ACTIVATION_STEP = "label.activation.step";
+ public static final String LABEL_ACTIVATION_IDLE = "label.activation.idle";
+
+ public static final String HELP_ACTIVATION = "help.activation";
+
+ protected JProgressBar progressBar;
+
+ public ActivationGUI(Container contentPane,
+ Locale locale,
+ Style guiStyle,
+ URL backgroundImgURL,
+ AbstractHelpListener helpListener) {
+ super(contentPane, locale, guiStyle, backgroundImgURL, helpListener);
+
+ progressBar = new JProgressBar();
+ }
+
+ @Override
+ public void showActivationProgressDialog(final int currentStep, final int maxProgress, final ActionListener cancelListener, final String cancelCommand) {
+
+ log.debug("scheduling activation progress dialog (step " + currentStep + ")");
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+
+ log.debug("show activation progress dialog (step " + currentStep + ")");
+
+ mainPanel.removeAll();
+ buttonPanel.removeAll();
+
+ mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+
+ JLabel infoLabel = new JLabel();
+ infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+
+ if (renderHeaderPanel) {
+ titleLabel.setText(cardmgmtMessages.getString(TITLE_ACTIVATION));
+ infoLabel.setText(cardmgmtMessages.getString(LABEL_ACTIVATION));
+ } else {
+ infoLabel.setText(cardmgmtMessages.getString(TITLE_ACTIVATION));
+ }
+
+ helpListener.setHelpTopic(HELP_ACTIVATION);
+
+ progressBar.setIndeterminate(false);
+ progressBar.setStringPainted(true);
+ progressBar.setString(null); //reset to percentage
+ progressBar.setMinimum(0);
+ progressBar.setMaximum(maxProgress);
+
+ JLabel stepLabel = new JLabel();
+ stepLabel.setFont(stepLabel.getFont().deriveFont(stepLabel.getFont().getStyle() & ~java.awt.Font.BOLD, stepLabel.getFont().getSize()-2));
+ String stepPattern = cardmgmtMessages.getString(LABEL_ACTIVATION_STEP);
+ stepLabel.setText(MessageFormat.format(stepPattern, new Object[]{ currentStep }));
+
+ GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
+ mainPanel.setLayout(mainPanelLayout);
+
+ GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup().addComponent(infoLabel);
+ GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(infoLabel);
+
+ if (!renderHeaderPanel) {
+ infoHorizontal.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE).addComponent(helpLabel);
+ infoVertical.addComponent(helpLabel);
+ }
+
+ mainPanelLayout.setHorizontalGroup(
+ mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(infoHorizontal)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(stepLabel)
+ .addComponent(progressBar)));
+
+ mainPanelLayout.setVerticalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addGroup(infoVertical)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createSequentialGroup()
+ .addComponent(stepLabel)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(progressBar)));
+
+ JButton cancelButton = new JButton();
+ cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD));
+ cancelButton.setText(messages.getString(BUTTON_CANCEL));
+ cancelButton.addActionListener(cancelListener);
+ cancelButton.setActionCommand(cancelCommand);
+
+ GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
+ buttonPanel.setLayout(buttonPanelLayout);
+
+ buttonPanelLayout.setHorizontalGroup(
+ buttonPanelLayout.createSequentialGroup()
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE));
+ buttonPanelLayout.setVerticalGroup(
+ buttonPanelLayout.createSequentialGroup()
+ .addComponent(cancelButton));
+
+ contentPanel.validate();
+
+ }
+ });
+
+ }
+
+ @Override
+ public void incrementProgress() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ progressBar.setValue(progressBar.getValue() + 1);
+ }
+ });
+
+ }
+
+ @Override
+ public void showIdleDialog(final ActionListener cancelListener, final String cancelCommand) {
+ log.debug("scheduling idle dialog");
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+
+ log.debug("show idle dialog");
+
+ mainPanel.removeAll();
+ buttonPanel.removeAll();
+
+ mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+
+ JLabel infoLabel = new JLabel();
+ infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+
+ if (renderHeaderPanel) {
+ titleLabel.setText(cardmgmtMessages.getString(TITLE_ACTIVATION));
+ infoLabel.setText(cardmgmtMessages.getString(LABEL_ACTIVATION));
+ } else {
+ infoLabel.setText(cardmgmtMessages.getString(TITLE_ACTIVATION));
+ }
+
+ helpListener.setHelpTopic(HELP_ACTIVATION);
+
+ progressBar.setIndeterminate(true);
+ progressBar.setStringPainted(true);
+ progressBar.setString(""); //not string painted progressbar is smaller
+
+ JLabel stepLabel = new JLabel();
+ stepLabel.setFont(stepLabel.getFont().deriveFont(stepLabel.getFont().getStyle() & ~java.awt.Font.BOLD, stepLabel.getFont().getSize()-2));
+ stepLabel.setText(cardmgmtMessages.getString(LABEL_ACTIVATION_IDLE));
+
+ GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
+ mainPanel.setLayout(mainPanelLayout);
+
+ GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup().addComponent(infoLabel);
+ GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(infoLabel);
+
+ if (!renderHeaderPanel) {
+ infoHorizontal.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE).addComponent(helpLabel);
+ infoVertical.addComponent(helpLabel);
+ }
+
+ mainPanelLayout.setHorizontalGroup(
+ mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(infoHorizontal)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(stepLabel)
+ .addComponent(progressBar)));
+
+ mainPanelLayout.setVerticalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addGroup(infoVertical)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createSequentialGroup()
+ .addComponent(stepLabel)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(progressBar)));
+
+ JButton cancelButton = new JButton();
+ cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD));
+ cancelButton.setText(messages.getString(BUTTON_CANCEL));
+ cancelButton.addActionListener(cancelListener);
+ cancelButton.setActionCommand(cancelCommand);
+
+ GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
+ buttonPanel.setLayout(buttonPanelLayout);
+
+ buttonPanelLayout.setHorizontalGroup(
+ buttonPanelLayout.createSequentialGroup()
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE));
+ buttonPanelLayout.setVerticalGroup(
+ buttonPanelLayout.createSequentialGroup()
+ .addComponent(cancelButton));
+
+ contentPanel.validate();
+
+ }
+ });
+
+ }
+}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUIFacade.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUIFacade.java
new file mode 100644
index 00000000..860a1097
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUIFacade.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.gui;
+
+import java.awt.event.ActionListener;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public interface ActivationGUIFacade extends BKUGUIFacade {
+
+ public void showActivationProgressDialog(int currentStep, int maxProgress, ActionListener cancelListener, String cancelCommand);
+
+ public void incrementProgress();
+
+ public void showIdleDialog(ActionListener cancelListener, String cancelCommand);
+
+}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java
new file mode 100644
index 00000000..4059f0e2
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import java.awt.Container;
+import java.net.URL;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * Common superclass for Activation and PinManagement GUIs
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class CardMgmtGUI extends BKUGUIImpl {
+
+ public static final String CARDMGMT_MESSAGES_BUNDLE = "at/gv/egiz/bku/gui/ActivationMessages";
+
+ protected ResourceBundle cardmgmtMessages;
+
+ public CardMgmtGUI(Container contentPane,
+ Locale locale,
+ Style guiStyle,
+ URL backgroundImgURL,
+ AbstractHelpListener helpListener) {
+ super(contentPane, locale, guiStyle, backgroundImgURL, helpListener);
+
+ if (locale != null) {
+ Locale lang = new Locale(locale.getLanguage().substring(0,2));
+ log.debug("loading applet resources for language: " + lang.toString());
+ cardmgmtMessages = ResourceBundle.getBundle(CARDMGMT_MESSAGES_BUNDLE, lang);
+ } else {
+ cardmgmtMessages = ResourceBundle.getBundle(CARDMGMT_MESSAGES_BUNDLE);
+ }
+
+ }
+}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java
new file mode 100644
index 00000000..8acf051e
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import java.awt.Container;
+import java.awt.event.ActionListener;
+import java.net.URL;
+import java.util.Locale;
+import javax.swing.GroupLayout;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.LayoutStyle;
+import javax.swing.SwingUtilities;
+
+/**
+ * TODO pull out ResourceBundle to common superclass for activationGUI and pinMgmtGUI
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class PINManagementGUI extends ActivationGUI implements PINManagementGUIFacade {
+
+ public static final String BUTTON_ACTIVATE = "button.activate";
+ public static final String BUTTON_UNBLOCK = "button.unblock";
+ public static final String BUTTON_CHANGE = "button.change";
+
+ public PINManagementGUI(Container contentPane,
+ Locale locale,
+ Style guiStyle,
+ URL backgroundImgURL,
+ AbstractHelpListener helpListener) {
+ super(contentPane, locale, guiStyle, backgroundImgURL, helpListener);
+ }
+
+ @Override
+ public void showPINManagementDialog(final PINStatusProvider pinStatusProvider,
+ final ActionListener activateListener, final String activateCmd,
+ final ActionListener changeListener, final String changeCmd,
+ final ActionListener unblockListener, final String unblockCmd,
+ final ActionListener cancelListener, final String cancelCmd) {
+// try {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ log.debug("show PIN management dialog");
+
+ mainPanel.removeAll();
+ buttonPanel.removeAll();
+
+ helpListener.setHelpTopic(HELP_PINMGMT);
+
+ JLabel mgmtLabel = new JLabel();
+ mgmtLabel.setFont(mgmtLabel.getFont().deriveFont(mgmtLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+
+ if (renderHeaderPanel) {
+ titleLabel.setText(cardmgmtMessages.getString(TITLE_PINMGMT));
+ mgmtLabel.setText(cardmgmtMessages.getString(MESSAGE_PINMGMT));
+ } else {
+ mgmtLabel.setText(cardmgmtMessages.getString(TITLE_PINMGMT));
+ }
+
+
+
+
+ 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(helpLabel);
+ messageVertical
+ .addComponent(helpLabel);
+ }
+
+ mainPanelLayout.setHorizontalGroup(messageHorizontal);
+ mainPanelLayout.setVerticalGroup(messageVertical);
+
+
+ JButton activateButton = new JButton();
+ activateButton.setFont(activateButton.getFont().deriveFont(activateButton.getFont().getStyle() & ~java.awt.Font.BOLD));
+ activateButton.setText(cardmgmtMessages.getString(BUTTON_ACTIVATE));
+ activateButton.setEnabled(true);//false);
+ activateButton.setActionCommand(activateCmd);
+ activateButton.addActionListener(activateListener);
+
+ JButton changeButton = new JButton();
+ changeButton.setFont(activateButton.getFont().deriveFont(activateButton.getFont().getStyle() & ~java.awt.Font.BOLD));
+ changeButton.setText(cardmgmtMessages.getString(BUTTON_CHANGE));
+ changeButton.setEnabled(false);
+ changeButton.setActionCommand(changeCmd);
+ changeButton.addActionListener(changeListener);
+
+ JButton unblockButton = new JButton();
+ unblockButton.setFont(activateButton.getFont().deriveFont(activateButton.getFont().getStyle() & ~java.awt.Font.BOLD));
+ unblockButton.setText(cardmgmtMessages.getString(BUTTON_UNBLOCK));
+ unblockButton.setEnabled(false);
+ unblockButton.setActionCommand(unblockCmd);
+ unblockButton.addActionListener(unblockListener);
+
+ JButton cancelButton = new JButton();
+ cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD));
+ cancelButton.setText(messages.getString(BUTTON_CANCEL));
+ cancelButton.setActionCommand(cancelCmd);
+ cancelButton.addActionListener(cancelListener);
+
+ 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)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(changeButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(unblockButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE);
+
+ GroupLayout.Group buttonVertical = buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(activateButton)
+ .addComponent(changeButton)
+ .addComponent(unblockButton)
+ .addComponent(cancelButton);
+
+ buttonPanelLayout.setHorizontalGroup(buttonHorizontal);
+ buttonPanelLayout.setVerticalGroup(buttonVertical);
+
+ contentPanel.validate();
+
+ }
+ });
+
+// } catch (Exception ex) {
+// log.error(ex.getMessage(), ex);
+// showErrorDialog(ERR_UNKNOWN_WITH_PARAM, new Object[] {ex.getMessage()});
+// }
+ }
+
+
+}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java
new file mode 100644
index 00000000..3d653fab
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import java.awt.event.ActionListener;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public interface PINManagementGUIFacade extends BKUGUIFacade {
+
+ public static final String HELP_PINMGMT = "help.pin.mgmt";
+ public static final String TITLE_PINMGMT = "title.pin.mgmt";
+ public static final String MESSAGE_PINMGMT = "message.pin.mgmt";
+
+ public void showPINManagementDialog(PINStatusProvider pinStatusProvider, ActionListener activateListener, String activateCmd, ActionListener changeListener, String changeCmd, ActionListener unblockListener, String unblockCmd, ActionListener cancelListener, String cancelCmd);
+
+}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusProvider.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusProvider.java
new file mode 100644
index 00000000..73fa0920
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusProvider.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.smcc.SignatureCardException;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public interface PINStatusProvider {
+
+ public enum STATUS { ACTIV, NOT_ACTIV, BLOCKED };
+
+ public STATUS getPINStatus(int pin) throws SignatureCardException;
+
+}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/ext/BKUAppletExt.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/ActivationApplet.java
index d9df5536..68f0cb72 100644
--- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/ext/BKUAppletExt.java
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/ActivationApplet.java
@@ -1,53 +1,56 @@
/*
* Copyright 2008 Federal Chancellery Austria and
* Graz University of Technology
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- *
- */
-package at.gv.egiz.bku.online.applet.ext;
-
-import at.gv.egiz.stal.service.translator.STALTranslator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+package at.gv.egiz.bku.online.applet;
+import at.gv.egiz.bku.gui.AbstractHelpListener;
+import at.gv.egiz.bku.gui.ActivationGUI;
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.bku.gui.BKUGUIFacade.Style;
import at.gv.egiz.bku.online.applet.BKUApplet;
-import at.gv.egiz.bku.smccstal.AbstractBKUWorker;
+import at.gv.egiz.bku.smccstal.AbstractSMCCSTAL;
import at.gv.egiz.bku.smccstal.ext.CardMgmtRequestHandler;
import at.gv.egiz.stal.ext.APDUScriptRequest;
import at.gv.egiz.stal.service.STALPortType;
+import at.gv.egiz.stal.service.translator.STALTranslator;
import at.gv.egiz.stalx.service.STALService;
import at.gv.egiz.stalx.service.translator.STALXTranslationHandler;
+import java.awt.Container;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Locale;
import javax.xml.namespace.QName;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
- * @author mcentner
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
*/
-public class BKUAppletExt extends BKUApplet {
+public class ActivationApplet extends BKUApplet {
private static final long serialVersionUID = 1L;
- private static Log log = LogFactory.getLog(BKUAppletExt.class);
+ private static Log log = LogFactory.getLog(ActivationApplet.class);
@Override
public void init() {
super.init();
- if (worker instanceof AbstractBKUWorker) {
+ if (worker instanceof AbstractSMCCSTAL) {
CardMgmtRequestHandler handler = new CardMgmtRequestHandler();
- ((AbstractBKUWorker) worker).addRequestHandler(APDUScriptRequest.class, handler);
+ ((AbstractSMCCSTAL) worker).addRequestHandler(APDUScriptRequest.class, handler);
log.debug("Registered CardMgmtRequestHandler");
} else {
log.warn("Cannot register CardMgmtRequestHandler.");
@@ -60,7 +63,7 @@ public class BKUAppletExt extends BKUApplet {
* @throws java.net.MalformedURLException
*/
@Override
- protected STALPortType getSTALPort() throws MalformedURLException {
+ public STALPortType getSTALPort() throws MalformedURLException {
URL wsdlURL = getURLParameter(WSDL_URL, null);
log.debug("setting STAL WSDL: " + wsdlURL);
QName endpointName = new QName(STAL_WSDL_NS, STAL_SERVICE);
@@ -70,11 +73,18 @@ public class BKUAppletExt extends BKUApplet {
}
@Override
- protected STALTranslator getSTALTranslator() {
+ public STALTranslator getSTALTranslator() {
STALTranslator translator = super.getSTALTranslator();
translator.registerTranslationHandler(new STALXTranslationHandler());
return translator;
}
-
+ @Override
+ protected BKUGUIFacade createGUI(Container contentPane,
+ Locale locale,
+ Style guiStyle,
+ URL backgroundImgURL,
+ AbstractHelpListener helpListener) {
+ return new ActivationGUI(contentPane, locale, guiStyle, backgroundImgURL, helpListener);
+ }
}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementApplet.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementApplet.java
new file mode 100644
index 00000000..72d06618
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementApplet.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.online.applet;
+
+import at.gv.egiz.bku.gui.AbstractHelpListener;
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.bku.gui.PINManagementGUI;
+import java.awt.Container;
+import java.net.URL;
+import java.util.Locale;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class PINManagementApplet extends BKUApplet {
+
+ private static final long serialVersionUID = 1L;
+ private static Log log = LogFactory.getLog(PINManagementApplet.class);
+
+ @Override
+ protected BKUGUIFacade createGUI(Container contentPane,
+ Locale locale,
+ BKUGUIFacade.Style guiStyle,
+ URL backgroundImgURL,
+ AbstractHelpListener helpListener) {
+ return new PINManagementGUI(contentPane, locale, guiStyle, backgroundImgURL, helpListener);
+ }
+
+ @Override
+ protected AppletBKUWorker createBKUWorker(BKUApplet applet, BKUGUIFacade gui) {
+ return new PINManagementBKUWorker(applet, gui);
+ }
+}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementBKUWorker.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementBKUWorker.java
new file mode 100644
index 00000000..e65d98ca
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementBKUWorker.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.online.applet;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.bku.gui.PINManagementGUIFacade;
+import at.gv.egiz.bku.smccstal.ext.PINMgmtRequestHandler;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.ext.ActivatePINRequest;
+import at.gv.egiz.stal.ext.ChangePINRequest;
+import at.gv.egiz.stal.ext.UnblockPINRequest;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class PINManagementBKUWorker extends AppletBKUWorker {
+
+ protected PINMgmtRequestHandler handler = new PINMgmtRequestHandler();
+ protected PINManagementActionListener listener = new PINManagementActionListener();
+
+ public PINManagementBKUWorker(BKUApplet applet, BKUGUIFacade gui) {
+ super(applet, gui);
+ handlerMap.clear();
+// PINMgmtRequestHandler handler = new PINMgmtRequestHandler();
+// addRequestHandler(ActivatePINRequest.class, handler);
+// addRequestHandler(ChangePINRequest.class, handler);
+// addRequestHandler(UnblockPINRequest.class, handler);
+ }
+
+ @Override
+ public void run() {
+ gui.showWelcomeDialog();
+
+ try {
+
+ if (waitForCard()) {
+ gui.showErrorDialog("no card, canceled PIN mgmt dialog", null);
+ }
+
+ actionCommandList.clear();
+ actionCommandList.add("cancel");
+
+ ((PINManagementGUIFacade) gui).showPINManagementDialog(handler,
+ listener, "activate",
+ listener, "change",
+ listener, "unblock",
+ this, "cancel");
+
+ waitForAction();
+
+ } catch (Exception ex) {
+ log.error(ex.getMessage(), ex);
+ showErrorDialog(BKUGUIFacade.ERR_UNKNOWN_WITH_PARAM, ex);
+ } finally {
+ if (signatureCard != null) {
+ signatureCard.disconnect(false);
+ }
+ }
+
+ applet.sendRedirect(sessionId);
+ }
+
+ protected class PINManagementActionListener implements ActionListener {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ try {
+ String cmd = e.getActionCommand();
+ if ("activate".equals(cmd)) {
+ //create STAL request, call handle(req)
+ ActivatePINRequest stalReq = new ActivatePINRequest();
+ STALResponse stalResp = handler.handleRequest(stalReq);
+ gui.showErrorDialog(BKUGUIFacade.ERR_UNKNOWN_WITH_PARAM, new Object[]{"debug"}, this, "back");
+ } else if ("change".equals(cmd)) {
+ } else if ("unblock".equals(cmd)) {
+ } else if ("back".equals(cmd)) {
+
+ ((PINManagementGUIFacade) gui).showPINManagementDialog(handler,
+ this, "activate",
+ this, "change",
+ this, "unblock",
+ PINManagementBKUWorker.this, "cancel");
+
+ }
+ } catch (InterruptedException ex) {
+ log.fatal(ex);
+ }
+ }
+ }
+}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/CardMgmtRequestHandler.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/CardMgmtRequestHandler.java
index f499de7e..769342e7 100644
--- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/CardMgmtRequestHandler.java
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/CardMgmtRequestHandler.java
@@ -19,6 +19,7 @@
*/
package at.gv.egiz.bku.smccstal.ext;
+import at.gv.egiz.bku.gui.ActivationGUIFacade;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -45,12 +46,13 @@ import at.gv.egiz.stal.ext.APDUScriptRequest.Reset;
import at.gv.egiz.stal.ext.APDUScriptResponse.Response;
import at.gv.egiz.stal.ext.APDUScriptResponse.ATR;
import at.gv.egiz.stal.ext.APDUScriptResponse.ResponseScriptElement;
+import java.awt.event.ActionListener;
/**
* @author mcentner
*
*/
-public class CardMgmtRequestHandler extends AbstractRequestHandler {
+public class CardMgmtRequestHandler extends AbstractRequestHandler implements ActionListener {
/**
* Logging facility.
@@ -61,7 +63,12 @@ public class CardMgmtRequestHandler extends AbstractRequestHandler {
* The sequence counter.
*/
private int sequenceNum = 0;
-
+
+ /**
+ * display script num
+ */
+ private int currentActivationScript = 0;
+
@Override
public STALResponse handleRequest(STALRequest request)
throws InterruptedException {
@@ -69,7 +76,8 @@ public class CardMgmtRequestHandler extends AbstractRequestHandler {
// APDU Script Request
if (request instanceof APDUScriptRequest) {
- gui.showWaitDialog("CardChannel");
+ currentActivationScript++;
+ log.debug("handling APDU script " + currentActivationScript);
Card icc = card.getCard();
@@ -81,20 +89,28 @@ public class CardMgmtRequestHandler extends AbstractRequestHandler {
List<RequestScriptElement> script = ((APDUScriptRequest) request).getScript();
ArrayList<ResponseScriptElement> responses = new ArrayList<ResponseScriptElement>(script.size());
+ ((ActivationGUIFacade) gui).showActivationProgressDialog(currentActivationScript, script.size(), this, "cancel");
+
try {
+ log.trace("begin exclusive");
icc.beginExclusive();
for (RequestScriptElement scriptElement : script) {
+ ((ActivationGUIFacade) gui).incrementProgress();
+
if (scriptElement instanceof Command) {
+ log.trace("handling APDU script element COMMAND");
Command command = (Command) scriptElement;
CommandAPDU commandAPDU = new CommandAPDU(command.getCommandAPDU());
-
+
+ log.trace("get basicchannel");
CardChannel channel = icc.getBasicChannel();
sequenceNum = command.getSequence();
- log.debug("Transmit " + sequenceNum + " " + commandAPDU.toString());
+ log.debug("Transmit APDU (sequence=" + sequenceNum + ")");
+ log.trace(commandAPDU.toString());
ResponseAPDU responseAPDU = channel.transmit(commandAPDU);
- log.debug("" + responseAPDU);
+ log.trace(responseAPDU.toString());
byte[] sw = new byte[] {
(byte) (0xFF & responseAPDU.getSW1()),
@@ -105,16 +121,22 @@ public class CardMgmtRequestHandler extends AbstractRequestHandler {
if (command.getExpectedSW() != null &&
!Arrays.equals(sw, command.getExpectedSW())) {
// unexpected SW
- log.info("Got unexpected SW. APDU-script execution stopped.");
+ log.warn("Got unexpected SW. APDU-script execution stopped.");
break;
}
} else if (scriptElement instanceof Reset) {
-
+
+ log.trace("handling APDU script element RESET");
sequenceNum = 0;
card.reset();
- responses.add(new ATR(icc.getATR().getBytes()));
-
+ javax.smartcardio.ATR atr = icc.getATR();
+ log.trace("got ATR: " + atr.toString());
+ responses.add(new ATR(atr.getBytes()));
+
+ log.trace("regain exclusive access to card");
+ icc = card.getCard();
+ icc.beginExclusive();
}
}
@@ -125,6 +147,9 @@ public class CardMgmtRequestHandler extends AbstractRequestHandler {
} catch (SignatureCardException e) {
log.info("Failed to reset smart card.", e);
responses.add(new Response(sequenceNum, null, null, Response.RC_UNSPECIFIED));
+ } catch (RuntimeException e) {
+ log.error(e);
+ throw e;
} finally {
try {
icc.endExclusive();
@@ -133,7 +158,8 @@ public class CardMgmtRequestHandler extends AbstractRequestHandler {
}
}
- gui.showWaitDialog("wait for server...");
+ log.trace("done handling APDU script " + currentActivationScript + ", return response containing " + responses.size() + " elements");
+ ((ActivationGUIFacade) gui).showIdleDialog(this, "cancel");
return new APDUScriptResponse(responses);
} else {
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PINMgmtRequestHandler.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PINMgmtRequestHandler.java
new file mode 100644
index 00000000..b2d34ff2
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PINMgmtRequestHandler.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.smccstal.ext;
+
+import at.gv.egiz.bku.gui.PINStatusProvider;
+import at.gv.egiz.bku.smccstal.AbstractRequestHandler;
+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.ActivatePINRequest;
+import at.gv.egiz.stal.ext.ChangePINRequest;
+import at.gv.egiz.stal.ext.UnblockPINRequest;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.smartcardio.Card;
+import javax.smartcardio.CardChannel;
+import javax.smartcardio.CardException;
+import javax.smartcardio.CommandAPDU;
+import javax.smartcardio.ResponseAPDU;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class PINMgmtRequestHandler extends AbstractRequestHandler implements PINStatusProvider {
+
+ protected static final Log log = LogFactory.getLog(PINMgmtRequestHandler.class);
+
+ @Override
+ public STALResponse handleRequest(STALRequest request) throws InterruptedException {
+ if (request instanceof ActivatePINRequest) {
+ log.error("not implemented yet");
+ return new ErrorResponse(1000);
+
+ } else if (request instanceof ChangePINRequest) {
+ log.error("not implemented yet");
+ return new ErrorResponse(1000);
+
+ } else if (request instanceof UnblockPINRequest) {
+ log.error("not implemented yet");
+ return new ErrorResponse(1000);
+
+ } else {
+ log.error("Got unexpected STAL request: " + request);
+ return new ErrorResponse(1000);
+ }
+ }
+
+ @Override
+ public boolean requireCard() {
+ return true;
+ }
+
+ @Override
+ public STATUS getPINStatus(int pin) throws SignatureCardException {
+ try {
+ Card icc = card.getCard();
+ icc.beginExclusive();
+ CardChannel channel = icc.getBasicChannel();
+ CommandAPDU verifyAPDU = new CommandAPDU(new byte[] {(byte) 0x00} );
+ ResponseAPDU responseAPDU = channel.transmit(verifyAPDU);
+ byte sw1 = (byte) responseAPDU.getSW1();
+ byte[] sw = new byte[] {
+ (byte) (0xFF & responseAPDU.getSW1()),
+ (byte) (0xFF & responseAPDU.getSW2()) };
+
+ icc.endExclusive();
+ return STATUS.ACTIV;
+ } catch (CardException ex) {
+ log.error("Failed to get PIN status: " + ex.getMessage());
+ throw new SignatureCardException("Failed to get PIN status", ex);
+ }
+ }
+
+}