diff options
author | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2010-01-19 12:10:37 +0000 |
---|---|---|
committer | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2010-01-19 12:10:37 +0000 |
commit | d592f2a95096d4f234a24564b794c712359756fb (patch) | |
tree | a43f6c8b360f451348357259490c8247540daf7c | |
parent | 9a3037ba70f14a246641eda772104a60b23770a1 (diff) | |
download | mocca-d592f2a95096d4f234a24564b794c712359756fb.tar.gz mocca-d592f2a95096d4f234a24564b794c712359756fb.tar.bz2 mocca-d592f2a95096d4f234a24564b794c712359756fb.zip |
clear pin after use
bugfix correction/backspace button pinpadPinGUI
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@581 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
-rw-r--r-- | BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 35 | ||||
-rw-r--r-- | smcc/src/main/java/at/gv/egiz/smcc/reader/DefaultCardReader.java | 19 |
2 files changed, 38 insertions, 16 deletions
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java index 3fc631c3..e005836c 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java @@ -41,6 +41,8 @@ import java.text.MessageFormat; import java.util.List; import java.util.Locale; import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.GroupLayout; import javax.swing.ImageIcon; import javax.swing.JButton; @@ -55,6 +57,8 @@ import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -93,7 +97,7 @@ public class BKUGUIImpl implements BKUGUIFacade { protected JLabel switchFocusDummyLabel; /** remember the pinfield to return to worker */ protected JPasswordField pinField; - protected JPasswordField pinpadPINField; + protected Document pinpadPIN; protected int buttonSize; @@ -600,9 +604,10 @@ public class BKUGUIImpl implements BKUGUIFacade { String pinName = getMessage(LABEL_PIN); pinLabel.setText(MessageFormat.format(pinName, new Object[]{pinSpec.getLocalizedName()})); - pinpadPINField = new JPasswordField(); + JPasswordField pinpadPINField = new JPasswordField(); pinpadPINField.setText(""); pinpadPINField.setEnabled(false); + pinpadPIN = pinpadPINField.getDocument(); JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); @@ -850,9 +855,11 @@ public class BKUGUIImpl implements BKUGUIFacade { public void correctionButtonPressed() { log.debug("[" + Thread.currentThread().getName() + "] correction button pressed"); - if (pinpadPINField != null) { - String maskedPIN = pinpadPINField.getText(); - pinpadPINField.setText(maskedPIN.substring(0, maskedPIN.length() - 1)); + if (pinpadPIN != null) { + try { + pinpadPIN.remove(0, 1); + } catch (BadLocationException ex) { + } } } @@ -860,8 +867,11 @@ public class BKUGUIImpl implements BKUGUIFacade { public void allKeysCleared() { log.debug("[" + Thread.currentThread().getName() + "] all keys cleared"); - if (pinpadPINField != null) { - pinpadPINField.setText(""); + if (pinpadPIN != null) { + try { + pinpadPIN.remove(0, pinpadPIN.getLength()); + } catch (BadLocationException ex) { + } } } @@ -869,8 +879,11 @@ public class BKUGUIImpl implements BKUGUIFacade { public void validKeyPressed() { log.debug("[" + Thread.currentThread().getName() + "] valid key pressed"); - if (pinpadPINField != null) { - pinpadPINField.setText(pinpadPINField.getText() + '*'); + if (pinpadPIN != null) { + try { + pinpadPIN.insertString(0, "*", null); + } catch (BadLocationException ex) { + } } } @@ -1265,8 +1278,8 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public char[] getPin() { if (pinField != null) { - char[] pin = pinField.getPassword(); - pinField = null; + char[] pin = pinField.getPassword(); //returns a copy + pinField = null; //garbage collect original pin (make sure to clear char[] after use) return pin; } return null; diff --git a/smcc/src/main/java/at/gv/egiz/smcc/reader/DefaultCardReader.java b/smcc/src/main/java/at/gv/egiz/smcc/reader/DefaultCardReader.java index 45ea7a5a..6bf4a7de 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/reader/DefaultCardReader.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/reader/DefaultCardReader.java @@ -35,6 +35,7 @@ import at.gv.egiz.smcc.VerifyAPDUSpec; import at.gv.egiz.smcc.pin.gui.ModifyPINGUI; import at.gv.egiz.smcc.pin.gui.PINGUI; import at.gv.egiz.smcc.util.ISO7816Utils; +import java.util.Arrays; /** * @@ -61,7 +62,10 @@ public class DefaultCardReader implements CardReader { throws SignatureCardException, CardException, InterruptedException { log.debug("VERIFY"); - return channel.transmit(ISO7816Utils.createVerifyAPDU(apduSpec, pinGUI.providePIN(pinSpec, retries))); + char[] pin = pinGUI.providePIN(pinSpec, retries); + ResponseAPDU response = channel.transmit(ISO7816Utils.createVerifyAPDU(apduSpec, pin)); + Arrays.fill(pin, '0'); + return response; } @Override @@ -69,9 +73,12 @@ public class DefaultCardReader implements CardReader { ModifyPINGUI pinGUI, PINSpec pinSpec, int retries) throws SignatureCardException, CardException, InterruptedException { log.debug("MODIFY (CHANGE_REFERENCE_DATA)"); - char[] oldPin = pinGUI.provideCurrentPIN(pinSpec, retries); - char[] newPin = pinGUI.provideNewPIN(pinSpec); - return channel.transmit(ISO7816Utils.createChangeReferenceDataAPDU(apduSpec, oldPin, newPin)); + char[] oldPIN = pinGUI.provideCurrentPIN(pinSpec, retries); + char[] newPIN = pinGUI.provideNewPIN(pinSpec); + ResponseAPDU response = channel.transmit(ISO7816Utils.createChangeReferenceDataAPDU(apduSpec, oldPIN, newPIN)); + Arrays.fill(oldPIN, '0'); + Arrays.fill(newPIN, '0'); + return response; } @Override @@ -80,7 +87,9 @@ public class DefaultCardReader implements CardReader { throws SignatureCardException, CardException, InterruptedException { log.debug("MODIFY (NEW_REFERENCE_DATA)"); char[] newPIN = pinGUI.provideNewPIN(pinSpec); - return channel.transmit(ISO7816Utils.createNewReferenceDataAPDU(apduSpec, newPIN)); + ResponseAPDU response = channel.transmit(ISO7816Utils.createNewReferenceDataAPDU(apduSpec, newPIN)); + Arrays.fill(newPIN, '0'); + return response; } @Override |