summaryrefslogtreecommitdiff
path: root/BKUGuiExt/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'BKUGuiExt/src/main')
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java251
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUIFacade.java34
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java73
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ComparePinDocument.java102
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ExtendedPinDocument.java108
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java761
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java129
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINSpecRenderer.java39
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINStatusRenderer.java61
-rw-r--r--BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINStatusTableModel.java58
-rw-r--r--BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties83
-rw-r--r--BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages_en.properties82
12 files changed, 1781 insertions, 0 deletions
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java
new file mode 100644
index 00000000..37f30340
--- /dev/null
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUI.java
@@ -0,0 +1,251 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.bku.gui.viewer.FontProvider;
+import java.awt.Container;
+import java.awt.Cursor;
+import java.awt.event.ActionListener;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.Locale;
+import javax.swing.GroupLayout;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JProgressBar;
+import javax.swing.LayoutStyle;
+import javax.swing.SwingUtilities;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class ActivationGUI extends CardMgmtGUI implements ActivationGUIFacade {
+
+ public static final String TITLE_ACTIVATION = "title.activation";
+ public static final String LABEL_ACTIVATION = "label.activation";
+ public static final String LABEL_ACTIVATION_STEP = "label.activation.step";
+ public static final String LABEL_ACTIVATION_IDLE = "label.activation.idle";
+
+ public static final String HELP_ACTIVATION = "help.activation";
+
+ protected JProgressBar progressBar;
+
+ public ActivationGUI(Container contentPane,
+ Locale locale,
+ Style guiStyle,
+ URL backgroundImgURL,
+ FontProvider fontProvider,
+ AbstractHelpListener helpListener,
+ SwitchFocusListener switchFocusListener) {
+ super(contentPane, locale, guiStyle, backgroundImgURL, fontProvider, helpListener, switchFocusListener);
+
+ progressBar = new JProgressBar();
+ }
+
+ @Override
+ public void showActivationProgressDialog(final int currentStep, final int maxProgress, final ActionListener cancelListener, final String cancelCommand) {
+
+ log.debug("scheduling activation progress dialog (step " + currentStep + ")");
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+
+ log.debug("show activation progress dialog (step " + currentStep + ")");
+
+ mainPanel.removeAll();
+ buttonPanel.removeAll();
+
+ mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+
+ JLabel infoLabel = new JLabel();
+ infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+
+ if (renderHeaderPanel) {
+ titleLabel.setText(cardmgmtMessages.getString(TITLE_ACTIVATION));
+ infoLabel.setText(cardmgmtMessages.getString(LABEL_ACTIVATION));
+ } else {
+ infoLabel.setText(cardmgmtMessages.getString(TITLE_ACTIVATION));
+ }
+
+ helpMouseListener.setHelpTopic(HELP_ACTIVATION);
+
+ progressBar.setIndeterminate(false);
+ progressBar.setStringPainted(true);
+ progressBar.setString(null); //reset to percentage
+ progressBar.setMinimum(0);
+ progressBar.setMaximum(maxProgress);
+
+ JLabel stepLabel = new JLabel();
+ stepLabel.setFont(stepLabel.getFont().deriveFont(stepLabel.getFont().getStyle() & ~java.awt.Font.BOLD, stepLabel.getFont().getSize()-2));
+ String stepPattern = cardmgmtMessages.getString(LABEL_ACTIVATION_STEP);
+ stepLabel.setText(MessageFormat.format(stepPattern, new Object[]{ currentStep }));
+
+ GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
+ mainPanel.setLayout(mainPanelLayout);
+
+ GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup().addComponent(infoLabel);
+ GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(infoLabel);
+
+ if (!renderHeaderPanel) {
+ infoHorizontal.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE).addComponent(helpLabel);
+ infoVertical.addComponent(helpLabel);
+ }
+
+ mainPanelLayout.setHorizontalGroup(
+ mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(infoHorizontal)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(stepLabel)
+ .addComponent(progressBar)));
+
+ mainPanelLayout.setVerticalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addGroup(infoVertical)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createSequentialGroup()
+ .addComponent(stepLabel)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(progressBar)));
+
+ JButton cancelButton = new JButton();
+ cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD));
+ cancelButton.setText(messages.getString(BUTTON_CANCEL));
+ cancelButton.addActionListener(cancelListener);
+ cancelButton.setActionCommand(cancelCommand);
+
+ GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
+ buttonPanel.setLayout(buttonPanelLayout);
+
+ buttonPanelLayout.setHorizontalGroup(
+ buttonPanelLayout.createSequentialGroup()
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE));
+ buttonPanelLayout.setVerticalGroup(
+ buttonPanelLayout.createSequentialGroup()
+ .addComponent(cancelButton));
+
+ contentPanel.validate();
+
+ }
+ });
+
+ }
+
+ @Override
+ public void incrementProgress() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ progressBar.setValue(progressBar.getValue() + 1);
+ }
+ });
+
+ }
+
+ @Override
+ public void showIdleDialog(final ActionListener cancelListener, final String cancelCommand) {
+ log.debug("scheduling idle dialog");
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+
+ log.debug("show idle dialog");
+
+ mainPanel.removeAll();
+ buttonPanel.removeAll();
+
+ mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+
+ JLabel infoLabel = new JLabel();
+ infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+
+ if (renderHeaderPanel) {
+ titleLabel.setText(cardmgmtMessages.getString(TITLE_ACTIVATION));
+ infoLabel.setText(cardmgmtMessages.getString(LABEL_ACTIVATION));
+ } else {
+ infoLabel.setText(cardmgmtMessages.getString(TITLE_ACTIVATION));
+ }
+
+ helpMouseListener.setHelpTopic(HELP_ACTIVATION);
+
+ progressBar.setIndeterminate(true);
+ progressBar.setStringPainted(true);
+ progressBar.setString(""); //not string painted progressbar is smaller
+
+ JLabel stepLabel = new JLabel();
+ stepLabel.setFont(stepLabel.getFont().deriveFont(stepLabel.getFont().getStyle() & ~java.awt.Font.BOLD, stepLabel.getFont().getSize()-2));
+ stepLabel.setText(cardmgmtMessages.getString(LABEL_ACTIVATION_IDLE));
+
+ GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
+ mainPanel.setLayout(mainPanelLayout);
+
+ GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup().addComponent(infoLabel);
+ GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(infoLabel);
+
+ if (!renderHeaderPanel) {
+ infoHorizontal.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE).addComponent(helpLabel);
+ infoVertical.addComponent(helpLabel);
+ }
+
+ mainPanelLayout.setHorizontalGroup(
+ mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(infoHorizontal)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(stepLabel)
+ .addComponent(progressBar)));
+
+ mainPanelLayout.setVerticalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addGroup(infoVertical)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createSequentialGroup()
+ .addComponent(stepLabel)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(progressBar)));
+
+ JButton cancelButton = new JButton();
+ cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD));
+ cancelButton.setText(messages.getString(BUTTON_CANCEL));
+ cancelButton.addActionListener(cancelListener);
+ cancelButton.setActionCommand(cancelCommand);
+
+ GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
+ buttonPanel.setLayout(buttonPanelLayout);
+
+ buttonPanelLayout.setHorizontalGroup(
+ buttonPanelLayout.createSequentialGroup()
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE));
+ buttonPanelLayout.setVerticalGroup(
+ buttonPanelLayout.createSequentialGroup()
+ .addComponent(cancelButton));
+
+ contentPanel.validate();
+
+ }
+ });
+
+ }
+}
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUIFacade.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUIFacade.java
new file mode 100644
index 00000000..3fc14d04
--- /dev/null
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ActivationGUIFacade.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.bku.gui.*;
+import java.awt.event.ActionListener;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public interface ActivationGUIFacade extends BKUGUIFacade {
+
+ public void showActivationProgressDialog(int currentStep, int maxProgress, ActionListener cancelListener, String cancelCommand);
+
+ public void incrementProgress();
+
+ public void showIdleDialog(ActionListener cancelListener, String cancelCommand);
+
+}
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java
new file mode 100644
index 00000000..98f44d55
--- /dev/null
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/CardMgmtGUI.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.bku.gui.viewer.FontProvider;
+import java.awt.Container;
+import java.net.URL;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * Common superclass for Activation and PinManagement GUIs
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class CardMgmtGUI extends BKUGUIImpl {
+
+ public static final String CARDMGMT_MESSAGES_BUNDLE = "at/gv/egiz/bku/gui/ActivationMessages";
+
+ protected ResourceBundle cardmgmtMessages;
+
+ public CardMgmtGUI(Container contentPane,
+ Locale locale,
+ Style guiStyle,
+ URL backgroundImgURL,
+ FontProvider fontProvider,
+ AbstractHelpListener helpListener,
+ SwitchFocusListener switchFocusListener) {
+ super(contentPane, locale, guiStyle, backgroundImgURL, fontProvider, helpListener, switchFocusListener);
+
+ }
+
+ @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());
+ cardmgmtMessages = ResourceBundle.getBundle(CARDMGMT_MESSAGES_BUNDLE, lang);
+ } 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/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ComparePinDocument.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ComparePinDocument.java
new file mode 100644
index 00000000..623f6fad
--- /dev/null
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ComparePinDocument.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.gui;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.swing.JButton;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import javax.swing.text.PlainDocument;
+
+/**
+ * Checks if the pin confirmation (compareTo) corresponds to this pin.
+ * Additionally, checks if currentPIN (optional) meets the requirements before enabling the OK button.
+ * @author clemens
+ */
+class ComparePinDocument extends PlainDocument {
+
+ private static final long serialVersionUID = 1L;
+ protected Pattern pinPattern;
+ protected int minLength;
+ protected int maxLength;
+ protected JButton enterButton;
+ protected Document compareTo;
+ protected Document currentPIN;
+
+ /**
+ * Constructor without compareTo Document parameter (allow null and set later to avoid cyclic dependencies)
+ */
+ public ComparePinDocument(int minLength, int maxLength, String pattern, JButton enterButton) {
+ if (enterButton == null) {
+ throw new NullPointerException("OK button null");
+ }
+ if (pattern != null) {
+ pinPattern = Pattern.compile(pattern);
+ } else {
+ pinPattern = Pattern.compile(".");
+ }
+ this.minLength = minLength;
+ this.maxLength = maxLength;
+ this.enterButton = enterButton;
+ }
+
+ /**
+ * @param compareTo should not be null (allow null and set later to avoid cyclic dependencies)
+ */
+ public ComparePinDocument(int minLength, int maxLength, String pattern,
+ JButton enterButton, Document compareTo) {
+ this(minLength, maxLength, pattern, enterButton);
+ this.compareTo = compareTo;
+ }
+
+ public ComparePinDocument(int minLength, int maxLength, String pattern,
+ JButton enterButton, Document compareTo, Document currentPIN) {
+ this(minLength, maxLength, pattern, enterButton, compareTo);
+ this.currentPIN = currentPIN;
+ }
+
+ @Override
+ public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
+ if (maxLength < 0 || maxLength >= (getLength() + str.length())) {
+ boolean matches = true;
+ for (int i = 0; i < str.length(); i++) {
+ Matcher m = pinPattern.matcher(str.substring(i, i + 1));
+ if (!m.matches()) {
+ matches = false;
+ }
+ }
+ if (matches) {
+ super.insertString(offs, str, a);
+ enterButton.setEnabled(
+ getLength() >= minLength
+ && (currentPIN == null || currentPIN.getLength() >= minLength)
+ && compareTo.getText(0, compareTo.getLength()).equals(getText(0, getLength())));
+ }
+ }
+ }
+
+ @Override
+ public void remove(int offs, int len) throws BadLocationException {
+ super.remove(offs, len);
+ enterButton.setEnabled(
+ getLength() >= minLength
+ && (currentPIN == null || currentPIN.getLength() >= minLength)
+ && compareTo.getText(0, compareTo.getLength()).equals(getText(0, getLength())));
+ }
+}
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ExtendedPinDocument.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ExtendedPinDocument.java
new file mode 100644
index 00000000..3a0d7a66
--- /dev/null
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/ExtendedPinDocument.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.gui;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.swing.JButton;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import javax.swing.text.PlainDocument;
+
+/**
+ * This PINDocument also checks if the additional (optional) pinDocuments also meet the requirements
+ * to enable the OK button.
+ * Checks if (optional) newPIN and confirmPIN correspond
+ *
+ * @author clemens
+ */
+class ExtendedPinDocument extends PlainDocument {
+
+ private static final long serialVersionUID = 1L;
+ protected Pattern pinPattern;
+ protected int minLength;
+ protected int maxLength;
+ protected JButton enterButton;
+ protected Document newPIN;
+ protected Document confirmPIN;
+
+ public ExtendedPinDocument(int minLength, int maxLength, String pattern, JButton enterButton) {
+ if (enterButton == null) {
+ throw new NullPointerException("OK Button null");
+ }
+ if (pattern != null) {
+ pinPattern = Pattern.compile(pattern);
+ } else {
+ pinPattern = Pattern.compile(".");
+ }
+ this.minLength = minLength;
+ this.maxLength = maxLength;
+ this.enterButton = enterButton;
+ }
+
+ /**
+ * @param pinSpec
+ * @param enterButton
+ * @param newPIN, confirmPIN
+ */
+ public ExtendedPinDocument(int minLength, int maxLength, String pattern, JButton enterButton, Document newPIN, Document confirmPIN) {
+ this(minLength, maxLength, pattern, enterButton);
+ this.newPIN = newPIN;
+ this.confirmPIN = confirmPIN;
+ }
+
+ @Override
+ public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
+ if (maxLength < 0 || maxLength >= (getLength() + str.length())) {
+ boolean matches = true;
+ for (int i = 0; i < str.length(); i++) {
+ Matcher m = pinPattern.matcher(str.substring(i, i + 1));
+ if (!m.matches()) {
+ matches = false;
+ }
+ }
+ if (matches) {
+ super.insertString(offs, str, a);
+ enterButton.setEnabled(
+ getLength() >= minLength
+ && (newPIN == null || newPIN.getLength() >= minLength)
+ && (confirmPIN == null || compare()));
+ }
+ }
+ }
+
+ @Override
+ public void remove(int offs, int len) throws BadLocationException {
+ super.remove(offs, len);
+ enterButton.setEnabled(
+ getLength() >= minLength
+ && (newPIN == null || newPIN.getLength() >= minLength)
+ && (confirmPIN == null || compare()));
+ }
+
+ /**
+ * assume confirmPIN != null
+ * @return
+ */
+ private boolean compare() throws BadLocationException {
+ if (newPIN != null) {
+ return confirmPIN.getText(0, confirmPIN.getLength()).equals(newPIN.getText(0, newPIN.getLength()));
+ }
+ return false;
+ }
+}
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java
new file mode 100644
index 00000000..4dcc388f
--- /dev/null
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java
@@ -0,0 +1,761 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.bku.gui.viewer.FontProvider;
+import at.gv.egiz.smcc.PINSpec;
+import java.awt.Container;
+import java.awt.Cursor;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.Map;
+import javax.swing.GroupLayout;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPasswordField;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.LayoutStyle;
+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 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 */
+ protected PINSpec pinSpec;
+
+ public PINManagementGUI(Container contentPane,
+ Locale locale,
+ Style guiStyle,
+ URL backgroundImgURL,
+ FontProvider fontProvider,
+ AbstractHelpListener helpListener,
+ SwitchFocusListener switchFocusListener) {
+ super(contentPane, locale, guiStyle, backgroundImgURL, fontProvider, helpListener, switchFocusListener);
+ }
+
+ @Override
+ public char[] getOldPin() {
+ if (oldPinField != null) {
+ char[] pin = oldPinField.getPassword();
+ oldPinField = null;
+ return pin;
+ }
+ return null;
+ }
+
+ @Override
+ public PINSpec getSelectedPINSpec() {
+ return pinSpec;
+ }
+
+ @Override
+ public void showPINManagementDialog(final Map<PINSpec, STATUS> pins,
+ final ActionListener activateListener,
+ final String activateCmd,
+ final String changeCmd,
+ final String unblockCmd,
+ final String verifyCmd,
+ final ActionListener cancelListener,
+ final String cancelCmd) {
+
+ log.debug("scheduling PIN managment dialog");
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ log.debug("show PIN management dialog");
+
+ mainPanel.removeAll();
+ buttonPanel.removeAll();
+
+ helpMouseListener.setHelpTopic(HELP_PINMGMT);
+ helpKeyListener.setHelpTopic(HELP_PINMGMT);
+
+
+ JLabel mgmtLabel = new JLabel();
+ mgmtLabel.setFont(mgmtLabel.getFont().deriveFont(mgmtLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+
+ if (renderHeaderPanel) {
+ titleLabel.setText(getMessage(TITLE_PINMGMT));
+ String infoPattern = getMessage(MESSAGE_PINMGMT);
+ mgmtLabel.setText(MessageFormat.format(infoPattern, pins.size()));
+ } else {
+ mgmtLabel.setText(getMessage(TITLE_PINMGMT));
+ }
+
+ final PINStatusTableModel tableModel = new PINStatusTableModel(pins);
+ final JTable pinStatusTable = new JTable(tableModel);
+ pinStatusTable.setDefaultRenderer(PINSpec.class, new PINSpecRenderer());
+ pinStatusTable.setDefaultRenderer(STATUS.class, new PINStatusRenderer(cardmgmtMessages));
+ pinStatusTable.setTableHeader(null);
+ pinStatusTable.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+// pinStatusTable.addMouseMotionListener(new MouseMotionAdapter() {
+//
+// @Override
+// public void mouseMoved(MouseEvent e) {
+// if (pinStatusTable.columnAtPoint(e.getPoint()) == 0) {
+// pinStatusTable.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+// } else {
+// pinStatusTable.setCursor(Cursor.getDefaultCursor());
+// }
+// }
+// });
+
+ final JButton activateButton = new JButton();
+ activateButton.setFont(activateButton.getFont().deriveFont(activateButton.getFont().getStyle() & ~java.awt.Font.BOLD));
+ activateButton.addActionListener(activateListener);
+
+ pinStatusTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ pinStatusTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+
+ @Override
+ public void valueChanged(final ListSelectionEvent e) {
+ //invoke later to allow thread to paint selection background
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ ListSelectionModel lsm = (ListSelectionModel) e.getSource();
+ int selectionIdx = lsm.getMinSelectionIndex();
+ if (selectionIdx >= 0) {
+ pinSpec = (PINSpec) tableModel.getValueAt(selectionIdx, 0);
+ STATUS status = (STATUS) tableModel.getValueAt(selectionIdx, 1);
+
+ if (status == STATUS.NOT_ACTIV) {
+ activateButton.setText(getMessage(BUTTON_ACTIVATE));
+ activateButton.setEnabled(true);
+ activateButton.setActionCommand(activateCmd);
+ } else if (status == STATUS.BLOCKED) {
+ activateButton.setText(getMessage(BUTTON_UNBLOCK));
+ activateButton.setEnabled(true);
+ activateButton.setActionCommand(unblockCmd);
+ } else if (status == STATUS.ACTIV) {
+ activateButton.setText(getMessage(BUTTON_CHANGE));
+ activateButton.setEnabled(true);
+ activateButton.setActionCommand(changeCmd);
+ } else if (status == STATUS.UNKNOWN) {
+ activateButton.setText(getMessage(BUTTON_VERIFY));
+ activateButton.setEnabled(true);
+ activateButton.setActionCommand(verifyCmd);
+ }
+ }
+ }
+ });
+ }
+ });
+
+ //select first entry
+ pinStatusTable.getSelectionModel().setSelectionInterval(0, 0);
+
+ JScrollPane pinStatusScrollPane = new JScrollPane(pinStatusTable);
+
+ GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
+ mainPanel.setLayout(mainPanelLayout);
+
+ GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup()
+ .addComponent(mgmtLabel);
+ GroupLayout.Group messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(mgmtLabel);
+ if (!renderHeaderPanel) {
+ messageHorizontal
+ .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE)
+ .addComponent(switchFocusDummyLabel)
+ .addComponent(helpLabel);
+ messageVertical
+ .addComponent(switchFocusDummyLabel)
+ .addComponent(helpLabel);
+ }
+
+ mainPanelLayout.setHorizontalGroup(
+ mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(messageHorizontal)
+ .addComponent(pinStatusScrollPane, 0, 0, Short.MAX_VALUE));
+
+ mainPanelLayout.setVerticalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addGroup(messageVertical)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(pinStatusScrollPane, 0, 0, pinStatusTable.getPreferredSize().height+3));
+
+ JButton cancelButton = new JButton();
+ cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD));
+ cancelButton.setText(getMessage(BUTTON_CLOSE));
+ cancelButton.setActionCommand(cancelCmd);
+ cancelButton.addActionListener(cancelListener);
+
+ GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
+ buttonPanel.setLayout(buttonPanelLayout);
+
+ GroupLayout.SequentialGroup buttonHorizontal = buttonPanelLayout.createSequentialGroup()
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(activateButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE);
+
+ GroupLayout.Group buttonVertical = buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(activateButton)
+ .addComponent(cancelButton);
+
+ buttonPanelLayout.setHorizontalGroup(buttonHorizontal);
+ buttonPanelLayout.setVerticalGroup(buttonVertical);
+
+ helpLabel.requestFocus();
+ contentPanel.validate();
+ }
+ });
+ }
+
+ @Override
+ public void showModifyPINDirect(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();
+ }
+ params[1] = pinSpec.getLocalizedLength();
+ if (type == DIALOG.CHANGE) {
+ log.debug("show change pin dialog");
+ title = TITLE_CHANGE_PIN;
+ msg = MESSAGE_CHANGE_PINPAD_DIREKT;
+ } else if (type == DIALOG.ACTIVATE) {
+ log.debug("show activate pin dialog");
+ title = TITLE_ACTIVATE_PIN;
+ msg = MESSAGE_ACTIVATE_PINPAD_DIREKT;
+ } else if (type == DIALOG.VERIFY) {
+ log.debug("show verify pin dialog");
+ title = TITLE_VERIFY_PINPAD;
+ msg = MESSAGE_ENTERPIN_PINPAD_DIRECT;
+ } else {
+ log.debug("show unblock pin dialog");
+ title = TITLE_UNBLOCK_PIN;
+ msg = MESSAGE_UNBLOCK_PINPAD_DIREKT;
+ }
+
+ } 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);
+ }
+
+ @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);
+ }
+
+
+ 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, MESSAGE_MGMT_PARAM;
+ HELP_TOPIC = HELP_PINMGMT;
+
+ 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_ENTERPIN;
+ } 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 retry pin dialog");
+ TITLE = TITLE_RETRY;
+ MESSAGE_MGMT = (retries < 2) ?
+ MESSAGE_LAST_RETRY : MESSAGE_RETRIES;
+ MESSAGE_MGMT_PARAM = String.valueOf(retries);
+ }
+
+ mainPanel.removeAll();
+ buttonPanel.removeAll();
+
+ helpMouseListener.setHelpTopic(HELP_TOPIC);
+ helpKeyListener.setHelpTopic(HELP_TOPIC);
+
+ JLabel mgmtLabel = new JLabel();
+ 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);
+ helpMouseListener.setHelpTopic(HELP_RETRY);
+ helpKeyListener.setHelpTopic(HELP_RETRY);
+ }
+
+ if (renderHeaderPanel) {
+ titleLabel.setText(getMessage(TITLE));
+ String mgmtPattern = getMessage(MESSAGE_MGMT);
+ mgmtLabel.setText(MessageFormat.format(mgmtPattern, MESSAGE_MGMT_PARAM));
+ } else {
+ mgmtLabel.setText(getMessage(TITLE));
+ }
+
+ ////////////////////////////////////////////////////////////////
+ // 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(switchFocusDummyLabel)
+ .addComponent(helpLabel);
+ infoVertical
+ .addComponent(switchFocusDummyLabel)
+ .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_ENTERPIN_PINPAD);
+ pinpadLabel.setText(MessageFormat.format(pinpadPattern,
+ new Object[] { pinSpec.getLocalizedName(), pinSpec.getLocalizedLength() }));
+
+ pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(pinpadLabel);
+ pinVertical = mainPanelLayout.createSequentialGroup()
+ .addComponent(pinpadLabel);
+ } else {
+
+ final JButton okButton = new JButton();
+ okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~Font.BOLD));
+ okButton.setText(getMessage(BUTTON_OK));
+ okButton.setEnabled(pinSpec.getMinLength() <= 0);
+ okButton.setActionCommand(okCommand);
+ okButton.addActionListener(okListener);
+
+ JLabel oldPinLabel = null;
+ JLabel repeatPinLabel = null;
+ JLabel pinLabel = new JLabel();
+ pinLabel.setFont(pinLabel.getFont().deriveFont(pinLabel.getFont().getStyle() & ~Font.BOLD));
+ String pinLabelPattern = (type == DIALOG.CHANGE || type == DIALOG.UNBLOCK) ? getMessage(LABEL_NEW_PIN) : getMessage(LABEL_PIN);
+ pinLabel.setText(MessageFormat.format(pinLabelPattern, new Object[]{pinSpec.getLocalizedName()}));
+
+ final JPasswordField repeatPinField = new JPasswordField();
+ pinField = new JPasswordField();
+ pinField.setText("");
+ pinField.setActionCommand(okCommand);
+ pinField.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (pinField.getPassword().length >= pinSpec.getMinLength()) {
+ if (type == DIALOG.VERIFY) {
+ okListener.actionPerformed(e);
+ } else {
+ repeatPinField.requestFocusInWindow();
+ }
+ }
+ }
+ });
+
+ if (type != DIALOG.VERIFY) {
+ repeatPinLabel = new JLabel();
+ repeatPinLabel.setFont(pinLabel.getFont());
+ String repeatPinLabelPattern = getMessage(LABEL_REPEAT_PIN);
+ repeatPinLabel.setText(MessageFormat.format(repeatPinLabelPattern, new Object[]{pinSpec.getLocalizedName()}));
+
+ repeatPinField.setText("");
+ repeatPinField.setActionCommand(okCommand);
+ repeatPinField.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (okButton.isEnabled()) {
+ okListener.actionPerformed(e);
+ }
+ }
+ });
+
+ if (type == DIALOG.CHANGE || type == DIALOG.UNBLOCK) {
+ oldPinLabel = new JLabel();
+ oldPinLabel.setFont(oldPinLabel.getFont().deriveFont(oldPinLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+ String oldPinLabelPattern = getMessage((type == DIALOG.CHANGE) ? LABEL_OLD_PIN : LABEL_PUK);
+ oldPinLabel.setText(MessageFormat.format(oldPinLabelPattern, new Object[]{pinSpec.getLocalizedName()}));
+
+ oldPinField = new JPasswordField();
+ oldPinField.setText("");
+ oldPinField.setActionCommand(okCommand);
+ oldPinField.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (oldPinField.getPassword().length >= pinSpec.getMinLength()) {
+ pinField.requestFocusInWindow();
+ }
+ }
+ });
+
+ ExtendedPinDocument oldPinDocument =
+ new ExtendedPinDocument(pinSpec.getMinLength(), pinSpec.getMaxLength(),
+ pinSpec.getRexepPattern(), okButton);
+ ComparePinDocument newPinDocument =
+ new ComparePinDocument(pinSpec.getRecMinLength(), pinSpec.getRecMaxLength(), pinSpec.getRexepPattern(),
+ okButton);
+ ComparePinDocument confirmPinDocument =
+ new ComparePinDocument(pinSpec.getRecMinLength(), pinSpec.getRecMaxLength(), pinSpec.getRexepPattern(),
+ okButton);
+
+ oldPinDocument.newPIN = newPinDocument;
+ oldPinDocument.confirmPIN = confirmPinDocument;
+
+ newPinDocument.compareTo = confirmPinDocument;
+ newPinDocument.currentPIN = oldPinDocument;
+ confirmPinDocument.compareTo = newPinDocument;
+ confirmPinDocument.currentPIN = oldPinDocument;
+
+ oldPinField.setDocument(oldPinDocument);
+ pinField.setDocument(newPinDocument);
+ repeatPinField.setDocument(confirmPinDocument);
+
+ } else {
+ // else -> ACTIVATE (not verify, not change)
+ ComparePinDocument newPinDocument =
+ new ComparePinDocument(pinSpec.getRecMinLength(), pinSpec.getRecMaxLength(), pinSpec.getRexepPattern(),
+ okButton);
+ ComparePinDocument confirmPinDocument =
+ new ComparePinDocument(pinSpec.getRecMinLength(), pinSpec.getRecMaxLength(), pinSpec.getRexepPattern(),
+ okButton);
+
+ newPinDocument.compareTo = confirmPinDocument;
+ confirmPinDocument.compareTo = newPinDocument;
+
+ pinField.setDocument(newPinDocument);
+ repeatPinField.setDocument(confirmPinDocument);
+ }
+ } else {
+ // VERIFY
+ pinField.setDocument(
+ new PINDocument(pinSpec.getMinLength(), pinSpec.getMaxLength(), pinSpec.getRexepPattern(), okButton));
+ }
+
+ JLabel pinsizeLabel = new JLabel();
+ pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~Font.BOLD, pinsizeLabel.getFont().getSize()-2));
+ String pinsizePattern = getMessage(LABEL_PINSIZE);
+ pinsizeLabel.setText(MessageFormat.format(pinsizePattern, pinSpec.getLocalizedLength()));
+
+ ////////////////////////////////////////////////////////////////
+ // NON-PINPAD SPECIFIC LAYOUT SECTION
+ ////////////////////////////////////////////////////////////////
+
+ pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING);
+ pinVertical = mainPanelLayout.createSequentialGroup();
+
+// if (pinLabelPos == PinLabelPosition.ABOVE) {
+// if (changePin) {
+// pinHorizontal
+// .addComponent(oldPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+// .addComponent(oldPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE);
+// pinVertical
+// .addComponent(oldPinLabel)
+// .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+// .addComponent(oldPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+// .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
+// }
+// pinHorizontal
+// .addComponent(pinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+// .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+// .addComponent(repeatPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+// .addComponent(repeatPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+// .addGroup(mainPanelLayout.createSequentialGroup()
+// .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE)
+// .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE));
+// pinVertical
+// .addComponent(pinLabel)
+// .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+// .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+// .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+// .addComponent(repeatPinLabel)
+// .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+// .addComponent(repeatPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+// .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+// .addComponent(pinsizeLabel);
+// } else {
+
+
+ if (type == DIALOG.CHANGE || type == DIALOG.UNBLOCK) {
+ pinHorizontal
+ .addGroup(mainPanelLayout.createSequentialGroup()
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(oldPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(pinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(repeatPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(oldPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(repeatPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
+
+ pinVertical
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(oldPinLabel)
+ .addComponent(oldPinField))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(pinLabel)
+ .addComponent(pinField))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(repeatPinLabel)
+ .addComponent(repeatPinField))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
+ } else if (type == DIALOG.ACTIVATE) {
+ pinHorizontal
+ .addGroup(mainPanelLayout.createSequentialGroup()
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(pinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(repeatPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(repeatPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
+
+ pinVertical
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(pinLabel)
+ .addComponent(pinField))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(repeatPinLabel)
+ .addComponent(repeatPinField))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
+ } else { // VERIFY
+ pinHorizontal
+ .addGroup(mainPanelLayout.createSequentialGroup()
+ .addComponent(pinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
+
+ pinVertical
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(pinLabel)
+ .addComponent(pinField))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
+ }
+ pinHorizontal
+ .addGroup(mainPanelLayout.createSequentialGroup()
+ .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE)
+ .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)
+ .addGroup(infoHorizontal)
+ .addGroup(pinHorizontal));
+
+ mainPanelLayout.setVerticalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addGroup(infoVertical)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(pinVertical));
+
+ helpLabel.requestFocus();
+ contentPanel.validate();
+
+ }
+ });
+ }
+
+ @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;
+ }
+
+ @Override
+ public void showEnterCurrentPIN(DIALOG type, PINSpec pinSpec, int retries) {
+ String title, message;
+// Object[] params = null;
+
+ if (type == PINManagementGUIFacade.DIALOG.VERIFY) {
+ title = PINManagementGUIFacade.TITLE_VERIFY_PINPAD;
+ message = BKUGUIFacade.MESSAGE_ENTERPIN_PINPAD;
+// params = new Object[]{pinSpec.getLocalizedName(), pinSpec.getLocalizedLength()};
+ } else if (type == PINManagementGUIFacade.DIALOG.ACTIVATE) {
+ title = PINManagementGUIFacade.TITLE_ACTIVATE_PIN;
+ message = PINManagementGUIFacade.MESSAGE_ACTIVATE_PINPAD_CURRENT;
+// params = new Object[]{pinSpec.getLocalizedName(), pinSpec.getLocalizedLength()};
+ } else if (type == PINManagementGUIFacade.DIALOG.CHANGE) {
+ title = PINManagementGUIFacade.TITLE_CHANGE_PIN;
+ message = PINManagementGUIFacade.MESSAGE_CHANGE_PINPAD_CURRENT;
+// params = new Object[]{pinSpec.getLocalizedName(), pinSpec.getLocalizedLength()};
+ } else { //if (type == DIALOG.UNBLOCK) {
+ title = PINManagementGUIFacade.TITLE_UNBLOCK_PIN;
+ message = PINManagementGUIFacade.MESSAGE_UNBLOCK_PINPAD_CURRENT;
+// params = new Object[]{pinSpec.getLocalizedName(), pinSpec.getLocalizedLength()};
+ }
+ showEnterPIN(pinSpec, retries, title, message, null);
+ }
+
+ @Override
+ public void showEnterNewPIN(DIALOG type, PINSpec pinSpec) {
+ String title, message;
+ if (type == PINManagementGUIFacade.DIALOG.ACTIVATE) {
+ title = PINManagementGUIFacade.TITLE_ACTIVATE_PIN;
+ message = PINManagementGUIFacade.MESSAGE_ACTIVATE_PINPAD_NEW;
+ } else if (type == PINManagementGUIFacade.DIALOG.CHANGE) {
+ title = PINManagementGUIFacade.TITLE_CHANGE_PIN;
+ message = PINManagementGUIFacade.MESSAGE_CHANGE_PINPAD_NEW;
+ } else if (type == DIALOG.UNBLOCK) {
+ title = PINManagementGUIFacade.TITLE_UNBLOCK_PIN;
+ message = PINManagementGUIFacade.MESSAGE_UNBLOCK_PINPAD_NEW;
+ } else {
+ log.error("enterNewPIN not supported for dialog type " + type);
+ showErrorDialog(ERR_UNKNOWN, null);
+ return;
+ }
+ showEnterPIN(pinSpec, -1, title, message, null);
+ }
+
+ @Override
+ public void showConfirmNewPIN(DIALOG type, PINSpec pinSpec) {
+ String title, message;
+ if (type == PINManagementGUIFacade.DIALOG.ACTIVATE) {
+ title = PINManagementGUIFacade.TITLE_ACTIVATE_PIN;
+ message = PINManagementGUIFacade.MESSAGE_ACTIVATE_PINPAD_CONFIRM;
+ } else if (type == PINManagementGUIFacade.DIALOG.CHANGE) {
+ title = PINManagementGUIFacade.TITLE_CHANGE_PIN;
+ message = PINManagementGUIFacade.MESSAGE_CHANGE_PINPAD_CONFIRM;
+ } else if (type == DIALOG.UNBLOCK) {
+ title = PINManagementGUIFacade.TITLE_UNBLOCK_PIN;
+ message = PINManagementGUIFacade.MESSAGE_UNBLOCK_PINPAD_CONFIRM;
+ } else {
+ log.error("enterNewPIN not supported for dialog type " + type);
+ showErrorDialog(ERR_UNKNOWN, null);
+ return;
+ }
+ showEnterPIN(pinSpec, -1, title, message, null);
+ }
+
+}
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java
new file mode 100644
index 00000000..46ae18b9
--- /dev/null
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.smcc.PINSpec;
+import java.awt.event.ActionListener;
+import java.util.Map;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public interface PINManagementGUIFacade extends BKUGUIFacade {
+
+ public static final String HELP_PINMGMT = "help.pin.mgmt";
+// public static final String HELP_VERIFY_PIN = "help.pin.verify";
+ public static final String TITLE_PINMGMT = "title.pin.mgmt";
+ public static final String TITLE_ACTIVATE_PIN = "title.activate.pin";
+ public static final String TITLE_CHANGE_PIN = "title.change.pin";
+// public static final String TITLE_VERIFY_PIN = "title.verify.pin";
+ 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_UNBLOCK_SUCCESS = "title.unblock.success";
+ public static final String TITLE_CHANGE_SUCCESS = "title.change.success";
+
+ // 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_UNBLOCK_SUCCESS = "unblock.success";
+ public static final String MESSAGE_PINMGMT = "pin.mgmt";
+// public static final String MESSAGE_PINPAD = "pinpad";
+
+ public static final String MESSAGE_ACTIVATE_PIN = "activate.pin";
+ public static final String MESSAGE_CHANGE_PIN = "change.pin";
+ public static final String MESSAGE_UNBLOCK_PIN = "unblock.pin";
+
+ public static final String MESSAGE_ACTIVATE_PINPAD_CURRENT = "activate.pinpad.current";
+ public static final String MESSAGE_CHANGE_PINPAD_CURRENT = "change.pinpad.current";
+ public static final String MESSAGE_UNBLOCK_PINPAD_CURRENT = "unblock.pinpad.current";
+ public static final String MESSAGE_ACTIVATE_PINPAD_NEW = "activate.pinpad.new";
+ public static final String MESSAGE_CHANGE_PINPAD_NEW = "change.pinpad.new";
+ public static final String MESSAGE_UNBLOCK_PINPAD_NEW = "unblock.pinpad.new";
+ public static final String MESSAGE_ACTIVATE_PINPAD_CONFIRM = "activate.pinpad.confirm";
+ public static final String MESSAGE_CHANGE_PINPAD_CONFIRM = "change.pinpad.confirm";
+ public static final String MESSAGE_UNBLOCK_PINPAD_CONFIRM = "unblock.pinpad.confirm";
+
+ public static final String MESSAGE_ACTIVATE_PINPAD_DIREKT = "activate.pinpad.direct";
+ public static final String MESSAGE_CHANGE_PINPAD_DIREKT = "change.pinpad.direct";
+ public static final String MESSAGE_UNBLOCK_PINPAD_DIREKT = "unblock.pinpad.direct";
+
+ public static final String LABEL_OLD_PIN = "label.old.pin";
+ public static final String LABEL_PUK = "label.puk";
+ public static final String LABEL_NEW_PIN = "label.new.pin";
+ public static final String LABEL_REPEAT_PIN = "label.repeat.pin";
+
+ public static final String ERR_STATUS = "err.status";
+ 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_VERIFY = "err.verify";
+ public static final String ERR_RETRIES = "err.retries";
+ public static final String ERR_LOCKED = "err.locked";
+ public static final String ERR_NOT_ACTIVE = "err.not.active";
+ public static final String ERR_PIN_FORMAT = "err.pin.format";
+ public static final String ERR_PIN_CONFIRMATION = "err.pin.confirmation";
+ public static final String ERR_PIN_OPERATION_ABORTED = "err.pin.operation.aborted";
+ public static final String ERR_UNSUPPORTED_CARD = "err.unsupported.card";
+
+ public static final String BUTTON_ACTIVATE = "button.activate";
+ public static final String BUTTON_UNBLOCK = "button.unblock";
+ public static final String BUTTON_CHANGE = "button.change";
+ public static final String BUTTON_VERIFY = "button.verify";
+
+ public static final String STATUS_ACTIVE = "status.active";
+ public static final String STATUS_BLOCKED = "status.blocked";
+ public static final String STATUS_NOT_ACTIVE = "status.not.active";
+ public static final String STATUS_UNKNOWN = "status.unknown";
+
+ public enum STATUS { ACTIV, NOT_ACTIV, BLOCKED, UNKNOWN };
+ public enum DIALOG { VERIFY, ACTIVATE, CHANGE, UNBLOCK };
+
+ /**
+ * list pins
+ */
+ public void showPINManagementDialog(Map<PINSpec, STATUS> pins,
+ ActionListener activateListener, String activateCmd, String changeCmd, String unblockCmd, String verifyCmd,
+ ActionListener cancelListener, String cancelCmd);
+
+ /**
+ * "software" pin-entry dialog (activate, change, unblock, verify)
+ */
+ public void showPINDialog(DIALOG type, PINSpec pinSpec, int retries,
+ ActionListener okListener, String okCmd,
+ ActionListener cancelListener, String cancelCmd);
+
+ /**
+ * <b>direct</b> pinpad pin-entry dialog
+ */
+ public void showModifyPINDirect(DIALOG type, PINSpec pinSpec, int retries);
+
+ /**
+ * <b>start/finish</b> pinpad pin-entry dialog
+ */
+ public void showEnterCurrentPIN(DIALOG type, PINSpec pinSpec, int retries);
+
+ public void showEnterNewPIN(DIALOG type, PINSpec pinSpec);
+
+ public void showConfirmNewPIN(DIALOG type, PINSpec pinSpec);
+
+
+ public char[] getOldPin();
+
+ public PINSpec getSelectedPINSpec();
+}
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINSpecRenderer.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINSpecRenderer.java
new file mode 100644
index 00000000..e3d73e1f
--- /dev/null
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINSpecRenderer.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.smcc.PINSpec;
+import javax.swing.table.DefaultTableCellRenderer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class PINSpecRenderer extends DefaultTableCellRenderer {
+
+ private static final Log log = LogFactory.getLog(PINSpecRenderer.class);
+
+ @Override
+ protected void setValue(Object value) {
+ PINSpec pinSpec = (PINSpec) value;
+ super.setText(pinSpec.getLocalizedName());
+ }
+
+}
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINStatusRenderer.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINStatusRenderer.java
new file mode 100644
index 00000000..83ff74f2
--- /dev/null
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINStatusRenderer.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.bku.gui.PINManagementGUIFacade.STATUS;
+import java.awt.Color;
+import java.awt.Font;
+import java.util.ResourceBundle;
+import javax.swing.table.DefaultTableCellRenderer;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class PINStatusRenderer extends DefaultTableCellRenderer {
+
+// 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);
+ protected ResourceBundle messages;
+
+ public PINStatusRenderer(ResourceBundle messages) {
+ this.messages = messages;
+ }
+
+ @Override
+ protected void setValue(Object value) {
+ STATUS pinStatus = (STATUS) value;
+ super.setFont(super.getFont().deriveFont(super.getFont().getStyle() | Font.BOLD));
+
+ if (pinStatus == STATUS.NOT_ACTIV) {
+ super.setForeground(RED);
+ super.setText("<html>" + messages.getString(PINManagementGUIFacade.STATUS_NOT_ACTIVE) + "</html>");
+ } else if (pinStatus == STATUS.ACTIV) {
+ super.setForeground(GREEN);
+ super.setText("<html>" + messages.getString(PINManagementGUIFacade.STATUS_ACTIVE) + "</html>");
+ } else if (pinStatus == STATUS.BLOCKED) {
+ super.setForeground(RED);
+ super.setText("<html>" + messages.getString(PINManagementGUIFacade.STATUS_BLOCKED) + "</html>");
+ } else {
+ super.setForeground(Color.BLACK);
+ super.setText("<html>" + messages.getString(PINManagementGUIFacade.STATUS_UNKNOWN) + "</html>");
+ }
+ }
+}
diff --git a/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINStatusTableModel.java b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINStatusTableModel.java
new file mode 100644
index 00000000..052c13b2
--- /dev/null
+++ b/BKUGuiExt/src/main/java/at/gv/egiz/bku/gui/PINStatusTableModel.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.bku.gui.PINManagementGUIFacade.STATUS;
+import at.gv.egiz.smcc.PINSpec;
+import java.util.Map;
+import javax.swing.table.DefaultTableModel;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class PINStatusTableModel extends DefaultTableModel {
+
+// protected static final Log log = LogFactory.getLog(PINStatusTableModel.class);
+ protected Class[] types;
+
+ public PINStatusTableModel(Map<PINSpec, STATUS> pinStatuses) {
+ super(0, 2);
+ if (pinStatuses == null) {
+ throw new RuntimeException("pinStatuses must not be null");
+ }
+// log.trace(pinStatuses.size() + " PINs");
+ types = new Class[] { PINSpec.class, STATUS.class };
+ for (PINSpec pinSpec : pinStatuses.keySet()) {
+ addRow(new Object[] { pinSpec, pinStatuses.get(pinSpec) });
+ }
+// PINSpec activePIN = new PINSpec(0, 1, null, "active-PIN", (byte) 0x01);
+// PINSpec blockedPIN = new PINSpec(0, 1, null, "blocked-PIN", (byte) 0x01);
+// addRow(new Object[] { activePIN, PINStatusProvider.STATUS.ACTIV });
+// addRow(new Object[] { blockedPIN, PINStatusProvider.STATUS.BLOCKED });
+ }
+
+ @Override
+ public Class getColumnClass(int columnIndex) {
+ return types[columnIndex];
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return false;
+ }
+}
diff --git a/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties b/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties
new file mode 100644
index 00000000..5ef3edee
--- /dev/null
+++ b/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages.properties
@@ -0,0 +1,83 @@
+# Copyright 2008 Federal Chancellery Austria and
+# Graz University of Technology
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+title.activation=<html>Aktivierung</html>
+title.pin.mgmt=<html>PIN Verwaltung</html>
+title.activate.pin=<html>PIN aktivieren</html>
+title.change.pin=<html>PIN \u00E4ndern</html>
+title.unblock.pin=<html>PIN entsperren</html>
+#title.verify.pin=<html>PIN Eingeben</html>
+title.activate.success=<html>Erfolg</html>
+title.change.success=<html>Erfolg</html>
+title.unblock.success=<html>Erfolg</html>
+
+# removed message.* prefix to reuse keys as help keys
+pin.mgmt=<html>Die Karte verf\u00FCgt \u00FCber {0} PINs</html>
+# software pin-entry messages
+activate.pin=<html>{0} eingeben und best\u00E4tigen</html>
+change.pin=<html>{0} eingeben und best\u00E4tigen</html>
+unblock.pin=<html>PUK zu {0} eingeben</html>
+# start/finish pin-entry messages
+activate.pinpad.current=<html>Transport-PIN am Kartenleser eingeben
+activate.pinpad.new=<html>Neue PIN am Kartenleser eingeben
+activate.pinpad.confirm=<html>Neue PIN am Kartenleser best\u00E4tigen
+change.pinpad.current=<html>Alte PIN am Kartenleser eingeben
+change.pinpad.new=<html>Neue PIN am Kartenleser eingeben
+change.pinpad.confirm=<html>Neue PIN am Kartenleser best\u00E4tigen
+unblock.pinpad.current=<html>PUK am Kartenleser eingeben
+unblock.pinpad.new=<html>Neue PIN am Kartenleser eingeben
+unblock.pinpad.confirm=<html>Neue PIN am Kartenleser best\u00E4tigen
+# direct pin-entry messages
+activate.pinpad.direct=<html>{0} ({1} stellig) am Kartenleser eingeben und wiederholen (jeweils best\u00E4tigen).</html>
+change.pinpad.direct=<html>Alte {0} ({1} stellig) am Kartenleser eingeben, danach neue {0} eingeben und wiederholen (jeweils best\u00E4tigen). </html>
+unblock.pinpad.direct=<html>{0} ({1} stellig) am Kartenleser eingeben (und best\u00E4tigen).</html>
+# response messages
+activate.success=<html>{0} wurde erfolgreich aktiviert
+change.success=<html>{0} wurde erfolgreich ge\u00E4ndert
+unblock.success=<html>{0} wurde erfolgreich entsperrt
+
+label.activation=<html>e-card Aktivierungsprozess</html>
+label.activation.step=<html>Schritt {0}</html>
+label.activation.idle=<html>Warte auf Server...</html>
+label.old.pin=<html>Alte {0}:</html>
+label.puk=<html>{0} PUK:</html>
+label.new.pin=<html>Neue {0}:</html>
+label.repeat.pin=<html>Best\u00E4tigung:</html>
+
+button.activate=Aktivieren
+button.change=\u00C4ndern
+button.unblock=Entsperren
+button.verify=Abfragen
+
+help.activation=help.activation
+help.pin.mgmt=help.pin.mgmt
+
+err.status=<html>Der Status der PINs konnte nicht \u00FCberpr\u00FCft werden.</html>
+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.verify=<html>VERIFY ERROR (TODO)</html>
+err.retries=<html>Falsche {0}, noch {1} Versuche</html>
+err.locked=<html>{0} gesperrt.</html>
+err.not.active=<html>{0} nicht aktiviert.</html>
+err.pin.format=<html>Ung\u00FCltige {0} L\u00E4nge, verlangt sind {1} Stellen.</html>
+err.pin.confirmation=<html>{0} und Best\u00E4tigung stimmen nicht \u00FCberein.</html>
+err.pin.operation.aborted=<html>Der Vorgang f\u00FCr {0} wurde abgebrochen.</html>
+err.unsupported.card=<html>Die Karte wird nicht unterst\u00FCtzt</html>
+
+status.not.active=NICHT AKTIV
+status.active=AKTIV
+status.blocked=GESPERRT
+status.unknown=UNBEKANNT
diff --git a/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages_en.properties b/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages_en.properties
new file mode 100644
index 00000000..87e3f181
--- /dev/null
+++ b/BKUGuiExt/src/main/resources/at/gv/egiz/bku/gui/ActivationMessages_en.properties
@@ -0,0 +1,82 @@
+# Copyright 2008 Federal Chancellery Austria and
+# Graz University of Technology
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+title.activation=<html>Activation</html>
+title.pin.mgmt=<html>PIN Management</html>
+title.activate.pin=<html>Activate PIN</html>
+#title.verify.pin=<html>Enter PIN</html>
+title.change.pin=<html>Change PIN</html>
+title.unblock.pin=<html>Unblock PIN</html>
+title.activate.success=<html>Success</html>
+title.change.success=<html>Success</html>
+title.unblock.success=<html>Success</html>
+
+# removed message.* prefix to reuse keys as help keys
+pin.mgmt=<html>{0} PINs available
+# software pin-entry messages
+activate.pin=<html>Enter and confirm {0}
+change.pin=<html>Enter and confirm {0}
+unblock.pin=<html>Enter PUK for {0}
+# start/finish pin-entry messages
+activate.pinpad.current=<html>Enter transport-PIN on cardreader
+activate.pinpad.new=<html>Enter new PIN on cardreader
+activate.pinpad.confirm=<html>Confirm new PIN on cardreader
+change.pinpad.current=<html>Enter old PIN on cardreader
+change.pinpad.new=<html>Enter new PIN on cardreader
+change.pinpad.confirm=<html>Confirm new PIN on cardreader
+unblock.pinpad.current=<html>Enter PUK on cardreader
+unblock.pinpad.new=<html>Enter new PIN on cardreader
+unblock.pinpad.confirm=<html>Confirm new PIN on cardreader
+# direct pin-entry messages
+activate.pinpad.direct=<html>Enter {0} ({1} digits) on cardreader and repeat (confirm in each case)
+change.pinpad.direct=<html>Enter old {0} ({1} digits) on cardreader, then enter new {0} and repeat (confirm in each case)
+unblock.pinpad.direct=<html>Enter {0} ({1} digits) on cardreader, then enter new {0} and repeat (confirm in each case)
+# response messages
+activate.success=<html>{0} successfully activated</html>
+change.success=<html>{0} successfully changed</html>
+unblock.success=<html>{0} successfully unblocked
+
+label.activation=<html>e-card activation process</html>
+label.activation.step=<html>Step {0}</html>
+label.activation.idle=<html>Wait for server...</html>
+label.old.pin=<html>Old {0}:</html>
+label.puk=<html>{0} PUK:</html>
+label.new.pin=<html>New {0}:</html>
+label.repeat.pin=<html>Confirmation:</html>
+
+button.activate=Activate
+button.change=Change
+button.unblock=Unblock
+button.verify=Query
+
+help.activation=help.activation
+help.pin.mgmt=help.pin.mgmt
+
+err.status=<html>PIN statuses could not be read.</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>
+err.locked=<html>{0} locked</html>
+err.not.active=<html>{0} not activated.</html>
+err.pin.format=<html>Invalid {0} length, {1} digit(s) required.</html>
+err.pin.confirmation=<html>{0} and confirmation do not match.</html>
+err.pin.operation.aborted=<html>The operation on {0} was aborted.</html>
+err.unsupported.card=<html>This card is not supported</html>
+
+status.not.active=NOT ACTIVE
+status.active=ACTIVE
+status.blocked=BLOCKED
+status.unknown=UNKNOWN