summaryrefslogtreecommitdiff
path: root/BKUAppletExt
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-02-11 20:01:17 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-02-11 20:01:17 +0000
commitd7fde6fc92f36a7cc8b8d412724951b12193bb9b (patch)
tree23bb695868c39f918b8a2c7aa228f783352c4249 /BKUAppletExt
parent754cb731b2d5f4888815c16c530fc3674264a4f2 (diff)
downloadmocca-d7fde6fc92f36a7cc8b8d412724951b12193bb9b.tar.gz
mocca-d7fde6fc92f36a7cc8b8d412724951b12193bb9b.tar.bz2
mocca-d7fde6fc92f36a7cc8b8d412724951b12193bb9b.zip
activation applet (NO PINMgmt yet)
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@295 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUAppletExt')
-rw-r--r--BKUAppletExt/nbactions.xml13
-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
-rw-r--r--BKUAppletExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties24
-rw-r--r--BKUAppletExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages_en.properties24
-rw-r--r--BKUAppletExt/src/test/java/at/gv/egiz/bku/gui/ActivationGuiTest.java62
-rw-r--r--BKUAppletExt/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java204
-rw-r--r--BKUAppletExt/src/test/java/at/gv/egiz/bku/smccstal/ext/FileSystemTest.java434
-rw-r--r--BKUAppletExt/src/test/resources/appletTest.html4
18 files changed, 1644 insertions, 33 deletions
diff --git a/BKUAppletExt/nbactions.xml b/BKUAppletExt/nbactions.xml
new file mode 100644
index 00000000..286e3ba6
--- /dev/null
+++ b/BKUAppletExt/nbactions.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<actions>
+ <action>
+ <actionName>CUSTOM-PackageNoTests</actionName>
+ <displayName>PackageNoTests</displayName>
+ <goals>
+ <goal>package</goal>
+ </goals>
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ </properties>
+ </action>
+ </actions>
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);
+ }
+ }
+
+}
diff --git a/BKUAppletExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties b/BKUAppletExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties
new file mode 100644
index 00000000..469af15f
--- /dev/null
+++ b/BKUAppletExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties
@@ -0,0 +1,24 @@
+# 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.
+
+title.activation=<html>Aktivierung</html>
+title.pin.mgmt=<html>PIN Verwaltung</html>
+message.pin.mgmt=<html>under construction</html>
+label.activation=<html>e-card Aktivierungsprozess</html>
+label.activation.step=<html>Schritt {0}</html>
+label.activation.idle=<html>Warte auf Server...</html>
+button.activate=Aktivieren
+button.change=\u00C4ndern
+button.unblock=Entsperren \ No newline at end of file
diff --git a/BKUAppletExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages_en.properties b/BKUAppletExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages_en.properties
new file mode 100644
index 00000000..16ac7d0b
--- /dev/null
+++ b/BKUAppletExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages_en.properties
@@ -0,0 +1,24 @@
+# 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.
+
+title.activation=<html>Aktivation</html>
+title.pin.mgmt=<html>PIN Management</html>
+message.pin.mgmt=<html>under construction</html>
+label.activation=<html>e-card activation process</html>
+label.activation.step=<html>Step {0}</html>
+label.activation.idle=<html>Wait for server...</html>
+button.activate=Activate
+button.change=Change
+button.unblock=Unblock \ No newline at end of file
diff --git a/BKUAppletExt/src/test/java/at/gv/egiz/bku/gui/ActivationGuiTest.java b/BKUAppletExt/src/test/java/at/gv/egiz/bku/gui/ActivationGuiTest.java
new file mode 100644
index 00000000..95c5c678
--- /dev/null
+++ b/BKUAppletExt/src/test/java/at/gv/egiz/bku/gui/ActivationGuiTest.java
@@ -0,0 +1,62 @@
+/*
+* 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.
+*/
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import java.awt.Container;
+import java.awt.Dimension;
+import javax.swing.JFrame;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ *
+ * @author clemens
+ */
+@Ignore
+public class ActivationGuiTest {
+
+ @Test
+ public void testBKUGUI() {
+ JFrame testFrame = new JFrame("BKUGUITest");
+ Container contentPane = testFrame.getContentPane();
+ contentPane.setPreferredSize(new Dimension(152, 145));
+// contentPane.setPreferredSize(new Dimension(300, 190));
+ ActivationGUIFacade gui = new ActivationGUI(contentPane, null, BKUGUIFacade.Style.tiny, null, null);
+ BKUGUIWorker worker = new BKUGUIWorker();
+ worker.init(gui);
+ testFrame.pack();
+ testFrame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ testFrame.setVisible(true);
+ new Thread(worker).start();
+
+ while(true) ;
+ }
+
+ @Test
+ public void dummyTest() {
+ }
+
+// public static void main(String[] args) {
+// new BKUGUITest().testBKUGUI();
+// }
+}
diff --git a/BKUAppletExt/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java b/BKUAppletExt/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java
new file mode 100644
index 00000000..669a63fc
--- /dev/null
+++ b/BKUAppletExt/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java
@@ -0,0 +1,204 @@
+/*
+ * 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.
+ */
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.smcc.PINSpec;
+import at.gv.egiz.stal.HashDataInput;
+import at.gv.egiz.stal.impl.ByteArrayHashDataInput;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author clemens
+ */
+public class BKUGUIWorker implements Runnable {
+
+ ActivationGUIFacade gui;
+
+ public void init(ActivationGUIFacade gui) {
+ this.gui = gui;
+ }
+
+ @Override
+ public void run() {
+ try {
+
+ final PINSpec signPinSpec = new PINSpec(6, 10, "[0-9]", "Signatur-PIN");
+
+
+ final ActionListener cancelListener = new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ System.out.println("CANCEL EVENT OCCURED: " + e);
+ }
+ };
+ ActionListener okListener = new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ System.out.println("OK EVENT OCCURED: " + e);
+ }
+ };
+ final ActionListener signListener = new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ System.out.println("SIGN EVENT OCCURED: " + e);
+ }
+ };
+ ActionListener hashdataListener = new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ System.out.println("HASHDATA EVENT OCCURED: " + e);
+ ActionListener returnListener = new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ gui.showSignaturePINDialog(signPinSpec, signListener, "sign", cancelListener, "cancel", null, "hashdata");
+ }
+ };
+ HashDataInput signedRef1 = new ByteArrayHashDataInput(
+ "Ich bin ein einfacher Text mit Umlauten: öäüßéç@€\n123\n456\n\tHello, world!\n\nlkjsd\nnksdjf".getBytes(),
+ "ref-id-0000000000000000000000001",
+ "text/plain",
+ "UTF-8");
+
+ HashDataInput signedRef2 = new ByteArrayHashDataInput(
+ "<xml>HashDataInput_002</xml>".getBytes(),
+ "ref-id-000000002",
+ "application/xhtml+xml",
+ "UTF-8");
+
+ HashDataInput signedRef3 = new ByteArrayHashDataInput(
+ "<xml>HashDataInput_003</xml>".getBytes(),
+ "ref-id-000000003",
+ "application/xhtml+xml",
+ "UTF-8");
+
+ HashDataInput signedRef4 = new ByteArrayHashDataInput(
+ "<xml>HashDataInput_004</xml>".getBytes(),
+ "ref-id-000000004",
+ "text/xml",
+ "UTF-8");
+
+ //
+ List<HashDataInput> signedRefs = new ArrayList();
+ signedRefs.add(signedRef1);
+ signedRefs.add(signedRef2);
+ signedRefs.add(signedRef3);
+ signedRefs.add(signedRef4);
+// signedRefs.add(signedRef4);
+// signedRefs.add(signedRef4);
+// signedRefs.add(signedRef4);
+// signedRefs.add(signedRef4);
+// signedRefs = Collections.singletonList(signedRef1);
+ gui.showHashDataInputDialog(signedRefs, returnListener, "return");
+ }
+ };
+
+
+
+// gui.showWelcomeDialog();
+//
+// Thread.sleep(2000);
+//
+// gui.showWaitDialog(null);
+//
+// Thread.sleep(1000);
+//
+// gui.showWaitDialog("test");
+//
+// Thread.sleep(1000);
+//
+//
+// gui.showInsertCardDialog(cancelListener, "cancel");
+//
+// Thread.sleep(2000);
+//
+// gui.showCardNotSupportedDialog(cancelListener, "cancel");
+//
+// Thread.sleep(2000);
+//
+// PINSpec cardPinSpec = new PINSpec(4, 4, "[0-9]", "Karten-PIN");
+//
+// gui.showCardPINDialog(cardPinSpec, okListener, "ok", cancelListener, "cancel");
+//
+// Thread.sleep(2000);
+//
+// gui.showSignaturePINDialog(signPinSpec, signListener, "sign", cancelListener, "cancel", hashdataListener, "hashdata");
+//
+// Thread.sleep(4000);
+//
+
+// gui.showErrorDialog(BKUGUIFacade.ERR_NO_PCSC, null, null, null);
+
+// gui.showSignaturePINRetryDialog(signPinSpec, 2, signListener, "sign", cancelListener, "cancel", hashdataListener, "hashdata");
+//
+// Thread.sleep(2000);
+//
+// gui.showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, new Object[] {"Testfehler"}, null, null);
+//
+// Thread.sleep(2000);
+//
+// gui.showErrorDialog("error.test", new Object[] {"Testfehler", "noch ein TestFehler"});
+//
+// Thread.sleep(2000);
+//
+// gui.showErrorDialog("error.no.hashdata", null);
+//
+// Thread.sleep(2000);
+//
+// gui.showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, new Object[] {"Testfehler"});
+//
+// Thread.sleep(2000);
+//
+// gui.showErrorDialog("error.unknown", null);
+
+ gui.showActivationProgressDialog(1, 3, null, null);
+
+ gui.incrementProgress();
+
+ Thread.sleep(1000);
+
+ gui.incrementProgress();
+
+ Thread.sleep(1000);
+
+ gui.incrementProgress();
+
+
+ Thread.sleep(1000);
+
+ gui.showIdleDialog(null, null);
+
+// gui.showTextPlainHashDataInput("hallo,\n welt!", "12345", null, "cancel", null, "save");
+// gui.showTextPlainHashDataInput("hallo,\n welt!", "12345", null, "cancel", null, "save");
+// Thread.sleep(2000);
+
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/BKUAppletExt/src/test/java/at/gv/egiz/bku/smccstal/ext/FileSystemTest.java b/BKUAppletExt/src/test/java/at/gv/egiz/bku/smccstal/ext/FileSystemTest.java
new file mode 100644
index 00000000..8d8b0385
--- /dev/null
+++ b/BKUAppletExt/src/test/java/at/gv/egiz/bku/smccstal/ext/FileSystemTest.java
@@ -0,0 +1,434 @@
+/*
+ * 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.smcc.FileNotFoundException;
+import at.gv.egiz.smcc.LockedException;
+import at.gv.egiz.smcc.NotActivatedException;
+import at.gv.egiz.smcc.PINProvider;
+import at.gv.egiz.smcc.PINSpec;
+import at.gv.egiz.smcc.SignatureCard;
+import at.gv.egiz.smcc.SignatureCardException;
+import at.gv.egiz.smcc.util.SMCCHelper;
+import at.gv.egiz.smcc.util.SmartCardIO;
+import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.Map;
+import javax.smartcardio.Card;
+import javax.smartcardio.CardChannel;
+import javax.smartcardio.CardException;
+import javax.smartcardio.CardTerminal;
+import javax.smartcardio.CommandAPDU;
+import javax.smartcardio.ResponseAPDU;
+import org.junit.Ignore;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class FileSystemTest {
+
+ /** asign premium */
+ public static final byte[] AID_DEC = new byte[] { (byte) 0xA0, (byte) 0x00,
+ (byte) 0x00, (byte) 0x01, (byte) 0x18, (byte) 0x45, (byte) 0x4E };
+
+ @Test
+// @Ignore
+ public void testCard() throws CardException, SignatureCardException, InterruptedException {
+
+ SMCCHelper smccHelper = new SMCCHelper();
+ switch (smccHelper.getResultCode()) {
+ case SMCCHelper.CARD_FOUND:
+ System.out.println("card found ");
+ }
+ SignatureCard signatureCard = smccHelper.getSignatureCard(new Locale("de"));
+ Card card = signatureCard.getCard();
+
+// SmartCardIO scIO = new SmartCardIO();
+// Map<CardTerminal, Card> terminalCardMap = scIO.getCards();
+//
+// for (CardTerminal ct : terminalCardMap.keySet()) {
+// Card card = terminalCardMap.get(ct);
+// System.out.println("found card (" + ct.getName() + "): " + Formatter.byteArrayToHexString(card.getATR().getBytes()));
+
+ System.out.println("found card " + Formatter.byteArrayToHexString(card.getATR().getBytes()));
+
+ CardChannel cardchannel;
+
+ //RESET
+ System.out.println("RESET");
+ signatureCard.reset();
+ card = signatureCard.getCard();
+// card.disconnect(true);
+// card = ct.connect("*");
+
+ System.out.println("begin exclusive");
+ card.beginExclusive();
+ System.out.println("get cardchannel");
+ cardchannel = card.getBasicChannel();
+
+ testECard(cardchannel, signatureCard, card);
+// testASignPremium(cardchannel, signatureCard, card);
+
+// }
+
+ }
+
+ public static class TestCard {
+
+ protected CardChannel channel;
+ protected int ifs_ = 254;
+
+ public TestCard(CardChannel channel) {
+ this.channel = channel;
+ }
+
+ protected byte[] readTLVFile(byte[] aid, byte[] ef, String pin, byte kid, int maxLength)
+ throws SignatureCardException, InterruptedException, CardException {
+
+
+ // SELECT FILE (AID)
+ selectFileAID(aid);
+
+ // SELECT FILE (EF)
+ ResponseAPDU resp = selectFileFID(ef);
+ if (resp.getSW() == 0x6a82) {
+ // EF not found
+ throw new FileNotFoundException("EF " + toString(ef) + " not found.");
+ } else if (resp.getSW() != 0x9000) {
+ throw new SignatureCardException("SELECT FILE with " + "FID=" + toString(ef) + " failed (" + "SW=" + Integer.toHexString(resp.getSW()) + ").");
+ }
+
+ // VERIFY
+ if (pin != null) {
+ int retries = verifyPIN(pin, kid);
+ if (retries != -1) {
+ throw new at.gv.egiz.smcc.VerificationFailedException(retries);
+ }
+ }
+
+ return readBinaryTLV(maxLength, (byte) 0x30);
+ }
+
+ protected byte[] readBinary(CardChannel channel, int offset, int len)
+ throws CardException, SignatureCardException {
+
+ //transmit(channel,apdu)
+ ResponseAPDU resp = channel.transmit(new CommandAPDU(0x00, 0xB0,
+ 0x7F & (offset >> 8), offset & 0xFF, len));
+ if (resp.getSW() == 0x9000) {
+ return resp.getData();
+ } else if (resp.getSW() == 0x6982) {
+ throw new at.gv.egiz.smcc.SecurityStatusNotSatisfiedException();
+ } else {
+ throw new SignatureCardException("Failed to read bytes (" + offset + "+" + len + "): SW=" + Integer.toHexString(resp.getSW()));
+ }
+
+ }
+
+ protected byte[] readBinaryTLV(int maxSize, byte expectedType) throws CardException,
+ SignatureCardException {
+
+// CardChannel channel = getCardChannel();
+
+ // read first chunk
+ int len = Math.min(maxSize, ifs_);
+ byte[] chunk = readBinary(channel, 0, len);
+ if (chunk.length > 0 && chunk[0] != expectedType) {
+ return null;
+ }
+ int offset = chunk.length;
+ int actualSize = maxSize;
+ if (chunk.length > 3) {
+ if ((chunk[1] & 0x80) > 0) {
+ int octets = (0x0F & chunk[1]);
+ actualSize = 2 + octets;
+ for (int i = 1; i <= octets; i++) {
+ actualSize += (0xFF & chunk[i + 1]) << ((octets - i) * 8);
+ }
+ } else {
+ actualSize = 2 + chunk[1];
+ }
+ }
+ ByteBuffer buffer = ByteBuffer.allocate(actualSize);
+ buffer.put(chunk, 0, Math.min(actualSize, chunk.length));
+ while (offset < actualSize) {
+ len = Math.min(ifs_, actualSize - offset);
+ chunk = readBinary(channel, offset, len);
+ buffer.put(chunk);
+ offset += chunk.length;
+ }
+ return buffer.array();
+
+ }
+
+ protected byte[] selectFileAID(byte[] dfName) throws CardException, SignatureCardException {
+// CardChannel channel = getCardChannel();
+ ResponseAPDU resp = channel.transmit(new CommandAPDU(0x00, 0xA4, 0x04,
+ 0x00, dfName, 256));
+ if (resp.getSW() != 0x9000) {
+ throw new SignatureCardException("Failed to select application AID=" + toString(dfName) + ": SW=" + Integer.toHexString(resp.getSW()) + ".");
+ } else {
+ return resp.getBytes();
+ }
+ }
+
+ protected ResponseAPDU selectFileFID(byte[] fid) throws CardException, SignatureCardException {
+// CardChannel channel = getCardChannel();
+ return channel.transmit(new CommandAPDU(0x00, 0xA4, 0x02,
+ 0x04, fid, 256));
+ }
+
+ protected String toString(byte[] b) {
+ StringBuffer sb = new StringBuffer();
+ if (b != null && b.length > 0) {
+ sb.append(Integer.toHexString((b[0] & 240) >> 4));
+ sb.append(Integer.toHexString(b[0] & 15));
+ }
+ for (int i = 1; i < b.length; i++) {
+ sb.append(':');
+ sb.append(Integer.toHexString((b[i] & 240) >> 4));
+ sb.append(Integer.toHexString(b[i] & 15));
+ }
+ return sb.toString();
+ }
+
+ protected int verifyPIN(String pin, byte kid) throws CardException, SignatureCardException {
+
+// CardChannel channel = getCardChannel();
+
+ ResponseAPDU resp;
+ if (pin == null) {
+ //
+ resp = channel.transmit(new CommandAPDU(0x00, 0x20, 0x00, kid));
+ } else {
+ // PIN length in bytes
+ int len = (int) Math.ceil(pin.length() / 2);
+
+ // BCD encode PIN and marshal PIN block
+ byte[] pinBytes = new BigInteger(pin, 16).toByteArray();
+ byte[] pinBlock = new byte[8];
+ if (len < pinBytes.length) {
+ System.arraycopy(pinBytes, pinBytes.length - len, pinBlock, 1, len);
+ } else {
+ System.arraycopy(pinBytes, 0, pinBlock, len - pinBytes.length + 1,
+ pinBytes.length);
+ }
+ pinBlock[0] = (byte) (0x20 + len * 2);
+ Arrays.fill(pinBlock, len + 1, 8, (byte) 0xff);
+
+ resp = channel.transmit(new CommandAPDU(0x00, 0x20, 0x00, kid, pinBlock));//, false);
+
+ }
+
+ if (resp.getSW() == 0x63c0) {
+ throw new LockedException("PIN locked.");
+ } else if (resp.getSW1() == 0x63 && resp.getSW2() >> 4 == 0xc) {
+ // return number of possible retries
+ return resp.getSW2() & 0x0f;
+ } else if (resp.getSW() == 0x6983) {
+ throw new LockedException();
+ } else if (resp.getSW() == 0x6984) {
+ // PIN LCS = "Initialized" (-> not activated)
+ throw new NotActivatedException("PIN not set.");
+ } else if (resp.getSW() == 0x9000) {
+ return -1; // success
+ } else {
+ throw new SignatureCardException("Failed to verify pin: SW=" + Integer.toHexString(resp.getSW()));
+ }
+ }
+ }
+
+ public static class Formatter {
+
+ private static String[] alphabet = {"0", "1", "2",
+ "3", "4", "5", "6", "7", "8",
+ "9", "A", "B", "C", "D", "E",
+ "F"};
+
+ public static String byteArrayToHexString(byte[] bytes) {
+
+ if (bytes == null || bytes.length <= 0) {
+ return null;
+ }
+
+ StringBuffer buf = new StringBuffer(2 * bytes.length);
+
+ byte c = 0x00;
+
+ for (int i = 0; i < bytes.length; i++) {
+
+ // high nibble
+ c = (byte) (bytes[i] & 0xf0);
+
+ // shift down
+ c = (byte) (c >>> 4);
+
+ // cut high order bits
+ c = (byte) (c & 0x0f);
+
+ buf.append(alphabet[(int) c]);
+
+ // low nibble
+ c = (byte) (bytes[i] & 0x0f);
+
+ buf.append(alphabet[(int) c]);
+ if (i < bytes.length - 1) {
+ buf.append(':');
+ }
+ }
+
+ return buf.toString();
+
+ }
+ }
+
+ protected void testASignPremium(CardChannel cardchannel, SignatureCard signatureCard, Card card) throws CardException {
+ byte[] selectMF = new byte[]{(byte) 0x00, (byte) 0xA4, (byte) 0x00, (byte) 0x0C, (byte) 0x02, (byte) 0x3F, (byte) 0x00};
+ byte[] selectDF_DEC = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x00, (byte) 0x0C, (byte) 0x02, (byte) 0xdf, (byte) 0x71 };
+ byte[] selectAID_DEC = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x04, (byte) 0x00, (byte) 0x07, (byte) 0xA0, (byte) 0x00,
+ (byte) 0x00, (byte) 0x01, (byte) 0x18, (byte) 0x45, (byte) 0x4E };
+
+ CommandAPDU cAPDU;
+ ResponseAPDU rAPDU;
+ byte[] sw;
+
+ cAPDU = new CommandAPDU(selectMF);
+ rAPDU = cardchannel.transmit(cAPDU);
+ sw = new byte[]{(byte) (0xFF & rAPDU.getSW1()), (byte) (0xFF & rAPDU.getSW2())};
+ System.out.println("cAPDU: " + Formatter.byteArrayToHexString(cAPDU.getBytes()));
+ System.out.println("rAPDU (sw=" + Formatter.byteArrayToHexString(sw) + "): " + Formatter.byteArrayToHexString(rAPDU.getData()));
+
+ cAPDU = new CommandAPDU(selectAID_DEC);
+ rAPDU = cardchannel.transmit(cAPDU);
+ sw = new byte[]{(byte) (0xFF & rAPDU.getSW1()), (byte) (0xFF & rAPDU.getSW2())};
+ System.out.println("cAPDU: " + Formatter.byteArrayToHexString(cAPDU.getBytes()));
+ System.out.println("rAPDU (sw=" + Formatter.byteArrayToHexString(sw) + "): " + Formatter.byteArrayToHexString(rAPDU.getData()));
+
+ cAPDU = new CommandAPDU(selectDF_DEC);
+ rAPDU = cardchannel.transmit(cAPDU);
+ sw = new byte[]{(byte) (0xFF & rAPDU.getSW1()), (byte) (0xFF & rAPDU.getSW2())};
+ System.out.println("cAPDU: " + Formatter.byteArrayToHexString(cAPDU.getBytes()));
+ System.out.println("rAPDU (sw=" + Formatter.byteArrayToHexString(sw) + "): " + Formatter.byteArrayToHexString(rAPDU.getData()));
+
+
+ }
+
+ protected void testECard(CardChannel cardchannel, SignatureCard signatureCard, Card card) throws CardException, InterruptedException, SignatureCardException {
+// if (cardTerminal != null) {
+// card_ = cardTerminal.connect("*");
+// }
+ byte[] selectMF = new byte[]{(byte) 0x00, (byte) 0xA4, (byte) 0x00, (byte) 0x0C, (byte) 0x02, (byte) 0x3F, (byte) 0x00};
+ byte[] readEF_GDO = new byte[]{(byte) 0x00, (byte) 0xB0, (byte) 0x82, (byte) 0x00, (byte) 0x00};
+ CommandAPDU cAPDU;
+ ResponseAPDU rAPDU;
+ byte[] sw;
+ cAPDU = new CommandAPDU(selectMF);
+ rAPDU = cardchannel.transmit(cAPDU);
+ sw = new byte[]{(byte) (0xFF & rAPDU.getSW1()), (byte) (0xFF & rAPDU.getSW2())};
+ System.out.println("cAPDU: " + Formatter.byteArrayToHexString(cAPDU.getBytes()));
+ System.out.println("rAPDU (sw=" + Formatter.byteArrayToHexString(sw) + "): " + Formatter.byteArrayToHexString(rAPDU.getData()));
+ cAPDU = new CommandAPDU(readEF_GDO);
+ rAPDU = cardchannel.transmit(cAPDU);
+ sw = new byte[]{(byte) (0xFF & rAPDU.getSW1()), (byte) (0xFF & rAPDU.getSW2())};
+ System.out.println("cAPDU: " + Formatter.byteArrayToHexString(cAPDU.getBytes()));
+ System.out.println("rAPDU (sw=" + Formatter.byteArrayToHexString(sw) + "): " + Formatter.byteArrayToHexString(rAPDU.getData()));
+ byte[] EF_GDO = rAPDU.getData();
+ //RESET
+ System.out.println("RESET");
+ signatureCard.reset();
+ card = signatureCard.getCard();
+// card.disconnect(true);
+// card = ct.connect("*");
+ System.out.println("begin exclusive");
+ card.beginExclusive();
+ System.out.println("get cardchannel");
+ cardchannel = card.getBasicChannel();
+ byte[] getCLC = new byte[]{(byte) 0x00, (byte) 0xCA, (byte) 0xDF, (byte) 0x20, (byte) 0x00};
+ byte[] verifyKartenPIN = new byte[]{(byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x01};
+ byte[] selectDF_SichereSignatur = new byte[]{(byte) 0x00, (byte) 0xA4, (byte) 0x04, (byte) 0x00, (byte) 0x08, (byte) 0xD0, (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x17, (byte) 0x00, (byte) 0x12, (byte) 0x01, (byte) 0x00};
+ byte[] verifySignaturPIN = new byte[]{(byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x81};
+ cAPDU = new CommandAPDU(getCLC);
+ rAPDU = cardchannel.transmit(cAPDU);
+ sw = new byte[]{(byte) (0xFF & rAPDU.getSW1()), (byte) (0xFF & rAPDU.getSW2())};
+ System.out.println("cAPDU: " + Formatter.byteArrayToHexString(cAPDU.getBytes()));
+ System.out.println("rAPDU (sw=" + Formatter.byteArrayToHexString(sw) + "): " + Formatter.byteArrayToHexString(rAPDU.getData()));
+ byte[] clc = rAPDU.getData();
+ cAPDU = new CommandAPDU(verifyKartenPIN);
+ rAPDU = cardchannel.transmit(cAPDU);
+ sw = new byte[]{(byte) (0xFF & rAPDU.getSW1()), (byte) (0xFF & rAPDU.getSW2())};
+ System.out.println("cAPDU: " + Formatter.byteArrayToHexString(cAPDU.getBytes()));
+ System.out.println("rAPDU (sw=" + Formatter.byteArrayToHexString(sw) + "): " + Formatter.byteArrayToHexString(rAPDU.getData()));
+ cAPDU = new CommandAPDU(selectDF_SichereSignatur);
+ rAPDU = cardchannel.transmit(cAPDU);
+ sw = new byte[]{(byte) (0xFF & rAPDU.getSW1()), (byte) (0xFF & rAPDU.getSW2())};
+ System.out.println("cAPDU: " + Formatter.byteArrayToHexString(cAPDU.getBytes()));
+ System.out.println("rAPDU (sw=" + Formatter.byteArrayToHexString(sw) + "): " + Formatter.byteArrayToHexString(rAPDU.getData()));
+ cAPDU = new CommandAPDU(verifySignaturPIN);
+ rAPDU = cardchannel.transmit(cAPDU);
+ sw = new byte[]{(byte) (0xFF & rAPDU.getSW1()), (byte) (0xFF & rAPDU.getSW2())};
+ System.out.println("cAPDU: " + Formatter.byteArrayToHexString(cAPDU.getBytes()));
+ System.out.println("rAPDU (sw=" + Formatter.byteArrayToHexString(sw) + "): " + Formatter.byteArrayToHexString(rAPDU.getData()));
+ //RESET
+ System.out.println("RESET");
+ signatureCard.reset();
+ card = signatureCard.getCard();
+ System.out.println("InfoboxReadRequests...");
+ PINProvider pinProvider = new PINProvider() {
+
+ @Override
+ public String providePIN(PINSpec spec, int retries) throws InterruptedException {
+ if (retries >= 3) {
+ return "2540";
+ } else {
+ throw new InterruptedException("TOO FEW PIN RETRIES LEFT, ABORTING");
+ }
+ }
+ };
+ byte[] ehic = signatureCard.getInfobox("EHIC", pinProvider, null);
+ System.out.println("EHIC: " + Formatter.byteArrayToHexString(ehic));
+ byte[] grunddaten = signatureCard.getInfobox("Grunddaten", pinProvider, null);
+ System.out.println("Grunddaten: " + Formatter.byteArrayToHexString(grunddaten));
+ //RESET
+ System.out.println("RESET");
+ signatureCard.reset();
+ card = signatureCard.getCard();
+// card.disconnect(true);
+// card = ct.connect("*");
+ System.out.println("begin exclusive");
+ card.beginExclusive();
+ System.out.println("get cardchannel");
+ cardchannel = card.getBasicChannel();
+ cAPDU = new CommandAPDU(getCLC);
+ rAPDU = cardchannel.transmit(cAPDU);
+ sw = new byte[]{(byte) (0xFF & rAPDU.getSW1()), (byte) (0xFF & rAPDU.getSW2())};
+ System.out.println("cAPDU: " + Formatter.byteArrayToHexString(cAPDU.getBytes()));
+ System.out.println("rAPDU (sw=" + Formatter.byteArrayToHexString(sw) + "): " + Formatter.byteArrayToHexString(rAPDU.getData()));
+ assertTrue(Arrays.equals(clc, rAPDU.getData()));
+ cAPDU = new CommandAPDU(readEF_GDO);
+ rAPDU = cardchannel.transmit(cAPDU);
+ sw = new byte[]{(byte) (0xFF & rAPDU.getSW1()), (byte) (0xFF & rAPDU.getSW2())};
+ System.out.println("cAPDU: " + Formatter.byteArrayToHexString(cAPDU.getBytes()));
+ System.out.println("rAPDU (sw=" + Formatter.byteArrayToHexString(sw) + "): " + Formatter.byteArrayToHexString(rAPDU.getData()));
+ assertTrue(Arrays.equals(EF_GDO, rAPDU.getData()));
+// }
+ }
+}
diff --git a/BKUAppletExt/src/test/resources/appletTest.html b/BKUAppletExt/src/test/resources/appletTest.html
index f7a47d0a..9add4309 100644
--- a/BKUAppletExt/src/test/resources/appletTest.html
+++ b/BKUAppletExt/src/test/resources/appletTest.html
@@ -17,10 +17,10 @@
<html>
<body>
<center>
- <applet code="at.gv.egiz.bku.online.applet.ext.BKUAppletExt.class"
+ <applet code="at.gv.egiz.bku.online.applet.PINManagementApplet.class"
archive="../BKUAppletExt-1.0.2-SNAPSHOT.jar, commons-logging.jar , iaik_jce_me4se.jar"
width=152 height=145>
- <param name="GuiStyle" value="activation"/>
+ <param name="GuiStyle" value="simple"/>
<param name="Locale" value="ja_JA"/>
<!--param name="Background" value="jar:file:/home/clemens/workspace/mocca/BKUApplet/target/BKUApplet-1.0-SNAPSHOT.jar!/images/help.png"/-->
<!--param name="Background" value="http://localhost:3495/img/BackgroundChipperling.png"/-->