summaryrefslogtreecommitdiff
path: root/BKUAppletExt/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-03-18 22:27:28 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-03-18 22:27:28 +0000
commit2a1df5e58e44f8d77f34eb80df74e8c0d27caceb (patch)
tree5603a81674a1fe60373ba0a3ca37b03473eeb92a /BKUAppletExt/src/main/java/at/gv/egiz
parent2f49ed7ea3649a51a9457b99004c8cb0ca443432 (diff)
downloadmocca-2a1df5e58e44f8d77f34eb80df74e8c0d27caceb.tar.gz
mocca-2a1df5e58e44f8d77f34eb80df74e8c0d27caceb.tar.bz2
mocca-2a1df5e58e44f8d77f34eb80df74e8c0d27caceb.zip
1.1-rc5 (pinProviderFactories, gui refactoring, signatureCard, secureViewer)
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@322 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUAppletExt/src/main/java/at/gv/egiz')
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java365
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java46
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/online/applet/PINManagementBKUWorker.java10
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/ManagementPINProviderFactory.java53
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PINManagementRequestHandler.java319
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PinpadPINProviderFactory.java126
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/SoftwarePINProviderFactory.java148
7 files changed, 725 insertions, 342 deletions
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
index c904be0c..159dd29d 100644
--- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java
@@ -56,8 +56,6 @@ public class PINManagementGUI extends CardMgmtGUI implements PINManagementGUIFac
/** remember the pinSpec to return to worker */
protected PINSpec pinSpec;
- protected enum DIALOG { VERIFY, ACTIVATE, CHANGE, UNBLOCK };
-
public PINManagementGUI(Container contentPane,
Locale locale,
Style guiStyle,
@@ -235,43 +233,110 @@ public class PINManagementGUI extends CardMgmtGUI implements PINManagementGUIFac
}
@Override
- public void showActivatePINDialog(final PINSpec pin,
- final ActionListener okListener, final String okCommand,
- final ActionListener cancelListener, final String cancelCommand) {
- log.debug("scheduling activate pin dialog");
- showPINDialog(DIALOG.ACTIVATE, pin, okListener, okCommand, cancelListener, cancelCommand);
+ public void showPINDialog(DIALOG type, PINSpec pinSpec,
+ ActionListener okListener, String okCommand,
+ ActionListener cancelListener, String cancelCommand) {
+ showPINDialog(type, pinSpec, -1, false,
+ okListener, okCommand, cancelListener, cancelCommand);
+ }
+
+ @Override
+ public void showPINDialog(DIALOG type, PINSpec pinSpec, int retries,
+ ActionListener okListener, String okCommand,
+ ActionListener cancelListener, String cancelCommand) {
+ showPINDialog(type, pinSpec, retries, false,
+ okListener, okCommand, cancelListener, cancelCommand);
}
+ @Override
+ public void showPinpadPINDialog(DIALOG type, PINSpec pinSpec, int retries) {
+ String title, msg;
+ Object[] params;
+ if (retries < 0) {
+ params = new Object[2];
+ if (shortText) {
+ params[0] = "PIN";
+ } else {
+ params[0] = pinSpec.getLocalizedName();
+ }
+ String pinSize = String.valueOf(pinSpec.getMinLength());
+ if (pinSpec.getMinLength() != pinSpec.getMaxLength()) {
+ pinSize += "-" + pinSpec.getMaxLength();
+ }
+ params[1] = pinSize;
+ if (type == DIALOG.CHANGE) {
+ log.debug("show change pin dialog");
+ title = TITLE_CHANGE_PIN;
+ msg = MESSAGE_CHANGEPIN_PINPAD;
+ } else if (type == DIALOG.ACTIVATE) {
+ log.debug("show activate pin dialog");
+ title = TITLE_ACTIVATE_PIN;
+ msg = MESSAGE_ENTERPIN_PINPAD;
+ } else if (type == DIALOG.VERIFY) {
+ log.debug("show verify pin dialog");
+ title = TITLE_VERIFY_PIN;
+ msg = MESSAGE_ENTERPIN_PINPAD;
+ } else {
+ log.debug("show unblock pin dialog");
+ title = TITLE_UNBLOCK_PIN;
+ msg = MESSAGE_ENTERPIN_PINPAD;
+ }
+
+ } else {
+ log.debug("show retry pin dialog");
+ title = TITLE_RETRY;
+ msg = (retries < 2) ?
+ MESSAGE_LAST_RETRY : MESSAGE_RETRIES;
+ params = new Object[] {String.valueOf(retries)};
+ }
+ showMessageDialog(title, msg, params);
+ }
private void showPINDialog(final DIALOG type, final PINSpec pinSpec,
+ final int retries, final boolean pinpad,
final ActionListener okListener, final String okCommand,
final ActionListener cancelListener, final String cancelCommand) {
+ log.debug("scheduling pin dialog");
+
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
- String HELP_TOPIC, TITLE, MESSAGE_MGMT;
+ String HELP_TOPIC, TITLE, MESSAGE_MGMT, MESSAGE_MGMT_PARAM;
HELP_TOPIC = HELP_PINMGMT;
- if (type == DIALOG.CHANGE) {
- log.debug("show change pin dialog");
- TITLE = TITLE_CHANGE_PIN;
- MESSAGE_MGMT = MESSAGE_CHANGE_PIN;
- } else if (type == DIALOG.ACTIVATE) {
- log.debug("show activate pin dialog");
- TITLE = TITLE_ACTIVATE_PIN;
- MESSAGE_MGMT = MESSAGE_ACTIVATE_PIN;
- oldPinField = null;
- } else if (type == DIALOG.VERIFY) {
- log.debug("show verify pin dialog");
- TITLE = TITLE_VERIFY_PIN;
- MESSAGE_MGMT = MESSAGE_VERIFY_PIN;
+ if (retries < 0) {
+ if (type == DIALOG.CHANGE) {
+ log.debug("show change pin dialog");
+ TITLE = TITLE_CHANGE_PIN;
+ MESSAGE_MGMT = MESSAGE_CHANGE_PIN;
+ } else if (type == DIALOG.ACTIVATE) {
+ log.debug("show activate pin dialog");
+ TITLE = TITLE_ACTIVATE_PIN;
+ MESSAGE_MGMT = MESSAGE_ACTIVATE_PIN;
+ oldPinField = null;
+ } else if (type == DIALOG.VERIFY) {
+ log.debug("show verify pin dialog");
+ TITLE = TITLE_VERIFY_PIN;
+ MESSAGE_MGMT = MESSAGE_VERIFY_PIN;
+ } else {
+ log.debug("show unblock pin dialog");
+ TITLE = TITLE_UNBLOCK_PIN;
+ MESSAGE_MGMT = MESSAGE_UNBLOCK_PIN;
+ }
+ if (shortText) {
+ MESSAGE_MGMT_PARAM = "PIN";
+ } else {
+ MESSAGE_MGMT_PARAM = pinSpec.getLocalizedName();
+ }
} else {
- log.debug("show unblock pin dialog");
- TITLE = TITLE_UNBLOCK_PIN;
- MESSAGE_MGMT = MESSAGE_UNBLOCK_PIN;
+ log.debug("show retry pin dialog");
+ TITLE = TITLE_RETRY;
+ MESSAGE_MGMT = (retries < 2) ?
+ MESSAGE_LAST_RETRY : MESSAGE_RETRIES;
+ MESSAGE_MGMT_PARAM = String.valueOf(retries);
}
mainPanel.removeAll();
@@ -280,24 +345,67 @@ public class PINManagementGUI extends CardMgmtGUI implements PINManagementGUIFac
helpListener.setHelpTopic(HELP_TOPIC);
JLabel mgmtLabel = new JLabel();
- mgmtLabel.setFont(mgmtLabel.getFont().deriveFont(mgmtLabel.getFont().getStyle() & ~Font.BOLD));
+ if (retries < 0) {
+ mgmtLabel.setFont(mgmtLabel.getFont().deriveFont(mgmtLabel.getFont().getStyle() & ~Font.BOLD));
+ } else {
+ mgmtLabel.setFont(mgmtLabel.getFont().deriveFont(mgmtLabel.getFont().getStyle() | Font.BOLD));
+ mgmtLabel.setForeground(ERROR_COLOR);
+ helpListener.setHelpTopic(HELP_RETRY);
+ }
if (renderHeaderPanel) {
titleLabel.setText(getMessage(TITLE));
String mgmtPattern = getMessage(MESSAGE_MGMT);
- if (shortText) {
- mgmtLabel.setText(MessageFormat.format(mgmtPattern, "PIN"));
- } else {
- mgmtLabel.setText(MessageFormat.format(mgmtPattern, pinSpec.getLocalizedName()));
- }
+ mgmtLabel.setText(MessageFormat.format(mgmtPattern, MESSAGE_MGMT_PARAM));
} else {
mgmtLabel.setText(getMessage(TITLE));
}
+ String pinSize = String.valueOf(pinSpec.getMinLength());
+ if (pinSpec.getMinLength() != pinSpec.getMaxLength()) {
+ pinSize += "-" + pinSpec.getMaxLength();
+ }
+
+ ////////////////////////////////////////////////////////////////
+ // COMMON LAYOUT SECTION
+ ////////////////////////////////////////////////////////////////
+
+ GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
+ mainPanel.setLayout(mainPanelLayout);
+
+ GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup()
+ .addComponent(mgmtLabel);
+ GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(mgmtLabel);
+
+ if (!renderHeaderPanel) {
+ infoHorizontal
+ .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE)
+ .addComponent(helpLabel);
+ infoVertical
+ .addComponent(helpLabel);
+ }
+
+ GroupLayout.ParallelGroup pinHorizontal;
+ GroupLayout.SequentialGroup pinVertical;
+
+ if (pinpad) {
+ JLabel pinpadLabel = new JLabel();
+ pinpadLabel.setFont(mgmtLabel.getFont().deriveFont(mgmtLabel.getFont().getStyle() & ~Font.BOLD));
+ String pinpadPattern = getMessage(MESSAGE_PINPAD);
+ pinpadLabel.setText(MessageFormat.format(pinpadPattern,
+ new Object[] { pinSpec.getLocalizedName(), pinSize }));
+
+ pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(pinpadLabel);
+ pinVertical = mainPanelLayout.createSequentialGroup()
+ .addComponent(pinpadLabel);
+ } else {
+
JButton okButton = new JButton();
okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~Font.BOLD));
okButton.setText(getMessage(BUTTON_OK));
- okButton.setEnabled(type == DIALOG.VERIFY && pinSpec.getMinLength() == 0);
+ okButton.setEnabled(pinSpec.getMinLength() <= 0);
okButton.setActionCommand(okCommand);
okButton.addActionListener(okListener);
@@ -334,7 +442,7 @@ public class PINManagementGUI extends CardMgmtGUI implements PINManagementGUIFac
repeatPinLabel.setText(MessageFormat.format(repeatPinLabelPattern, new Object[]{pinSpec.getLocalizedName()}));
repeatPinField.setText("");
- repeatPinField.setDocument(new PINDocument(pinSpec, okButton, pinField.getDocument()));
+// repeatPinField.setDocument(new PINDocument(pinSpec, okButton, pinField.getDocument()));
repeatPinField.setActionCommand(okCommand);
repeatPinField.addActionListener(new ActionListener() {
@@ -365,7 +473,15 @@ public class PINManagementGUI extends CardMgmtGUI implements PINManagementGUIFac
}
}
});
- } // else -> ACTIVATE (not verify, not change)
+
+ repeatPinField.setDocument(new PINDocument(
+ pinSpec, okButton,
+ pinField.getDocument(), oldPinField.getDocument()));
+ } else {
+ // else -> ACTIVATE (not verify, not change)
+ repeatPinField.setDocument(new PINDocument(
+ pinSpec, okButton, pinField.getDocument()));
+ }
} else {
pinField.setDocument(new PINDocument(pinSpec, okButton));
}
@@ -373,30 +489,14 @@ public class PINManagementGUI extends CardMgmtGUI implements PINManagementGUIFac
JLabel pinsizeLabel = new JLabel();
pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~Font.BOLD, pinsizeLabel.getFont().getSize()-2));
String pinsizePattern = getMessage(LABEL_PINSIZE);
- String pinSize = String.valueOf(pinSpec.getMinLength());
- if (pinSpec.getMinLength() != pinSpec.getMaxLength()) {
- pinSize += "-" + pinSpec.getMaxLength();
- }
pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSize}));
- GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
- mainPanel.setLayout(mainPanelLayout);
-
- GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup()
- .addComponent(mgmtLabel);
- GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addComponent(mgmtLabel);
-
- if (!renderHeaderPanel) {
- infoHorizontal
- .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE)
- .addComponent(helpLabel);
- infoVertical
- .addComponent(helpLabel);
- }
+ ////////////////////////////////////////////////////////////////
+ // NON-PINPAD SPECIFIC LAYOUT SECTION
+ ////////////////////////////////////////////////////////////////
- GroupLayout.ParallelGroup pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING);
- GroupLayout.SequentialGroup pinVertical = mainPanelLayout.createSequentialGroup();
+ pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING);
+ pinVertical = mainPanelLayout.createSequentialGroup();
// if (pinLabelPos == PinLabelPosition.ABOVE) {
// if (changePin) {
@@ -495,7 +595,38 @@ public class PINManagementGUI extends CardMgmtGUI implements PINManagementGUIFac
.addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE));
pinVertical
.addComponent(pinsizeLabel);
-// }
+
+ GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
+ buttonPanel.setLayout(buttonPanelLayout);
+
+ GroupLayout.SequentialGroup buttonHorizontal = buttonPanelLayout.createSequentialGroup()
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(okButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE);
+ GroupLayout.Group buttonVertical;
+
+ JButton cancelButton = new JButton();
+ cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD));
+ cancelButton.setText(getMessage(BUTTON_CANCEL));
+ cancelButton.setActionCommand(cancelCommand);
+ cancelButton.addActionListener(cancelListener);
+
+ buttonHorizontal
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE);
+ buttonVertical = buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(okButton)
+ .addComponent(cancelButton);
+
+ buttonPanelLayout.setHorizontalGroup(buttonHorizontal);
+ buttonPanelLayout.setVerticalGroup(buttonVertical);
+
+ if (oldPinField != null) {
+ oldPinField.requestFocusInWindow();
+ } else {
+ pinField.requestFocusInWindow();
+ }
+
+ } // END NON-PINPAD SECTION
mainPanelLayout.setHorizontalGroup(
mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
@@ -508,35 +639,6 @@ public class PINManagementGUI extends CardMgmtGUI implements PINManagementGUIFac
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pinVertical));
- GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
- buttonPanel.setLayout(buttonPanelLayout);
-
- GroupLayout.SequentialGroup buttonHorizontal = buttonPanelLayout.createSequentialGroup()
- .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(okButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE);
- GroupLayout.Group buttonVertical;
-
- JButton cancelButton = new JButton();
- cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD));
- cancelButton.setText(getMessage(BUTTON_CANCEL));
- cancelButton.setActionCommand(cancelCommand);
- cancelButton.addActionListener(cancelListener);
-
- buttonHorizontal
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE);
- buttonVertical = buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(okButton)
- .addComponent(cancelButton);
-
- buttonPanelLayout.setHorizontalGroup(buttonHorizontal);
- buttonPanelLayout.setVerticalGroup(buttonVertical);
-
- if (oldPinField != null) {
- oldPinField.requestFocusInWindow();
- } else {
- pinField.requestFocusInWindow();
- }
contentPanel.validate();
}
@@ -544,97 +646,6 @@ public class PINManagementGUI extends CardMgmtGUI implements PINManagementGUIFac
}
@Override
- public void showChangePINDialog(final PINSpec pin,
- final ActionListener okListener, final String okCommand,
- final ActionListener cancelListener, final String cancelCommand) {
-
- log.debug("scheduling change pin dialog");
- showPINDialog(DIALOG.CHANGE, pin, okListener, okCommand, cancelListener, cancelCommand);
- }
-
- @Override
- public void showUnblockPINDialog(final PINSpec pin,
- final ActionListener okListener, final String okCommand,
- final ActionListener cancelListener, final String cancelCommand) {
-
- log.debug("scheduling unblock PIN dialog");
-
- SwingUtilities.invokeLater(new Runnable() {
-
- @Override
- public void run() {
-
- log.debug("show unblock PIN dialog");
-
- log.error("unblock pin not supported");
-
- mainPanel.removeAll();
- buttonPanel.removeAll();
-
- if (renderHeaderPanel) {
- titleLabel.setText(getMessage(TITLE_ERROR));
- }
-
- helpListener.setHelpTopic(HELP_PINMGMT);
-
- String errorMsgPattern = getMessage(ERR_UNBLOCK);
- String errorMsg = MessageFormat.format(errorMsgPattern, pin.getLocalizedName());
-
- JLabel errorMsgLabel = new JLabel();
- errorMsgLabel.setFont(errorMsgLabel.getFont().deriveFont(errorMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
- errorMsgLabel.setText(errorMsg);
-
- GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
- mainPanel.setLayout(mainPanelLayout);
-
- GroupLayout.ParallelGroup mainHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING);
- GroupLayout.SequentialGroup mainVertical = mainPanelLayout.createSequentialGroup();
-
- if (!renderHeaderPanel) {
- JLabel errorTitleLabel = new JLabel();
- errorTitleLabel.setFont(errorTitleLabel.getFont().deriveFont(errorTitleLabel.getFont().getStyle() | java.awt.Font.BOLD));
- errorTitleLabel.setText(getMessage(TITLE_ERROR));
- errorTitleLabel.setForeground(ERROR_COLOR);
-
- mainHorizontal
- .addGroup(mainPanelLayout.createSequentialGroup()
- .addComponent(errorTitleLabel)
- .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE)
- .addComponent(helpLabel));
- mainVertical
- .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addComponent(errorTitleLabel)
- .addComponent(helpLabel));
- }
-
- mainPanelLayout.setHorizontalGroup(mainHorizontal
- .addComponent(errorMsgLabel));
- mainPanelLayout.setVerticalGroup(mainVertical
- .addComponent(errorMsgLabel));
-
- JButton okButton = new JButton();
- okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD));
- okButton.setText(getMessage(BUTTON_OK));
- okButton.setActionCommand(cancelCommand);
- okButton.addActionListener(cancelListener);
-
- GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
- buttonPanel.setLayout(buttonPanelLayout);
-
- buttonPanelLayout.setHorizontalGroup(
- buttonPanelLayout.createSequentialGroup()
- .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(okButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE));
- buttonPanelLayout.setVerticalGroup(
- buttonPanelLayout.createSequentialGroup()
- .addComponent(okButton));
-
- contentPanel.validate();
- }
- });
- }
-
- @Override
protected int initButtonSize() {
int bs = super.initButtonSize();
@@ -659,8 +670,4 @@ public class PINManagementGUI extends CardMgmtGUI implements PINManagementGUIFac
return bs;
}
- @Override
- public void showVerifyPINDialog(PINSpec pin, ActionListener okListener, String okCmd, ActionListener cancelListener, String cancelCmd) {
- showPINDialog(DIALOG.VERIFY, pin, okListener, okCmd, cancelListener, cancelCmd);
- }
}
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
index 9c630431..45313f42 100644
--- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java
@@ -35,13 +35,18 @@ public interface PINManagementGUIFacade extends BKUGUIFacade {
public static final String TITLE_UNBLOCK_PIN = "title.unblock.pin";
public static final String TITLE_ACTIVATE_SUCCESS = "title.activate.success";
public static final String TITLE_CHANGE_SUCCESS = "title.change.success";
- public static final String MESSAGE_ACTIVATE_SUCCESS = "message.activate.success";
- public static final String MESSAGE_CHANGE_SUCCESS = "message.change.success";
- public static final String MESSAGE_PINMGMT = "message.pin.mgmt";
- public static final String MESSAGE_ACTIVATE_PIN = "message.activate.pin";
- public static final String MESSAGE_CHANGE_PIN = "message.change.pin";
- public static final String MESSAGE_VERIFY_PIN = "message.verify.pin";
- public static final String MESSAGE_UNBLOCK_PIN = "message.unblock.pin";
+
+ // removed message.* prefix to reuse keys as help keys
+ public static final String MESSAGE_ACTIVATE_SUCCESS = "activate.success";
+ public static final String MESSAGE_CHANGE_SUCCESS = "change.success";
+ public static final String MESSAGE_PINMGMT = "pin.mgmt";
+ public static final String MESSAGE_PINPAD = "pinpad";
+ public static final String MESSAGE_CHANGEPIN_PINPAD = "pinpad.change";
+ public static final String MESSAGE_ACTIVATE_PIN = "activate.pin";
+ public static final String MESSAGE_CHANGE_PIN = "change.pin";
+ public static final String MESSAGE_VERIFY_PIN = "verify.pin";
+ public static final String MESSAGE_UNBLOCK_PIN = "unblock.pin";
+
public static final String LABEL_OLD_PIN = "label.old.pin";
public static final String LABEL_NEW_PIN = "label.new.pin";
public static final String LABEL_REPEAT_PIN = "label.repeat.pin";
@@ -66,26 +71,37 @@ public interface PINManagementGUIFacade extends BKUGUIFacade {
public static final String STATUS_UNKNOWN = "status.unknown";
public enum STATUS { ACTIV, NOT_ACTIV, BLOCKED, UNKNOWN };
+ public enum DIALOG { VERIFY, ACTIVATE, CHANGE, UNBLOCK };
public void showPINManagementDialog(Map<PINSpec, STATUS> pins,
ActionListener activateListener, String activateCmd, String changeCmd, String unblockCmd, String verifyCmd,
ActionListener cancelListener, String cancelCmd);
- public void showActivatePINDialog(PINSpec pin,
+ public void showPINDialog(DIALOG type, PINSpec pin,
ActionListener okListener, String okCmd,
ActionListener cancelListener, String cancelCmd);
- public void showChangePINDialog(PINSpec pin,
+ public void showPINDialog(DIALOG type, PINSpec pin, int retries,
ActionListener okListener, String okCmd,
ActionListener cancelListener, String cancelCmd);
- public void showUnblockPINDialog(PINSpec pin,
- ActionListener okListener, String okCmd,
- ActionListener cancelListener, String cancelCmd);
+ public void showPinpadPINDialog(DIALOG type, PINSpec pin, int retries);
- public void showVerifyPINDialog(PINSpec pin,
- ActionListener okListener, String okCmd,
- ActionListener cancelListener, String cancelCmd);
+// public void showActivatePINDialog(PINSpec pin,
+// ActionListener okListener, String okCmd,
+// ActionListener cancelListener, String cancelCmd);
+//
+// public void showChangePINDialog(PINSpec pin,
+// ActionListener okListener, String okCmd,
+// ActionListener cancelListener, String cancelCmd);
+//
+// public void showUnblockPINDialog(PINSpec pin,
+// ActionListener okListener, String okCmd,
+// ActionListener cancelListener, String cancelCmd);
+//
+// public void showVerifyPINDialog(PINSpec pin,
+// ActionListener okListener, String okCmd,
+// ActionListener cancelListener, String cancelCmd);
public char[] getOldPin();
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
index 85892026..81b635f8 100644
--- 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
@@ -42,7 +42,8 @@ public class PINManagementBKUWorker extends AppletBKUWorker {
@Override
public void run() {
- gui.showWelcomeDialog();
+ gui.showMessageDialog(BKUGUIFacade.TITLE_WELCOME,
+ BKUGUIFacade.MESSAGE_WELCOME);
try {
List<STALResponse> responses = handleRequest(Collections.singletonList(new PINManagementRequest()));
@@ -53,7 +54,6 @@ public class PINManagementBKUWorker extends AppletBKUWorker {
log.debug("PIN management dialog terminated");
} else if (response instanceof ErrorResponse) {
log.debug("PIN management dialog terminated with error");
- showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, null);
} else {
throw new RuntimeException("Invalid STAL response: " + response.getClass().getName());
}
@@ -62,7 +62,11 @@ public class PINManagementBKUWorker extends AppletBKUWorker {
}
} catch (RuntimeException ex) {
- log.error("unexpected error: " + ex.getMessage(), ex);
+ log.error(ex.getMessage());
+ Throwable cause = ex.getCause();
+ if (cause != null) { // && cause instanceof InterruptedException) {
+ log.info(cause.getMessage());
+ }
showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, null);
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/ManagementPINProviderFactory.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/ManagementPINProviderFactory.java
new file mode 100644
index 00000000..b0dd8766
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/ManagementPINProviderFactory.java
@@ -0,0 +1,53 @@
+/*
+ * 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.ChangePINProvider;
+import at.gv.egiz.bku.gui.PINManagementGUIFacade;
+import at.gv.egiz.smcc.PINProvider;
+import at.gv.egiz.smcc.SignatureCard;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public abstract class ManagementPINProviderFactory {
+// extends at.gv.egiz.bku.smccstal.PINProviderFactory {
+
+ PINManagementGUIFacade gui;
+
+ public static ManagementPINProviderFactory getInstance(SignatureCard forCard,
+ PINManagementGUIFacade gui) {
+// if (forCard.ifdSupportsFeature(SignatureCard.FEATURE_VERIFY_PIN_DIRECT)) {
+//// forCard.ifdSupportsFeature(SignatureCard.FEATURE_MODIFY_PIN_DIRECT)
+// return new PinpadPINProviderFactory(gui);
+//
+// } else {
+ return new SoftwarePINProviderFactory(gui);
+// }
+ }
+
+ public abstract PINProvider getVerifyPINProvider();
+
+ public abstract PINProvider getActivatePINProvider();
+
+ public abstract ChangePINProvider getChangePINProvider();
+
+ public abstract PINProvider getUnblockPINProvider();
+
+}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PINManagementRequestHandler.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PINManagementRequestHandler.java
index 66db0484..6b565b26 100644
--- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PINManagementRequestHandler.java
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PINManagementRequestHandler.java
@@ -18,13 +18,19 @@ package at.gv.egiz.bku.smccstal.ext;
import at.gv.egiz.bku.gui.BKUGUIFacade;
import at.gv.egiz.bku.gui.PINManagementGUIFacade;
+import at.gv.egiz.bku.gui.PINManagementGUIFacade.DIALOG;
import at.gv.egiz.bku.gui.PINManagementGUIFacade.STATUS;
import at.gv.egiz.bku.smccstal.AbstractRequestHandler;
+import at.gv.egiz.bku.smccstal.PINProviderFactory;
+import at.gv.egiz.smcc.CancelledException;
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.STARCOSCard;
+import at.gv.egiz.smcc.SignatureCard;
import at.gv.egiz.smcc.SignatureCardException;
+import at.gv.egiz.smcc.TimeoutException;
import at.gv.egiz.smcc.VerificationFailedException;
import at.gv.egiz.smcc.util.SMCCHelper;
import at.gv.egiz.stal.ErrorResponse;
@@ -35,8 +41,6 @@ import at.gv.egiz.stal.ext.PINManagementResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.smartcardio.Card;
import javax.smartcardio.CardChannel;
import javax.smartcardio.CardException;
@@ -53,7 +57,8 @@ public class PINManagementRequestHandler extends AbstractRequestHandler {
protected static final Log log = LogFactory.getLog(PINManagementRequestHandler.class);
- Map<PINSpec, STATUS> pinStatuses;
+ protected Map<PINSpec, STATUS> pinStatuses;
+ private ManagementPINProviderFactory pinProviderFactory;
@Override
public STALResponse handleRequest(STALRequest request) throws InterruptedException {
@@ -61,9 +66,12 @@ public class PINManagementRequestHandler extends AbstractRequestHandler {
PINManagementGUIFacade gui = (PINManagementGUIFacade) this.gui;
+ PINSpec selectedPIN = null;
+
try {
- pinStatuses = getPINStatuses();
+ pinStatuses = getPINStatuses();
+
gui.showPINManagementDialog(pinStatuses,
this, "activate_enterpin", "change_enterpin", "unblock_enterpuk", "verify_enterpin",
this, "cancel");
@@ -74,175 +82,100 @@ public class PINManagementRequestHandler extends AbstractRequestHandler {
if ("cancel".equals(actionCommand)) {
return new PINManagementResponse();
- } else if ("back".equals(actionCommand)) {
- gui.showPINManagementDialog(pinStatuses,
- this, "activate_enterpin", "change_enterpin", "unblock_enterpuk", "verify_enterpin",
- this, "cancel");
} else {
- PINSpec selectedPIN = gui.getSelectedPINSpec();
+ selectedPIN = gui.getSelectedPINSpec();
if (selectedPIN == null) {
- throw new RuntimeException("no PIN selected for activation/change");
+ throw new NullPointerException("no PIN selected for activation/change");
}
- if ("activate_enterpin".equals(actionCommand)) {
- gui.showActivatePINDialog(selectedPIN,
- this, "activate", this, "back");
- } else if ("change_enterpin".equals(actionCommand)) {
- gui.showChangePINDialog(selectedPIN,
- this, "change", this, "back");
- } else if ("unblock_enterpuk".equals(actionCommand)) {
- gui.showUnblockPINDialog(selectedPIN,
- this, "unblock", this, "back");
- } else if ("verify_enterpin".equals(actionCommand)) {
- gui.showVerifyPINDialog(selectedPIN,
- this, "verify", this, "back");
- } else if ("activate".equals(actionCommand)) {
- try {
- log.debug("activate " + selectedPIN.getLocalizedName());
- card.activatePIN(selectedPIN,
- String.valueOf(gui.getPin()));
+ if (pinProviderFactory == null) {
+ pinProviderFactory =
+ ManagementPINProviderFactory.getInstance(card, gui);
+ }
+
+ try {
+ if ("activate_enterpin".equals(actionCommand)) {
+ log.info("activate " + selectedPIN.getLocalizedName());
+ card.activatePIN(selectedPIN,
+ pinProviderFactory.getActivatePINProvider());
updatePINStatus(selectedPIN, STATUS.ACTIV);
gui.showMessageDialog(PINManagementGUIFacade.TITLE_ACTIVATE_SUCCESS,
PINManagementGUIFacade.MESSAGE_ACTIVATE_SUCCESS,
new Object[] {selectedPIN.getLocalizedName()},
- this, "ok");
+ BKUGUIFacade.BUTTON_OK, this, "ok");
waitForAction();
- gui.showPINManagementDialog(pinStatuses,
- this, "activate_enterpin", "change_enterpin", "unblock_enterpuk", "verify_enterpin",
- this, "cancel");
- } catch (GetPINStatusException ex) {
- log.error("failed to get " + selectedPIN.getLocalizedName() +
- " status: " + ex.getMessage());
- gui.showErrorDialog(PINManagementGUIFacade.ERR_STATUS, null,
- this, "cancel");
- } catch (SignatureCardException ex) {
- log.error("failed to activate " + selectedPIN.getLocalizedName() +
- ": " + ex.getMessage());
- gui.showErrorDialog(PINManagementGUIFacade.ERR_ACTIVATE,
- new Object[] {selectedPIN.getLocalizedName()},
- this, "cancel");
- }
- } else if ("change".equals(actionCommand)) {
- log.info("change " + selectedPIN.getLocalizedName());
- try {
- card.changePIN(selectedPIN,
- String.valueOf(gui.getOldPin()),
- String.valueOf(gui.getPin()));
+ } else if ("change_enterpin".equals(actionCommand)) {
+ log.info("change " + selectedPIN.getLocalizedName());
+ card.changePIN(selectedPIN,
+ pinProviderFactory.getChangePINProvider());
updatePINStatus(selectedPIN, STATUS.ACTIV);
gui.showMessageDialog(PINManagementGUIFacade.TITLE_CHANGE_SUCCESS,
PINManagementGUIFacade.MESSAGE_CHANGE_SUCCESS,
new Object[] {selectedPIN.getLocalizedName()},
- this, "ok");
- waitForAction();
- gui.showPINManagementDialog(pinStatuses,
- this, "activate_enterpin", "change_enterpin", "unblock_enterpuk", "verify_enterpin",
- this, "cancel");
- } catch (GetPINStatusException ex) {
- log.error("failed to get " + selectedPIN.getLocalizedName() +
- " status: " + ex.getMessage());
- gui.showErrorDialog(PINManagementGUIFacade.ERR_STATUS, null,
- this, "cancel");
- } catch (LockedException ex) {
- log.error("failed to change " + selectedPIN.getLocalizedName() +
- ": PIN locked");
- updatePINStatus(selectedPIN, STATUS.BLOCKED);
- gui.showErrorDialog(PINManagementGUIFacade.ERR_LOCKED,
- new Object[] {selectedPIN.getLocalizedName()},
- this, "ok");
- waitForAction();
- gui.showPINManagementDialog(pinStatuses,
- this, "activate_enterpin", "change_enterpin", "unblock_enterpuk", "verify_enterpin",
- this, "cancel");
- } catch (VerificationFailedException ex) {
- log.error("failed to change " + selectedPIN.getLocalizedName() +
- ": " + ex.getMessage());
- gui.showErrorDialog(PINManagementGUIFacade.ERR_RETRIES,
- new Object[] {selectedPIN.getLocalizedName(), ex.getRetries()},
- this, "change_enterpin");
- } catch (NotActivatedException ex) {
- log.error("failed to change " + selectedPIN.getLocalizedName() +
- ": PIN not active");
- updatePINStatus(selectedPIN, STATUS.NOT_ACTIV);
- gui.showErrorDialog(PINManagementGUIFacade.ERR_NOT_ACTIVE,
- new Object[] {selectedPIN.getLocalizedName()},
- this, "ok");
+ BKUGUIFacade.BUTTON_OK, this, "ok");
waitForAction();
- gui.showPINManagementDialog(pinStatuses,
- this, "activate_enterpin", "change_enterpin", "unblock_enterpuk", "verify_enterpin",
- this, "cancel");
- } catch (SignatureCardException ex) {
- log.error("failed to change " + selectedPIN.getLocalizedName() +
- ": " + ex.getMessage());
- gui.showErrorDialog(PINManagementGUIFacade.ERR_CHANGE,
- new Object[] {selectedPIN.getLocalizedName()},
- this, "cancel");
- }
- } else if ("unblock".equals(actionCommand)) {
- log.info("unblock " + selectedPIN.getLocalizedName());
- log.error("unblock PIN not implemented");
- gui.showErrorDialog(PINManagementGUIFacade.ERR_UNBLOCK, null, this, "cancel");
- } else if ("verify".equals(actionCommand)) {
- try {
+
+ } else if ("unblock_enterpuk".equals(actionCommand)) {
+ log.info("unblock " + selectedPIN.getLocalizedName());
+ card.unblockPIN(selectedPIN,
+ pinProviderFactory.getUnblockPINProvider());
+ } else if ("verify_enterpin".equals(actionCommand)) {
log.info("verify " + selectedPIN.getLocalizedName());
- int retries = card.verifyPIN(selectedPIN, String.valueOf(gui.getPin()));
- log.trace(retries + " retries");
- if (retries < 0) {
- updatePINStatus(selectedPIN, STATUS.ACTIV);
- gui.showPINManagementDialog(pinStatuses,
- this, "activate_enterpin", "change_enterpin", "unblock_enterpuk", "verify_enterpin",
- this, "cancel");
- } else {
- log.error("failed to verify " + selectedPIN.getLocalizedName() +
- ": " + retries + " retries left");
- gui.showErrorDialog(PINManagementGUIFacade.ERR_RETRIES,
- new Object[] {selectedPIN.getLocalizedName(), retries},
- this, "verify_enterpin");
- }
- } catch (GetPINStatusException ex) {
- log.error("failed to get " + selectedPIN.getLocalizedName() +
- " status: " + ex.getMessage());
- gui.showErrorDialog(PINManagementGUIFacade.ERR_STATUS, null,
- this, "cancel");
- } catch (LockedException ex) {
- log.error("failed to verify " + selectedPIN.getLocalizedName() +
- ": PIN locked");
- updatePINStatus(selectedPIN, STATUS.BLOCKED);
- gui.showPINManagementDialog(pinStatuses,
- this, "activate_enterpin", "change_enterpin", "unblock_enterpuk", "verify_enterpin",
- this, "cancel");
- } catch (NotActivatedException ex) {
- log.error("failed to verify " + selectedPIN.getLocalizedName() +
- ": PIN not active");
- updatePINStatus(selectedPIN, STATUS.NOT_ACTIV);
- gui.showPINManagementDialog(pinStatuses,
- this, "activate_enterpin", "change_enterpin", "unblock_enterpuk", "verify_enterpin",
- this, "cancel");
- } catch (SignatureCardException ex) {
- log.error("failed to verify " + selectedPIN.getLocalizedName() +
- ": " + ex.getMessage());
- gui.showErrorDialog(PINManagementGUIFacade.ERR_STATUS,
- new Object[] {selectedPIN.getLocalizedName()},
- this, "cancel");
+ card.verifyPIN(selectedPIN,
+ pinProviderFactory.getVerifyPINProvider());
+ updatePINStatus(selectedPIN, STATUS.ACTIV);
}
-
- } else {
- throw new RuntimeException("unsupported action " + actionCommand);
+ } catch (CancelledException ex) {
+ log.trace("cancelled");
+ } catch (TimeoutException ex) {
+ log.error("Timeout during pin entry");
+ gui.showMessageDialog(BKUGUIFacade.TITLE_ENTRY_TIMEOUT,
+ BKUGUIFacade.ERR_PIN_TIMEOUT,
+ new Object[] {selectedPIN.getLocalizedName()},
+ BKUGUIFacade.BUTTON_OK, this, null);
+ waitForAction();
+ } catch (LockedException ex) {
+ log.error(selectedPIN.getLocalizedName() + " locked");
+ updatePINStatus(selectedPIN, STATUS.BLOCKED);
+ gui.showErrorDialog(PINManagementGUIFacade.ERR_LOCKED,
+ new Object[] {selectedPIN.getLocalizedName()},
+ this, null);
+ waitForAction();
+ } catch (NotActivatedException ex) {
+ log.error(selectedPIN.getLocalizedName() + " not active");
+ updatePINStatus(selectedPIN, STATUS.NOT_ACTIV);
+ gui.showErrorDialog(PINManagementGUIFacade.ERR_NOT_ACTIVE,
+ new Object[] {selectedPIN.getLocalizedName()},
+ this, null);
+ waitForAction();
}
- }
- }
+ } // end if
+
+ selectedPIN = null;
+ gui.showPINManagementDialog(pinStatuses,
+ this, "activate_enterpin", "change_enterpin", "unblock_enterpuk", "verify_enterpin",
+ this, "cancel");
+ } // end while
+
} catch (GetPINStatusException ex) {
- log.error("Failed to get PIN statuses: " + ex.getMessage());
+ String pin = (selectedPIN != null) ? selectedPIN.getLocalizedName() : "pin";
+ log.error("failed to get " + pin + " status: " + ex.getMessage());
gui.showErrorDialog(PINManagementGUIFacade.ERR_STATUS, null,
this, "ok");
waitForAction();
return new ErrorResponse(1000);
+ } catch (SignatureCardException ex) {
+ log.error(ex.getMessage(), ex);
+ gui.showErrorDialog(PINManagementGUIFacade.ERR_UNKNOWN, null,
+ this, "ok");
+ waitForAction();
+ return new ErrorResponse(1000);
}
} else {
log.error("Got unexpected STAL request: " + request);
return new ErrorResponse(1000);
}
-
}
@Override
@@ -375,4 +308,100 @@ public class PINManagementRequestHandler extends AbstractRequestHandler {
pinStatuses.put(pinSpec, status);
}
}
+
+// /**
+// * provides oldPin and newPin from one dialog,
+// * and don't know whether providePIN() or provideOldPIN() is called first.
+// */
+// class SoftwarePinProvider implements PINProvider {
+//
+// private PINManagementGUIFacade.DIALOG type;
+// private boolean retry = false;
+//
+// private char[] newPin;
+// private char[] oldPin;
+//
+// public SoftwarePinProvider(DIALOG type) {
+// this.type = type;
+// }
+//
+// @Override
+// public char[] providePIN(PINSpec spec, int retries)
+// throws CancelledException, InterruptedException {
+// if (newPin == null) {
+// getPINs(spec, retries);
+// }
+// char[] pin = newPin;
+// newPin = null;
+// return pin;
+// }
+//
+// @Override
+// public char[] provideOldPIN(PINSpec spec, int retries)
+// throws CancelledException, InterruptedException {
+// if (oldPin == null) {
+// getPINs(spec, retries);
+// }
+// char[] pin = oldPin;
+// oldPin = null;
+// return pin;
+// }
+//
+// private void getPINs(PINSpec spec, int retries)
+// throws InterruptedException, CancelledException {
+// PINManagementGUIFacade gui =
+// (PINManagementGUIFacade) PINManagementRequestHandler.this.gui;
+//
+// if (retry) {
+// gui.showPINDialog(type, spec, retries,
+// PINManagementRequestHandler.this, "exec",
+// PINManagementRequestHandler.this, "back");
+// } else {
+// gui.showPINDialog(type, spec,
+// PINManagementRequestHandler.this, "exec",
+// PINManagementRequestHandler.this, "back");
+// }
+// waitForAction();
+//
+// if (actionCommand.equals("exec")) {
+// gui.showWaitDialog(null);
+// retry = true;
+// oldPin = gui.getOldPin();
+// newPin = gui.getPin();
+// } else if (actionCommand.equals("back")) {
+// throw new CancelledException();
+// } else {
+// log.error("unsupported command " + actionCommand);
+// throw new CancelledException();
+// }
+// }
+// }
+//
+//
+// class PinpadPinProvider implements PINProvider {
+//
+// private PINManagementGUIFacade.DIALOG type;
+// private boolean retry = false;
+//
+// public PinpadPinProvider(DIALOG type) {
+// this.type = type;
+// }
+//
+// @Override
+// public char[] providePIN(PINSpec spec, int retries) {
+// log.debug("provide pin for " + type);
+// if (retry) {
+// ((PINManagementGUIFacade) gui).showPinpadPINDialog(type, spec, retries);
+// } else {
+// ((PINManagementGUIFacade) gui).showPinpadPINDialog(type, spec, -1);
+// retry = true;
+// }
+// return null;
+// }
+//
+// @Override
+// public char[] provideOldPIN(PINSpec spec, int retries) {
+// return null;
+// }
+// }
}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PinpadPINProviderFactory.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PinpadPINProviderFactory.java
new file mode 100644
index 00000000..4176e0a9
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/PinpadPINProviderFactory.java
@@ -0,0 +1,126 @@
+/*
+ * 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.ChangePINProvider;
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.bku.gui.PINManagementGUIFacade;
+import at.gv.egiz.bku.gui.PINManagementGUIFacade.DIALOG;
+import at.gv.egiz.bku.smccstal.AbstractPINProvider;
+import at.gv.egiz.smcc.CancelledException;
+import at.gv.egiz.smcc.PINProvider;
+import at.gv.egiz.smcc.PINSpec;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class PinpadPINProviderFactory extends ManagementPINProviderFactory {
+
+ protected PinpadPINProviderFactory(PINManagementGUIFacade gui) {
+ this.gui = gui;
+ }
+
+ @Override
+ public PINProvider getVerifyPINProvider() {
+ return new SimplePinProvider(DIALOG.VERIFY);
+ }
+
+ @Override
+ public PINProvider getActivatePINProvider() {
+ return new SimplePinProvider(DIALOG.ACTIVATE);
+ }
+
+ @Override
+ public ChangePINProvider getChangePINProvider() {
+ return new SimplePinProvider(DIALOG.CHANGE);
+ }
+
+ @Override
+ public PINProvider getUnblockPINProvider() {
+ return new SimplePinProvider(DIALOG.UNBLOCK);
+ }
+
+
+ class SimplePinProvider extends AbstractPINProvider
+ implements ChangePINProvider {
+
+// protected PINManagementGUIFacade gui;
+ protected PINManagementGUIFacade.DIALOG type;
+
+ private SimplePinProvider(PINManagementGUIFacade.DIALOG type) {
+ this.type = type;
+ }
+
+ @Override
+ public char[] providePIN(PINSpec spec, int retries)
+ throws CancelledException, InterruptedException {
+
+ showPinpadPINDialog(retries, spec);
+ retry = true;
+ return null;
+
+// gui.showPINDialog(type, spec, (retry) ? retries : -1,
+// this, "exec",
+// this, "back");
+//
+// waitForAction();
+//
+// if ("exec".equals(action)) {
+// gui.showWaitDialog(null);
+// retry = true;
+// return gui.getPin();
+// } else if ("back".equals(action)) {
+// throw new CancelledException();
+// } else {
+// log.error("unsupported command " + action);
+// throw new CancelledException();
+// }
+ }
+
+ /**
+ * do not call this method without calling providePIN()
+ * (no message is displayed)
+ * @param spec
+ * @param retries
+ * @return
+ */
+ @Override
+ public char[] provideOldPIN(PINSpec spec, int retries) {
+ return null;
+ }
+
+ private void showPinpadPINDialog(int retries, PINSpec pinSpec) {
+ String title, message;
+ Object[] params;
+ if (retry) {
+ title = BKUGUIFacade.TITLE_RETRY;
+ message = BKUGUIFacade.MESSAGE_RETRIES;
+ params = new Object[]{String.valueOf(retries)};
+ } else {
+ title = BKUGUIFacade.TITLE_SIGN;
+ message = BKUGUIFacade.MESSAGE_ENTERPIN_PINPAD;
+ String pinSize = String.valueOf(pinSpec.getMinLength());
+ if (pinSpec.getMinLength() != pinSpec.getMaxLength()) {
+ pinSize += "-" + pinSpec.getMaxLength();
+ }
+ params = new Object[]{pinSpec.getLocalizedName(), pinSize};
+ }
+ gui.showMessageDialog(title, message, params);
+ }
+ }
+}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/SoftwarePINProviderFactory.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/SoftwarePINProviderFactory.java
new file mode 100644
index 00000000..e87512d0
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/SoftwarePINProviderFactory.java
@@ -0,0 +1,148 @@
+/*
+ * 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.BKUGUIFacade;
+import at.gv.egiz.smcc.ChangePINProvider;
+import at.gv.egiz.bku.gui.PINManagementGUIFacade;
+import at.gv.egiz.bku.gui.PINManagementGUIFacade.DIALOG;
+import at.gv.egiz.bku.smccstal.AbstractPINProvider;
+import at.gv.egiz.smcc.CancelledException;
+import at.gv.egiz.smcc.PINProvider;
+import at.gv.egiz.smcc.PINSpec;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class SoftwarePINProviderFactory extends ManagementPINProviderFactory {
+
+ protected SoftwarePINProviderFactory(PINManagementGUIFacade gui) {
+ this.gui = gui;
+ }
+
+ @Override
+ public PINProvider getVerifyPINProvider() {
+ return new SimplePinProvider(DIALOG.VERIFY);
+ }
+
+ @Override
+ public PINProvider getActivatePINProvider() {
+ return new SimplePinProvider(DIALOG.ACTIVATE);
+ }
+
+ @Override
+ public ChangePINProvider getChangePINProvider() {
+ return new ChangePinProvider();
+ }
+
+ @Override
+ public PINProvider getUnblockPINProvider() {
+ return new SimplePinProvider(DIALOG.UNBLOCK);
+ }
+
+ class SimplePinProvider extends AbstractPINProvider {
+
+// protected PINManagementGUIFacade gui;
+ protected PINManagementGUIFacade.DIALOG type;
+
+ private SimplePinProvider(DIALOG type) {
+ this.type = type;
+ }
+
+ @Override
+ public char[] providePIN(PINSpec spec, int retries)
+ throws CancelledException, InterruptedException {
+
+ gui.showPINDialog(type, spec, (retry) ? retries : -1,
+ this, "exec",
+ this, "back");
+
+ waitForAction();
+
+ if ("exec".equals(action)) {
+ gui.showMessageDialog(BKUGUIFacade.TITLE_WAIT,
+ BKUGUIFacade.MESSAGE_WAIT);
+ retry = true;
+ return gui.getPin();
+ } else if ("back".equals(action)) {
+ throw new CancelledException();
+ } else {
+ log.error("unsupported command " + action);
+ throw new CancelledException();
+ }
+ }
+ }
+
+ class ChangePinProvider extends AbstractPINProvider
+ implements ChangePINProvider {
+
+// protected PINManagementGUIFacade gui;
+
+ private char[] oldPin;
+ private char[] newPin;
+
+ private ChangePinProvider() {
+ }
+
+ @Override
+ public char[] providePIN(PINSpec spec, int retries)
+ throws CancelledException, InterruptedException {
+ if (newPin == null) {
+ getPINs(spec, retries);
+ }
+ char[] pin = newPin;
+ newPin = null;
+ return pin;
+ }
+
+ @Override
+ public char[] provideOldPIN(PINSpec spec, int retries)
+ throws CancelledException, InterruptedException {
+ if (oldPin == null) {
+ getPINs(spec, retries);
+ }
+ char[] pin = oldPin;
+ oldPin = null;
+ return pin;
+ }
+
+ private void getPINs(PINSpec spec, int retries)
+ throws InterruptedException, CancelledException {
+
+ gui.showPINDialog(PINManagementGUIFacade.DIALOG.CHANGE, spec,
+ (retry) ? retries : -1,
+ this, "exec",
+ this, "back");
+
+ waitForAction();
+
+ if ("exec".equals(action)) {
+ gui.showMessageDialog(BKUGUIFacade.TITLE_WAIT,
+ BKUGUIFacade.MESSAGE_WAIT);
+ retry = true;
+ oldPin = gui.getOldPin();
+ newPin = gui.getPin();
+ } else if ("back".equals(action)) {
+ throw new CancelledException();
+ } else {
+ log.error("unsupported command " + action);
+ throw new CancelledException();
+ }
+ }
+ }
+}