|
如何使用JSSE实现SSL安全连接(7) /** default to not trustable */ private boolean isTrusted=false; private JDialog trust=null; private JList certItems=null; private JTextArea certValues=null; private JComboBox certChain=null; private final String certParms[]={"Version","Serial Number","Signature Algorithm", "Issuer", "Validity Period", "Subject", "Signature","Certificate Fingerprint"}; private X509Certificate[] chain; private int chainIdx=0;
/** * Creates an instance of the class and stores the certificate to show internally. * * @param chain In: The certificate chain to show. */ AskForTrustability (X509Certificate[] chain) { this.chain=chain; } /** * This method shows a dialog with all interesting information of the certificate and * asks the user if the certificate is trustable or not. This method blocks until * the user presses the 'Yes' or 'No' button. * * @return: true: The certificate chain is trustable * false: The certificate chain is not trustable */
public boolean showCertificateAndGetDecision() { if(chain == null chain.length == 0) { return false; }
trust=new JDialog((Frame)null,"Untrusted server certificate for SSL connection",true); Container cont=trust.getContentPane(); GridBagLayout gl=new GridBagLayout(); cont.setLayout(gl);
|