I am developing a client application that accepts or rejects certificates from a server just as any browser would do. More detailed explanation of my work can be found in this Code Review.
The method I am using to display my certificates is,
public boolean DisplayCertficate(java.security.cert.X509Certificate cert){
final JPanel panel = new JPanel();
String message = " Do you want to accept this certificate? \n"
+ "\n Certificate for: " + cert.getSubjectDN()
+ "\n Certificate issued by: "
+ cert.getIssuerDN()
+ "\n The certificate is valid from: "
+ cert.getNotBefore() + "\n Certificate SN#: "
+ cert.getSerialNumber() + "\n Generated with: "
+ cert.getSigAlgName();
String title = "Security Alert";
String[] options = { "yes", "no" };
int confirm = JOptionPane.showOptionDialog(panel, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
if (confirm == JOptionPane.YES_OPTION){
return true;
} else if (confirm == JOptionPane.NO_OPTION) {
return false;
}
else{
return false;
}
}
And this function is called in another class:
if(PopUp.DisplayCertficate((X509Certificate) c) == true){
return true;
}
else{
PopUp.NeedCertificate();
return false;
}
This works fine if I need a certificate from a single server. If I am trying to load multiple servers one after another into my Client UI, multiple JOptionPane
windows open up in a quick succession. This freezes the displayed certificate window.
Is there a way I can open a new JOptionPane
window in a different location for each certificate I try to load?