Code with Finding: |
class PassportGUI {
/**
* Constructs the GUI.
*
* @param arg command line arguments, are ignored for now.
*/
public PassportGUI(String[] arg) {
try {
Security.insertProviderAt(PROVIDER, 2);
if(arg != null && arg.length > 0 &&
(arg[0].equals("apduio") || arg[0].equals("jcop"))) {
if(arg[0].equals("apduio"))
service = new PassportApduService(new APDUIOService());
else
service = new PassportApduService(new JCOPEmulatorService());
// sample data from icao
DEFAULT_DOC_NR = "L898902C<";
DEFAULT_DATE_OF_BIRTH = "690806";
DEFAULT_DATE_OF_EXPIRY = "940623";
}
else {
service = new PassportApduService(new JPCSCService());
// Loes's passport
DEFAULT_DOC_NR = "XX0001027";
DEFAULT_DATE_OF_BIRTH = "711019";
DEFAULT_DATE_OF_EXPIRY = "111001";
}
setLayout(new BorderLayout());
JPanel northPanel = new JPanel(new FlowLayout());
terminalsComboBox = new JComboBox();
String[] terminals = service.getTerminals();
for (int i = 0; i < terminals.length; i++) {
terminalsComboBox.addItem(terminals[i]);
}
openButton = new JButton("Open");
openButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String[] terminals = service.getTerminals();
String terminal = terminals[terminalsComboBox.getSelectedIndex()];
service.open(terminal);
openButton.setEnabled(false);
closeButton.setEnabled(true);
}
});
northPanel.add(terminalsComboBox);
northPanel.add(openButton);
closeButton = new JButton("Close");
closeButton.setEnabled(false);
closeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
service.close();
closeButton.setEnabled(false);
openButton.setEnabled(true);
}
});
northPanel.add(closeButton);
add(northPanel, BorderLayout.NORTH);
log = new APDULogPanel();
add(log, BorderLayout.SOUTH);
JTabbedPane tabbedPane = new JTabbedPane();
BACPanel bacPanel = new BACPanel(service);
APDUSenderPanel apduSenderPanel = new APDUSenderPanel(service);
LDSPanel ldsPanel = new LDSPanel(service);
FacePanel facePanel = new FacePanel(service);
AAPanel aaPanel = new AAPanel(service);
InitPassportPanel initPanel = new InitPassportPanel(service);
bacPanel.addAuthenticationListener(apduSenderPanel);
bacPanel.addAuthenticationListener(ldsPanel);
bacPanel.addAuthenticationListener(facePanel);
bacPanel.addAuthenticationListener(aaPanel);
bacPanel.addAuthenticationListener(initPanel);
tabbedPane.addTab("BAC", bacPanel);
tabbedPane.addTab("APDU", apduSenderPanel);
tabbedPane.addTab("LDS", ldsPanel);
tabbedPane.addTab("Face", facePanel);
tabbedPane.addTab("AA", aaPanel);
tabbedPane.addTab("Init", initPanel);
add(tabbedPane, BorderLayout.CENTER);
service.addAPDUListener(log);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}
|