diff options
author | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2009-02-27 18:10:57 +0000 |
---|---|---|
committer | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2009-02-27 18:10:57 +0000 |
commit | 4387153c6f65b55d576e1890c5b582237227369e (patch) | |
tree | 61ca0fba74146ef0d70aaf92728dcd675cfe71f6 | |
parent | 6576428966f1e3d688269a407b072fb01f9f7647 (diff) | |
download | mocca-4387153c6f65b55d576e1890c5b582237227369e.tar.gz mocca-4387153c6f65b55d576e1890c5b582237227369e.tar.bz2 mocca-4387153c6f65b55d576e1890c5b582237227369e.zip |
1.1-rc2
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@310 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
20 files changed, 418 insertions, 220 deletions
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 index 4059f0e2..ac9ab78b 100644 --- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java +++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java @@ -40,6 +40,12 @@ public class CardMgmtGUI extends BKUGUIImpl { AbstractHelpListener helpListener) { super(contentPane, locale, guiStyle, backgroundImgURL, helpListener); + } + + @Override + protected void loadMessageBundle(Locale locale) { + super.loadMessageBundle(locale); + if (locale != null) { Locale lang = new Locale(locale.getLanguage().substring(0,2)); log.debug("loading applet resources for language: " + lang.toString()); @@ -47,6 +53,18 @@ public class CardMgmtGUI extends BKUGUIImpl { } else { cardmgmtMessages = ResourceBundle.getBundle(CARDMGMT_MESSAGES_BUNDLE); } + } + + @Override + protected String getMessage(String key) { + if (super.hasMessage(key)) { + return super.getMessage(key); + } + return cardmgmtMessages.getString(key); + } + @Override + protected boolean hasMessage(String key) { + return (cardmgmtMessages.containsKey(key) || super.hasMessage(key)); } } 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 8eef8aea..1276f2d0 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 @@ -39,13 +39,17 @@ import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * 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 class PINManagementGUI extends CardMgmtGUI implements PINManagementGUIFacade { + protected static final Log log = LogFactory.getLog(PINManagementGUI.class); + /** remember the pinfield to return to worker */ protected JPasswordField oldPinField; /** remember the pinSpec to return to worker */ @@ -70,7 +74,7 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF } @Override - public PINSpec getSelectedPIN() { + public PINSpec getSelectedPINSpec() { return pinSpec; } @@ -100,11 +104,11 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF mgmtLabel.setFont(mgmtLabel.getFont().deriveFont(mgmtLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); if (renderHeaderPanel) { - titleLabel.setText(cardmgmtMessages.getString(TITLE_PINMGMT)); - String infoPattern = cardmgmtMessages.getString(MESSAGE_PINMGMT); + titleLabel.setText(getMessage(TITLE_PINMGMT)); + String infoPattern = getMessage(MESSAGE_PINMGMT); mgmtLabel.setText(MessageFormat.format(infoPattern, pins.size())); } else { - mgmtLabel.setText(cardmgmtMessages.getString(TITLE_PINMGMT)); + mgmtLabel.setText(getMessage(TITLE_PINMGMT)); } final PINStatusTableModel tableModel = new PINStatusTableModel(pins); @@ -146,19 +150,19 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF STATUS status = (STATUS) tableModel.getValueAt(selectionIdx, 1); if (status == STATUS.NOT_ACTIV) { - activateButton.setText(cardmgmtMessages.getString(BUTTON_ACTIVATE)); + activateButton.setText(getMessage(BUTTON_ACTIVATE)); activateButton.setEnabled(true); activateButton.setActionCommand(activateCmd); } else if (status == STATUS.BLOCKED) { - activateButton.setText(cardmgmtMessages.getString(BUTTON_UNBLOCK)); + activateButton.setText(getMessage(BUTTON_UNBLOCK)); activateButton.setEnabled(true); activateButton.setActionCommand(unblockCmd); } else if (status == STATUS.ACTIV) { - activateButton.setText(cardmgmtMessages.getString(BUTTON_CHANGE)); + activateButton.setText(getMessage(BUTTON_CHANGE)); activateButton.setEnabled(true); activateButton.setActionCommand(changeCmd); } else { - activateButton.setText(cardmgmtMessages.getString(BUTTON_ACTIVATE)); + activateButton.setText(getMessage(BUTTON_ACTIVATE)); activateButton.setEnabled(false); } } @@ -200,7 +204,7 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF JButton cancelButton = new JButton(); cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.setText(getMessage(BUTTON_CLOSE)); cancelButton.setActionCommand(cancelCmd); cancelButton.addActionListener(cancelListener); @@ -266,27 +270,27 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF mgmtLabel.setFont(mgmtLabel.getFont().deriveFont(mgmtLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); if (renderHeaderPanel) { - titleLabel.setText(cardmgmtMessages.getString(TITLE)); - String mgmtPattern = cardmgmtMessages.getString(MESSAGE_MGMT); + 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())); } } else { - mgmtLabel.setText(cardmgmtMessages.getString(TITLE)); + mgmtLabel.setText(getMessage(TITLE)); } JButton okButton = new JButton(); okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - okButton.setText(messages.getString(BUTTON_OK)); + okButton.setText(getMessage(BUTTON_OK)); okButton.setEnabled(false); okButton.setActionCommand(okCommand); okButton.addActionListener(okListener); JLabel pinLabel = new JLabel(); pinLabel.setFont(pinLabel.getFont().deriveFont(pinLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - String pinLabelPattern = (changePin) ? cardmgmtMessages.getString(LABEL_NEW_PIN) : messages.getString(LABEL_PIN); + String pinLabelPattern = (changePin) ? getMessage(LABEL_NEW_PIN) : getMessage(LABEL_PIN); pinLabel.setText(MessageFormat.format(pinLabelPattern, new Object[]{pinSpec.getLocalizedName()})); final JPasswordField repeatPinField = new JPasswordField(); @@ -305,7 +309,7 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF }); JLabel repeatPinLabel = new JLabel(); repeatPinLabel.setFont(pinLabel.getFont()); - String repeatPinLabelPattern = cardmgmtMessages.getString(LABEL_REPEAT_PIN); + String repeatPinLabelPattern = getMessage(LABEL_REPEAT_PIN); repeatPinLabel.setText(MessageFormat.format(repeatPinLabelPattern, new Object[]{pinSpec.getLocalizedName()})); repeatPinField.setText(""); @@ -325,7 +329,7 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF if (changePin) { oldPinLabel = new JLabel(); oldPinLabel.setFont(oldPinLabel.getFont().deriveFont(oldPinLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - String oldPinLabelPattern = cardmgmtMessages.getString(LABEL_OLD_PIN); + String oldPinLabelPattern = getMessage(LABEL_OLD_PIN); oldPinLabel.setText(MessageFormat.format(oldPinLabelPattern, new Object[]{pinSpec.getLocalizedName()})); oldPinField = new JPasswordField(); @@ -345,7 +349,7 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); - String pinsizePattern = messages.getString(LABEL_PINSIZE); + String pinsizePattern = getMessage(LABEL_PINSIZE); String pinSize = String.valueOf(pinSpec.getMinLength()); if (pinSpec.getMinLength() != pinSpec.getMaxLength()) { pinSize += "-" + pinSpec.getMaxLength(); @@ -468,7 +472,7 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF JButton cancelButton = new JButton(); cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.setText(getMessage(BUTTON_CANCEL)); cancelButton.setActionCommand(cancelCommand); cancelButton.addActionListener(cancelListener); @@ -522,12 +526,12 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_ERROR)); + titleLabel.setText(getMessage(TITLE_ERROR)); } helpListener.setHelpTopic(HELP_PINMGMT); - String errorMsgPattern = cardmgmtMessages.getString(ERR_UNBLOCK); + String errorMsgPattern = getMessage(ERR_UNBLOCK); String errorMsg = MessageFormat.format(errorMsgPattern, pin.getLocalizedName()); JLabel errorMsgLabel = new JLabel(); @@ -543,7 +547,7 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF if (!renderHeaderPanel) { JLabel errorTitleLabel = new JLabel(); errorTitleLabel.setFont(errorTitleLabel.getFont().deriveFont(errorTitleLabel.getFont().getStyle() | java.awt.Font.BOLD)); - errorTitleLabel.setText(messages.getString(TITLE_ERROR)); + errorTitleLabel.setText(getMessage(TITLE_ERROR)); errorTitleLabel.setForeground(ERROR_COLOR); mainHorizontal @@ -564,7 +568,7 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF JButton okButton = new JButton(); okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - okButton.setText(messages.getString(BUTTON_OK)); + okButton.setText(getMessage(BUTTON_OK)); okButton.setActionCommand(cancelCommand); okButton.addActionListener(cancelListener); @@ -584,5 +588,28 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF }); } + @Override + protected int initButtonSize() { + int bs = super.initButtonSize(); + JButton b = new JButton(); + b.setText(getMessage(BUTTON_ACTIVATE)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } + b.setText(getMessage(BUTTON_CHANGE)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } + b.setText(getMessage(BUTTON_UNBLOCK)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } + b.setText(getMessage(BUTTON_CANCEL)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } + + return bs; + } } 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 2a8f28d2..ffdc230d 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 @@ -43,6 +43,7 @@ public interface PINManagementGUIFacade extends BKUGUIFacade { public static final String ERR_ACTIVATE = "err.activate"; public static final String ERR_CHANGE = "err.change"; public static final String ERR_UNBLOCK = "err.unblock"; + public static final String ERR_RETRIES = "err.retries"; public static final String BUTTON_ACTIVATE = "button.activate"; public static final String BUTTON_UNBLOCK = "button.unblock"; @@ -73,5 +74,5 @@ public interface PINManagementGUIFacade extends BKUGUIFacade { public char[] getOldPin(); - public PINSpec getSelectedPIN(); + public PINSpec getSelectedPINSpec(); } diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusRenderer.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusRenderer.java index 2f8852ff..4cb84b77 100644 --- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusRenderer.java +++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusRenderer.java @@ -31,7 +31,7 @@ import org.apache.commons.logging.LogFactory; */ public class PINStatusRenderer extends DefaultTableCellRenderer { - private static final Log log = LogFactory.getLog(PINStatusRenderer.class); +// private static final Log log = LogFactory.getLog(PINStatusRenderer.class); public static final Color RED = new Color(0.9f, 0.0f, 0.0f); public static final Color GREEN = new Color(0.0f, 0.8f, 0.0f); 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 ffd83e42..85892026 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 @@ -25,8 +25,6 @@ import at.gv.egiz.stal.ext.PINManagementRequest; import at.gv.egiz.stal.ext.PINManagementResponse; import java.util.Collections; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; /** * This BKU Worker does not connect to STAL webservice @@ -52,8 +50,9 @@ public class PINManagementBKUWorker extends AppletBKUWorker { if (responses.size() == 1) { STALResponse response = responses.get(0); if (response instanceof PINManagementResponse) { - log.debug("PIN management dialog finished"); + 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()); 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 fcef3191..851bff21 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 @@ -22,6 +22,7 @@ import at.gv.egiz.bku.gui.PINManagementGUIFacade.STATUS; import at.gv.egiz.bku.smccstal.AbstractRequestHandler; import at.gv.egiz.smcc.PINSpec; import at.gv.egiz.smcc.SignatureCardException; +import at.gv.egiz.smcc.VerificationFailedException; import at.gv.egiz.smcc.util.SMCCHelper; import at.gv.egiz.stal.ErrorResponse; import at.gv.egiz.stal.STALRequest; @@ -31,6 +32,8 @@ 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; @@ -45,7 +48,6 @@ import org.apache.commons.logging.LogFactory; */ public class PINManagementRequestHandler extends AbstractRequestHandler { - public static final String ERR_NOPIN_SELECTED = "err.no.pin.selected"; protected static final Log log = LogFactory.getLog(PINManagementRequestHandler.class); // protected ResourceBundle messages; @@ -70,7 +72,7 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { } else if ("back".equals(actionCommand)) { showPINManagementDialog(gui); } else { - PINSpec selectedPIN = gui.getSelectedPIN(); + PINSpec selectedPIN = gui.getSelectedPINSpec(); if (selectedPIN == null) { throw new RuntimeException("no PIN selected for activation/change"); @@ -99,6 +101,11 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { byte[] pin = encodePIN(gui.getPin()); //new byte[]{(byte) 0x25, (byte) 0x40}; changePIN(selectedPIN.getKID(), selectedPIN.getContextAID(), oldPin, pin); showPINManagementDialog(gui); + } catch (VerificationFailedException ex) { + log.error("failed to change " + selectedPIN.getLocalizedName() + ": " + ex.getMessage()); + gui.showErrorDialog(PINManagementGUIFacade.ERR_RETRIES, + new Object[] {selectedPIN.getLocalizedName(), ex.getRetries()}, + this, "back"); } catch (SignatureCardException ex) { log.error("failed to change " + selectedPIN.getLocalizedName() + ": " + ex.getMessage()); gui.showErrorDialog(PINManagementGUIFacade.ERR_CHANGE, @@ -132,8 +139,8 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { * @throws at.gv.egiz.smcc.SignatureCardException */ private void activatePIN(byte kid, byte[] contextAID, byte[] pin) throws SignatureCardException { + Card icc = card.getCard(); try { - Card icc = card.getCard(); icc.beginExclusive(); CardChannel channel = icc.getBasicChannel(); @@ -141,6 +148,7 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { CommandAPDU selectAPDU = new CommandAPDU(0x00, 0xa4, 0x04, 0x0c, contextAID); ResponseAPDU responseAPDU = channel.transmit(selectAPDU); if (responseAPDU.getSW() != 0x9000) { + icc.endExclusive(); String msg = "Failed to activate PIN " + SMCCHelper.toString(new byte[]{kid}) + ": Failed to select AID " + SMCCHelper.toString(contextAID) + ": " + SMCCHelper.toString(responseAPDU.getBytes()); @@ -150,8 +158,9 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { } if (pin.length > 7) { - log.error("Invalid PIN"); - throw new SignatureCardException("Invalid PIN"); + icc.endExclusive(); + log.error("PIN too long"); + throw new SignatureCardException("PIN too long"); } byte length = (byte) (0x20 | pin.length * 2); @@ -166,24 +175,27 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { ResponseAPDU responseAPDU = channel.transmit(verifyAPDU); if (responseAPDU.getSW() != 0x9000) { + icc.endExclusive(); String msg = "Failed to activate PIN " + SMCCHelper.toString(new byte[]{kid}) + ": " + SMCCHelper.toString(responseAPDU.getBytes()); log.error(msg); throw new SignatureCardException(msg); } - - icc.endExclusive(); - - } catch (CardException ex) { - log.error("Failed to get PIN status: " + ex.getMessage()); - throw new SignatureCardException("Failed to get PIN status", ex); + log.error("Failed to activate PIN: " + ex.getMessage()); + throw new SignatureCardException(ex.getMessage(), ex); + } finally { + try { + icc.endExclusive(); + } catch (CardException ex) { + log.trace("failed to end exclusive card access"); + } } } - private void changePIN(byte kid, byte[] contextAID, byte[] oldPIN, byte[] newPIN) throws SignatureCardException { + private void changePIN(byte kid, byte[] contextAID, byte[] oldPIN, byte[] newPIN) throws SignatureCardException, VerificationFailedException { + Card icc = card.getCard(); try { - Card icc = card.getCard(); icc.beginExclusive(); CardChannel channel = icc.getBasicChannel(); @@ -191,6 +203,7 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { CommandAPDU selectAPDU = new CommandAPDU(0x00, 0xa4, 0x04, 0x0c, contextAID); ResponseAPDU responseAPDU = channel.transmit(selectAPDU); if (responseAPDU.getSW() != 0x9000) { + icc.endExclusive(); String msg = "Failed to change PIN " + SMCCHelper.toString(new byte[]{kid}) + ": Failed to select AID " + SMCCHelper.toString(contextAID) + ": " + SMCCHelper.toString(responseAPDU.getBytes()); @@ -200,8 +213,9 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { } if (oldPIN.length > 7 || newPIN.length > 7) { - log.error("Invalid PIN"); - throw new SignatureCardException("Invalid PIN"); + icc.endExclusive(); + log.error("PIN too long"); + throw new SignatureCardException("PIN too long"); } byte oldLength = (byte) (0x20 | oldPIN.length * 2); byte newLength = (byte) (0x20 | newPIN.length * 2); @@ -220,49 +234,43 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { CommandAPDU verifyAPDU = new CommandAPDU(apdu); ResponseAPDU responseAPDU = channel.transmit(verifyAPDU); + if (responseAPDU.getSW1() == 0x63 && responseAPDU.getSW2() >> 4 == 0xc) { + icc.endExclusive(); + int retries = responseAPDU.getSW2() & 0x0f; + log.error("Wrong PIN, " + retries + " tries left"); + throw new VerificationFailedException(retries); + } if (responseAPDU.getSW() != 0x9000) { - String msg = "Failed to change PIN " + SMCCHelper.toString(new byte[]{kid}) + ": " + SMCCHelper.toString(responseAPDU.getBytes()); + icc.endExclusive(); + String msg = "Failed to change PIN " + + SMCCHelper.toString(new byte[]{kid}) + ": " + + SMCCHelper.toString(responseAPDU.getBytes()); log.error(msg); throw new SignatureCardException(msg); } - - - icc.endExclusive(); - + } catch (CardException ex) { - log.error("Failed to get PIN status: " + ex.getMessage()); - throw new SignatureCardException("Failed to get PIN status", ex); + log.error("Failed to change PIN: " + ex.getMessage()); + throw new SignatureCardException(ex.getMessage(), ex); + } finally { + try { + icc.endExclusive(); + } catch (CardException ex) { + log.trace("failed to end exclusive card access"); + } } } public Map<PINSpec, STATUS> getPINStatuses() throws SignatureCardException { + Card icc = card.getCard(); try { - Card icc = card.getCard(); icc.beginExclusive(); CardChannel channel = icc.getBasicChannel(); HashMap<PINSpec, STATUS> pinStatuses = new HashMap<PINSpec, STATUS>(); List<PINSpec> pins = card.getPINSpecs(); - //select DF_SichereSignatur 00 A4 04 0C 08 D0 40 00 00 17 00 12 01 -// CommandAPDU selectAPDU = new CommandAPDU(new byte[]{(byte) 0x00, (byte) 0xa4, (byte) 0x04, (byte) 0x0c, (byte) 0x08, -// (byte) 0xd0, (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x17, (byte) 0x00, (byte) 0x12, (byte) 0x01}); -// ResponseAPDU rAPDU = channel.transmit(selectAPDU); -// log.debug("SELECT FILE DF_SichereSignatur: " + SMCCHelper.toString(rAPDU.getBytes())); - - //select DF_SIG DF 70 -// CommandAPDU selectAPDU = new CommandAPDU(new byte[]{(byte) 0x00, (byte) 0xa4, (byte) 0x00, (byte) 0x0c, (byte) 0x02, -// (byte) 0xdf, (byte) 0x70 }); -// ResponseAPDU rAPDU = channel.transmit(selectAPDU); -// log.debug("SELECT FILE DF_SIG: " + SMCCHelper.toString(rAPDU.getBytes())); - - //select DF_DEC DF 71 -// CommandAPDU selectAPDU = new CommandAPDU(new byte[]{(byte) 0x00, (byte) 0xa4, (byte) 0x04, (byte) 0x0c, (byte) 0x08, -// (byte) 0xd0, (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x17, (byte) 0x00, (byte) 0x12, (byte) 0x01}); -// ResponseAPDU rAPDU = channel.transmit(selectAPDU); -// log.debug("SELECT FILE DF_SichereSignatur: " + SMCCHelper.toString(rAPDU.getBytes())); - for (PINSpec pinSpec : pins) { byte kid = pinSpec.getKID(); byte[] contextAID = pinSpec.getContextAID(); @@ -271,6 +279,7 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { CommandAPDU selectAPDU = new CommandAPDU(0x00, 0xa4, 0x04, 0x0c, contextAID); ResponseAPDU responseAPDU = channel.transmit(selectAPDU); if (responseAPDU.getSW() != 0x9000) { + icc.endExclusive(); String msg = "Failed to activate PIN " + SMCCHelper.toString(new byte[]{kid}) + ": Failed to select AID " + SMCCHelper.toString(contextAID) + ": " + SMCCHelper.toString(responseAPDU.getBytes()); @@ -296,13 +305,19 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { pinStatuses.put(pinSpec, status); } - icc.endExclusive(); +// icc.endExclusive(); return pinStatuses; } catch (CardException ex) { log.error("Failed to get PIN status: " + ex.getMessage()); - throw new SignatureCardException("Failed to get PIN status", ex); + throw new SignatureCardException(ex.getMessage(), ex); + } finally { + try { + icc.endExclusive(); + } catch (CardException ex) { + log.trace("failed to end exclusive card access"); + } } } @@ -312,7 +327,7 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { for (int i = 0; i < length; i++) { pin[i] = (byte) (16*Character.digit(pinChars[i*2], 16) + Character.digit(pinChars[i*2+1], 16)); } - log.trace("***** " + SMCCHelper.toString(pin) + " ******"); +// log.trace("***** " + SMCCHelper.toString(pin) + " ******"); return pin; } @@ -324,7 +339,7 @@ public class PINManagementRequestHandler extends AbstractRequestHandler { this, "cancel"); } catch (SignatureCardException ex) { gui.showErrorDialog(BKUGUIFacade.ERR_UNKNOWN_WITH_PARAM, - new Object[]{"FAILED TO GET PIN STATUSES: " + ex.getMessage()}, + new Object[]{ex.getMessage()}, this, "cancel"); } } 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 index e51044af..b6099db6 100644 --- a/BKUAppletExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties +++ b/BKUAppletExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties @@ -41,6 +41,7 @@ help.pin.mgmt=help.pin.mgmt err.activate=<html>Beim Aktivieren der {0} trat ein Fehler auf.</html> err.change=<html>Beim \u00C4ndern der {0} trat ein Fehler auf.</html> err.unblock=<html>Das Entsperren der {0} wird nicht unterst\u00FCtzt.</html> +err.retries=<html>Falscher {0}, noch {1} Versuche</html> status.not.active=NICHT AKTIV status.active=AKTIV 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 index 1cf4a102..40332826 100644 --- 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 @@ -38,11 +38,12 @@ button.unblock=Unblock help.activation=help.activation help.pin.mgmt=help.pin.mgmt -err.activate=<html>An error occured during activation of {0}.</html> -err.change=<html>An error occured during changing of {0}.</html> +err.activate=<html>An error occured during the activation of {0}.</html> +err.change=<html>An error occured during the changing of {0}.</html> err.unblock=<html>Unblocking of {0} is not supported.</html> +err.retries=<html>Wrong {0}, {1} tries remaining</html> -status.not.active=Not active -status.active=Active -status.blocked=Blocked -status.unknown=Unknown +status.not.active=NOT ACTIVE +status.active=ACTIVE +status.blocked=BLOCKED +status.unknown=UNKNOWN diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java index 6fd29ba9..ae91670a 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java @@ -97,6 +97,10 @@ public interface BKUGUIFacade { // public void init(Container contentPane, Locale locale, Style guiStyle, URL background, ActionListener helpListener); + /** + * BKUWorker needs to init signature card with locale + * @return + */ public Locale getLocale(); public void showWelcomeDialog(); 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 1d5a2cf4..ca597701 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 @@ -115,13 +115,7 @@ public class BKUGUIImpl implements BKUGUIFacade { ActionListener helpListener) { this.contentPane = contentPane; - if (locale != null) { - Locale lang = new Locale(locale.getLanguage().substring(0,2)); - log.debug("loading applet resources for language: " + lang.toString()); - messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, lang); - } else { - messages = ResourceBundle.getBundle(MESSAGES_BUNDLE); - } + loadMessageBundle(locale); if (guiStyle == Style.advanced) { renderHeaderPanel = true; @@ -230,11 +224,11 @@ public class BKUGUIImpl implements BKUGUIFacade { helpLabel = new JLabel(); helpLabel.setIcon(new ImageIcon(getClass().getResource(HELP_IMG))); - helpLabel.getAccessibleContext().setAccessibleName(messages.getString(ALT_HELP)); + helpLabel.getAccessibleContext().setAccessibleName(getMessage(ALT_HELP)); helpLabel.addMouseListener(helpListener); helpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - buttonSize = initButtonSize(messages, renderCancelButton); + buttonSize = initButtonSize(); if (renderHeaderPanel) { headerPanel = new JPanel(); @@ -292,11 +286,33 @@ public class BKUGUIImpl implements BKUGUIFacade { contentPanelLayout.setVerticalGroup(verticalContent); } + /** + * BKUWorker inits signaturecard with locale + * @return + */ @Override public Locale getLocale() { return messages.getLocale(); } + /** + * to be overridden by subclasses providing additional resource messages + * @param key + * @return + */ + protected String getMessage(String key) { + return messages.getString(key); + } + + /** + * to be overridden by subclasses providing additional resource messages + * @param key + * @return + */ + protected boolean hasMessage(String key) { + return messages.containsKey(key); + } + @Override public void showWelcomeDialog() { @@ -318,10 +334,10 @@ public class BKUGUIImpl implements BKUGUIFacade { welcomeMsgLabel.setFont(welcomeMsgLabel.getFont().deriveFont(welcomeMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_WELCOME)); - welcomeMsgLabel.setText(messages.getString(MESSAGE_WAIT)); + titleLabel.setText(getMessage(TITLE_WELCOME)); + welcomeMsgLabel.setText(getMessage(MESSAGE_WAIT)); } else { - welcomeMsgLabel.setText(messages.getString(TITLE_WELCOME)); + welcomeMsgLabel.setText(getMessage(TITLE_WELCOME)); } GroupLayout mainPanelLayout = new GroupLayout(mainPanel); @@ -364,14 +380,14 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_INSERTCARD)); + titleLabel.setText(getMessage(TITLE_INSERTCARD)); } helpListener.setHelpTopic(HELP_INSERTCARD); JLabel insertCardMsgLabel = new JLabel(); insertCardMsgLabel.setFont(insertCardMsgLabel.getFont().deriveFont(insertCardMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - insertCardMsgLabel.setText(messages.getString(MESSAGE_INSERTCARD)); + insertCardMsgLabel.setText(getMessage(MESSAGE_INSERTCARD)); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); @@ -395,7 +411,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderCancelButton) { JButton cancelButton = new JButton(); cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.setText(getMessage(BUTTON_CANCEL)); cancelButton.addActionListener(cancelListener); cancelButton.setActionCommand(cancelCommand); @@ -440,10 +456,10 @@ public class BKUGUIImpl implements BKUGUIFacade { insertCardMsgLabel.setFont(insertCardMsgLabel.getFont().deriveFont(insertCardMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_CARD_NOT_SUPPORTED)); - insertCardMsgLabel.setText(messages.getString(MESSAGE_INSERTCARD)); + titleLabel.setText(getMessage(TITLE_CARD_NOT_SUPPORTED)); + insertCardMsgLabel.setText(getMessage(MESSAGE_INSERTCARD)); } else { - insertCardMsgLabel.setText(messages.getString(TITLE_CARD_NOT_SUPPORTED)); + insertCardMsgLabel.setText(getMessage(TITLE_CARD_NOT_SUPPORTED)); } helpListener.setHelpTopic(HELP_CARDNOTSUPPORTED); @@ -469,7 +485,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderCancelButton) { JButton cancelButton = new JButton(); cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.setText(getMessage(BUTTON_CANCEL)); cancelButton.addActionListener(cancelListener); cancelButton.setActionCommand(cancelCommand); @@ -506,23 +522,23 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderHeaderPanel) { if (numRetries < 0) { - String cardpinTitle = messages.getString(TITLE_CARDPIN); + String cardpinTitle = getMessage(TITLE_CARDPIN); titleLabel.setText(MessageFormat.format(cardpinTitle, new Object[]{pinSpec.getLocalizedName()})); } else { - titleLabel.setText(messages.getString(TITLE_RETRY)); + titleLabel.setText(getMessage(TITLE_RETRY)); } } JButton okButton = new JButton(); okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - okButton.setText(messages.getString(BUTTON_OK)); + okButton.setText(getMessage(BUTTON_OK)); okButton.setEnabled(false); okButton.setActionCommand(okCommand); okButton.addActionListener(okListener); JLabel cardPinLabel = new JLabel(); cardPinLabel.setFont(cardPinLabel.getFont().deriveFont(cardPinLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - String pinLabel = messages.getString(LABEL_PIN); + String pinLabel = getMessage(LABEL_PIN); cardPinLabel.setText(MessageFormat.format(pinLabel, new Object[]{pinSpec.getLocalizedName()})); pinField = new JPasswordField(); @@ -542,7 +558,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel infoLabel = new JLabel(); if (numRetries < 0) { infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - String infoPattern = messages.getString(MESSAGE_ENTERPIN); + String infoPattern = getMessage(MESSAGE_ENTERPIN); if (shortText) { infoLabel.setText(MessageFormat.format(infoPattern, new Object[] {"PIN"})); } else { @@ -552,9 +568,9 @@ public class BKUGUIImpl implements BKUGUIFacade { } else { String retryPattern; if (numRetries < 2) { - retryPattern = messages.getString(MESSAGE_LAST_RETRY); + retryPattern = getMessage(MESSAGE_LAST_RETRY); } else { - retryPattern = messages.getString(MESSAGE_RETRIES); + retryPattern = getMessage(MESSAGE_RETRIES); } infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); @@ -564,7 +580,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); - String pinsizePattern = messages.getString(LABEL_PINSIZE); + String pinsizePattern = getMessage(LABEL_PINSIZE); String pinSize = String.valueOf(pinSpec.getMinLength()); if (pinSpec.getMinLength() != pinSpec.getMaxLength()) { pinSize += "-" + pinSpec.getMaxLength(); @@ -638,7 +654,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderCancelButton) { JButton cancelButton = new JButton(); cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.setText(getMessage(BUTTON_CANCEL)); cancelButton.setActionCommand(cancelCommand); cancelButton.addActionListener(cancelListener); @@ -699,22 +715,22 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderHeaderPanel) { if (numRetries < 0) { - titleLabel.setText(messages.getString(TITLE_SIGN)); + titleLabel.setText(getMessage(TITLE_SIGN)); } else { - titleLabel.setText(messages.getString(TITLE_RETRY)); + titleLabel.setText(getMessage(TITLE_RETRY)); } } JButton signButton = new JButton(); signButton.setFont(signButton.getFont().deriveFont(signButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - signButton.setText(messages.getString(BUTTON_SIGN)); + signButton.setText(getMessage(BUTTON_SIGN)); signButton.setEnabled(false); signButton.setActionCommand(signCommand); signButton.addActionListener(signListener); JLabel signPinLabel = new JLabel(); signPinLabel.setFont(signPinLabel.getFont().deriveFont(signPinLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - String pinLabel = messages.getString(LABEL_PIN); + String pinLabel = getMessage(LABEL_PIN); signPinLabel.setText(MessageFormat.format(pinLabel, new Object[]{pinSpec.getLocalizedName()})); pinField = new JPasswordField(); @@ -733,7 +749,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); - String pinsizePattern = messages.getString(LABEL_PINSIZE); + String pinsizePattern = getMessage(LABEL_PINSIZE); String pinSize = String.valueOf(pinSpec.getMinLength()); if (pinSpec.getMinLength() != pinSpec.getMaxLength()) { pinSize += "-" + pinSpec.getMaxLength(); @@ -744,9 +760,9 @@ public class BKUGUIImpl implements BKUGUIFacade { if (numRetries < 0) { infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); if (shortText) { - infoLabel.setText(messages.getString(MESSAGE_HASHDATALINK_TINY)); + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY)); } else { - infoLabel.setText(messages.getString(MESSAGE_HASHDATALINK)); + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); } infoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); infoLabel.setForeground(HYPERLINK_COLOR); @@ -762,9 +778,9 @@ public class BKUGUIImpl implements BKUGUIFacade { } else { String retryPattern; if (numRetries < 2) { - retryPattern = messages.getString(MESSAGE_LAST_RETRY); + retryPattern = getMessage(MESSAGE_LAST_RETRY); } else { - retryPattern = messages.getString(MESSAGE_RETRIES); + retryPattern = getMessage(MESSAGE_RETRIES); } infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); @@ -839,7 +855,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderCancelButton) { JButton cancelButton = new JButton(); cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.setText(getMessage(BUTTON_CANCEL)); cancelButton.setActionCommand(cancelCommand); cancelButton.addActionListener(cancelListener); @@ -881,12 +897,12 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_ERROR)); + titleLabel.setText(getMessage(TITLE_ERROR)); } helpListener.setHelpTopic(errorMsgKey); - String errorMsgPattern = messages.getString(errorMsgKey); + String errorMsgPattern = getMessage(errorMsgKey); String errorMsg = MessageFormat.format(errorMsgPattern, errorMsgParams); JLabel errorMsgLabel = new JLabel(); @@ -902,7 +918,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (!renderHeaderPanel) { JLabel errorTitleLabel = new JLabel(); errorTitleLabel.setFont(errorTitleLabel.getFont().deriveFont(errorTitleLabel.getFont().getStyle() | java.awt.Font.BOLD)); - errorTitleLabel.setText(messages.getString(TITLE_ERROR)); + errorTitleLabel.setText(getMessage(TITLE_ERROR)); errorTitleLabel.setForeground(ERROR_COLOR); mainHorizontal @@ -923,7 +939,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JButton okButton = new JButton(); okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - okButton.setText(messages.getString(BUTTON_OK)); + okButton.setText(getMessage(BUTTON_OK)); okButton.setActionCommand(okCommand); okButton.addActionListener(okListener); @@ -959,12 +975,12 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_ERROR)); + titleLabel.setText(getMessage(TITLE_ERROR)); } helpListener.setHelpTopic(errorMsgKey); - String errorMsgPattern = messages.getString(errorMsgKey); + String errorMsgPattern = getMessage(errorMsgKey); String errorMsg = MessageFormat.format(errorMsgPattern, errorMsgParams); JLabel errorMsgLabel = new JLabel(); @@ -981,7 +997,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (!renderHeaderPanel) { JLabel errorTitleLabel = new JLabel(); errorTitleLabel.setFont(errorTitleLabel.getFont().deriveFont(errorTitleLabel.getFont().getStyle() | java.awt.Font.BOLD)); - errorTitleLabel.setText(messages.getString(TITLE_ERROR)); + errorTitleLabel.setText(getMessage(TITLE_ERROR)); errorTitleLabel.setForeground(ERROR_COLOR); mainHorizontal @@ -1021,7 +1037,7 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_WAIT)); + titleLabel.setText(getMessage(TITLE_WAIT)); } helpListener.setHelpTopic(HELP_WAIT); @@ -1031,7 +1047,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (waitMessage != null) { waitMsgLabel.setText("<html>" + waitMessage + "</html>"); } else { - waitMsgLabel.setText(messages.getString(MESSAGE_WAIT)); + waitMsgLabel.setText(getMessage(MESSAGE_WAIT)); } GroupLayout mainPanelLayout = new GroupLayout(mainPanel); @@ -1079,7 +1095,7 @@ public class BKUGUIImpl implements BKUGUIFacade { final String okCommand) { if (signedReferences == null) { - showErrorDialog(messages.getString(ERR_NO_HASHDATA), new Object[] {"No SignedReferences provided"}, okListener, okCommand); + showErrorDialog(getMessage(ERR_NO_HASHDATA), new Object[] {"No SignedReferences provided"}, okListener, okCommand); return; } @@ -1142,14 +1158,14 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_HASHDATA)); + titleLabel.setText(getMessage(TITLE_HASHDATA)); } helpListener.setHelpTopic(HELP_HASHDATALIST); JLabel refIdLabel = new JLabel(); refIdLabel.setFont(refIdLabel.getFont().deriveFont(refIdLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - String refIdLabelPattern = messages.getString(MESSAGE_HASHDATALIST); + String refIdLabelPattern = getMessage(MESSAGE_HASHDATALIST); refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.size()})); HashDataTableModel tableModel = new HashDataTableModel(signedReferences, renderRefId); @@ -1229,7 +1245,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JButton backButton = new JButton(); backButton.setFont(backButton.getFont().deriveFont(backButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - backButton.setText(messages.getString(BUTTON_BACK)); + backButton.setText(getMessage(BUTTON_BACK)); backButton.setActionCommand(backCommand); backButton.addActionListener(backListener); @@ -1271,15 +1287,15 @@ public class BKUGUIImpl implements BKUGUIFacade { fileDialog.setDialogType(JFileChooser.SAVE_DIALOG); fileDialog.setFileHidingEnabled(true); if (signedRefs.size() == 1) { - fileDialog.setDialogTitle(messages.getString(WINDOWTITLE_SAVE)); + fileDialog.setDialogTitle(getMessage(WINDOWTITLE_SAVE)); fileDialog.setFileSelectionMode(JFileChooser.FILES_ONLY); String mimeType = signedRefs.get(0).getMimeType(); MimeFilter mimeFilter = new MimeFilter(mimeType, messages); fileDialog.setFileFilter(mimeFilter); - String filename = messages.getString(SAVE_HASHDATAINPUT_PREFIX) + MimeFilter.getExtension(mimeType); + String filename = getMessage(SAVE_HASHDATAINPUT_PREFIX) + MimeFilter.getExtension(mimeType); fileDialog.setSelectedFile(new File(userHome, filename)); } else { - fileDialog.setDialogTitle(messages.getString(WINDOWTITLE_SAVEDIR)); + fileDialog.setDialogTitle(getMessage(WINDOWTITLE_SAVEDIR)); fileDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); } @@ -1292,14 +1308,14 @@ public class BKUGUIImpl implements BKUGUIFacade { String id = hashDataInput.getReferenceId(); File file; if (f.isDirectory()) { - String filename = messages.getString(SAVE_HASHDATAINPUT_PREFIX) + '_' + id + MimeFilter.getExtension(mimeType); + String filename = getMessage(SAVE_HASHDATAINPUT_PREFIX) + '_' + id + MimeFilter.getExtension(mimeType); file = new File(f, filename); } else { file = f; } if (file.exists()) { - String ovrwrt = messages.getString(MESSAGE_OVERWRITE); - int overwrite = JOptionPane.showConfirmDialog(fileDialog, MessageFormat.format(ovrwrt, file), messages.getString(WINDOWTITLE_OVERWRITE), JOptionPane.OK_CANCEL_OPTION); + String ovrwrt = getMessage(MESSAGE_OVERWRITE); + int overwrite = JOptionPane.showConfirmDialog(fileDialog, MessageFormat.format(ovrwrt, file), getMessage(WINDOWTITLE_OVERWRITE), JOptionPane.OK_CANCEL_OPTION); if (overwrite != JOptionPane.OK_OPTION) { continue; } @@ -1352,34 +1368,50 @@ public class BKUGUIImpl implements BKUGUIFacade { }); } } - - private static int initButtonSize(ResourceBundle messages, boolean renderCancelButton) { - int buttonSize = 0; - - JButton b = new JButton(); - b.setText(messages.getString(BUTTON_OK)); - if (b.getPreferredSize().width > buttonSize) { - buttonSize = b.getPreferredSize().width; - } - b.setText(messages.getString(BUTTON_SIGN)); - if (b.getPreferredSize().width > buttonSize) { - buttonSize = b.getPreferredSize().width; - } - b.setText(messages.getString(BUTTON_BACK)); - if (b.getPreferredSize().width > buttonSize) { - buttonSize = b.getPreferredSize().width; - } - b.setText(messages.getString(BUTTON_SAVE)); - if (b.getPreferredSize().width > buttonSize) { - buttonSize = b.getPreferredSize().width; + /** + * Called from constructor. + * Subclasses may override this method to ensure the message bundle is loaded + * once initButtonSize (called from constructor as well) is called. + * (Only relevant if initButtonSize is overridden as well) + * @param locale + */ + protected void loadMessageBundle(Locale locale) { + if (locale != null) { + Locale lang = new Locale(locale.getLanguage().substring(0, 2)); + log.debug("loading applet resources for language: " + lang.toString()); + messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, lang); + } else { + messages = ResourceBundle.getBundle(MESSAGES_BUNDLE); + } } - if (renderCancelButton) { - b.setText(messages.getString(BUTTON_CANCEL)); - if (b.getPreferredSize().width > buttonSize) { - buttonSize = b.getPreferredSize().width; + + protected int initButtonSize() { + int bs = 0; + + JButton b = new JButton(); + b.setText(getMessage(BUTTON_OK)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } + b.setText(getMessage(BUTTON_SIGN)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } + b.setText(getMessage(BUTTON_BACK)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } + b.setText(getMessage(BUTTON_SAVE)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } + if (renderCancelButton) { + b.setText(getMessage(BUTTON_CANCEL)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } } + return bs; } - return buttonSize; - } } diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java index 81b70b7c..9a9bd444 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java +++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java @@ -315,10 +315,6 @@ public class STALRequestBrokerImpl implements STALRequestBroker { } } - @Override - public void setLocale(Locale locale) { - } - private List<JAXBElement<? extends RequestType>> createSingleQuitRequest() { QuitRequestType quitT = of.createQuitRequestType(); JAXBElement<QuitRequestType> quit = of.createGetNextRequestResponseTypeQuitRequest(quitT); diff --git a/BKUOnline/src/main/webapp/PINManagement.jsp b/BKUOnline/src/main/webapp/PINManagement.jsp new file mode 100644 index 00000000..0f08f64b --- /dev/null +++ b/BKUOnline/src/main/webapp/PINManagement.jsp @@ -0,0 +1,79 @@ +<!-- + 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. +--> +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8" + import="at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage"%> + +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <title>MOCCA PIN Management</title> + <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon"> + <script type="text/javascript" src="js/deployJava.js"></script> + <style type="text/css" media="all">@import "css/applet.css";</style> + + <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> + <META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2002 11:12:01 GMT"> + <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> + </head> + <% + String locale = request.getParameter("locale"); + if (locale == null) { + String acceptLanguage = request.getHeader("Accept-Language"); + locale = AcceptLanguage.getLocale(acceptLanguage).toString(); + } + String widthP = request.getParameter("appletWidth"); + String heightP = request.getParameter("appletHeight"); + int width = (widthP == null) ? 295 + : Integer.parseInt(widthP); + int height = (heightP == null) ? 195 + : Integer.parseInt(heightP); + String guiStyle = request.getParameter("appletGuiStyle"); + if (guiStyle == null) { + guiStyle = "advanced"; + } + String backgroundImg = request.getParameter("appletBackground"); + %> + <body id="appletpage" style="width:<%=width%>"> + <script> + if (!deployJava.versionCheck('1.6.0_04+')) { + document + .write('<b>Diese Anwendung benötigt die Java Platform Version 1.6.0_04 oder höher.</b>' + '<input type="submit" value="Java Platform 1.6.0_02 installieren" onclick="deployJava.installLatestJRE();">'); + } else { + var attributes = { + codebase :'applet', + code : 'at.gv.egiz.bku.online.applet.PINManagementApplet.class', + archive : 'BKUAppletExt.jar, commons-logging.jar, iaik_jce_me4se.jar', + width : <%=width%>, + height :<%=height%> + }; + var parameters = { + GuiStyle : '<%=guiStyle%>', + Locale : '<%=locale%>', + Background : '<%=backgroundImg%>', + HelpURL : '../help/', + SessionID : '<%=request.getSession().getId()%>', + RedirectURL : '../', + RedirectTarget: '_parent' + }; + var version = '1.6.0_04'; + deployJava.runApplet(attributes, parameters, version); + } + </script> + </body> +</html> diff --git a/BKUOnline/src/main/webapp/slRequestForm.html b/BKUOnline/src/main/webapp/SLRequestForm.html index 76cd1be9..2aed5298 100644 --- a/BKUOnline/src/main/webapp/slRequestForm.html +++ b/BKUOnline/src/main/webapp/SLRequestForm.html @@ -32,6 +32,7 @@ //--> </script> + <style type="text/css" media="all">@import "css/main.css";</style> </head> <body> diff --git a/BKUOnline/src/main/webapp/css/applet.css b/BKUOnline/src/main/webapp/css/applet.css index 4bfbd77d..d2c734a1 100644 --- a/BKUOnline/src/main/webapp/css/applet.css +++ b/BKUOnline/src/main/webapp/css/applet.css @@ -1,4 +1,3 @@ - root { display: block; } diff --git a/BKUOnline/src/main/webapp/css/main.css b/BKUOnline/src/main/webapp/css/main.css new file mode 100644 index 00000000..114b8da9 --- /dev/null +++ b/BKUOnline/src/main/webapp/css/main.css @@ -0,0 +1,48 @@ +/* +Document : main +Created on : 27.02.2009, 10:24:41 +Author : clemens +Description: +Purpose of the stylesheet follows. +*/ + +/* +TODO customize this sample style +Syntax recommendation http://www.w3.org/TR/REC-CSS2/ +*/ + +root { + display: block; +} + +body { + font-family: sans-serif; + font-size: 14px; +} + +h1 { + font-size: 16px; +} + +.box { + margin-top: 10px; + color: #292929; + width: 250px; + border: 1px solid #BABABA; + background-color: #ddd; + padding-left: 10px; + padding-right: 10px; + margin-left: 10px; + margin-bottom: 1em; + -o-border-radius: 10px; + -moz-border-radius: 12px; + -webkit-border-radius: 10px; + -webkit-box-shadow: 0px 3px 7px #adadad; + border-radius: 10px; + -moz-box-sizing: border-box; + -opera-sizing: border-box; + -webkit-box-sizing: border-box; + -khtml-box-sizing: border-box; + box-sizing: border-box; + overflow: hidden; +}
\ No newline at end of file diff --git a/BKUOnline/src/main/webapp/index.html b/BKUOnline/src/main/webapp/index.html index 94e2890f..653da5b1 100644 --- a/BKUOnline/src/main/webapp/index.html +++ b/BKUOnline/src/main/webapp/index.html @@ -16,44 +16,21 @@ --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> -<head> -<title>BKU Online</title> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> -</head> -<body> -<style type="text/css"> - .box { - margin-top: 10px; - color: #292929; - width: 300px; - border: 1px solid #BABABA; - background-color: #ddd; - padding-left: 10px; - padding-right: 10px; - margin-left: 10px; - margin-bottom: 1em; - -o-border-radius: 10px; - -moz-border-radius: 12px; - -webkit-border-radius: 10px; - -webkit-box-shadow: 0px 3px 7px #adadad; - border-radius: 10px; - -moz-box-sizing: border-box; - -opera-sizing: border-box; - -webkit-box-sizing: border-box; - -khtml-box-sizing: border-box; - box-sizing: border-box; - overflow: hidden; - } -</style> -<div id="animDiv" class="box"> -<p> -<h1>TestRequest</h1> -<a href="slRequestForm.html">Security Layer Request</a> -<h1>STAL Service</h1> -<a href="stal">STAL Service Endpoint Information</a> -</p> -</div> - - -</body> + <head> + <title>BKU Online</title> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <style type="text/css" media="all">@import "css/main.css";</style> + </head> + <body> + <div id="animDiv" class="box"> + <p> + <h1>SL Request</h1> + <a href="SLRequestForm.html">Security Layer Request</a> + <h1>PIN Management</h1> + <a href="PINManagement.jsp">PIN Management Applet</a> + <h1>STAL Service</h1> + <a href="stal">STAL Service Endpoint</a> + </p> + </div> + </body> </html> diff --git a/STAL/src/main/java/at/gv/egiz/stal/STAL.java b/STAL/src/main/java/at/gv/egiz/stal/STAL.java index 7015ec29..a88d8f89 100644 --- a/STAL/src/main/java/at/gv/egiz/stal/STAL.java +++ b/STAL/src/main/java/at/gv/egiz/stal/STAL.java @@ -39,5 +39,5 @@ public interface STAL { * If the locale is not set the default locale will be used. * @param locale must not be null. */ - public void setLocale(Locale locale); +// public void setLocale(Locale locale); }
\ No newline at end of file diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java index 5b061850..144416ed 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java @@ -216,7 +216,7 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager { bindingProcessor.init(stal, commandInvokerClass.newInstance()); if (locale != null) { bindingProcessor.setLocale(locale); - stal.setLocale(locale); +// stal.setLocale(locale); } return bindingProcessor; } diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractBKUWorker.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractBKUWorker.java index b6c5a8ca..23b71690 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractBKUWorker.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractBKUWorker.java @@ -54,7 +54,7 @@ public abstract class AbstractBKUWorker extends AbstractSMCCSTAL implements Acti throw new NullPointerException("No BKU GUI provided"); } this.gui = gui; - this.locale = gui.getLocale(); +// this.locale = gui.getLocale(); addRequestHandler(QuitRequest.class, this); } @@ -149,7 +149,7 @@ public abstract class AbstractBKUWorker extends AbstractSMCCSTAL implements Acti } break; case SMCCHelper.CARD_FOUND: - signatureCard = smccHelper.getSignatureCard(locale); + signatureCard = smccHelper.getSignatureCard(gui.getLocale()); return false; } smccHelper.update(3000); diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java index 0074860f..3691156e 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Locale; +//import java.util.Locale; import java.util.Map; import java.util.Set; @@ -41,7 +41,7 @@ public abstract class AbstractSMCCSTAL implements STAL { public final static int DEFAULT_MAX_RETRIES = 1; - protected Locale locale = Locale.getDefault(); +// protected Locale locale = Locale.getDefault(); protected SignatureCard signatureCard = null; protected Map<String, SMCCSTALRequestHandler> handlerMap = new HashMap<String, SMCCSTALRequestHandler>(); @@ -159,13 +159,13 @@ public abstract class AbstractSMCCSTAL implements STAL { return handlerMap.get(request.getSimpleName()); } - @Override - public void setLocale(Locale locale) { - if (locale == null) { - throw new NullPointerException("Locale must not be set to null"); - } - this.locale = locale; - } +// @Override +// public void setLocale(Locale locale) { +// if (locale == null) { +// throw new NullPointerException("Locale must not be set to null"); +// } +// this.locale = locale; +// } public void setMaxRetries(int maxRetries) { this.maxRetries = maxRetries; |