~ubuntu-branches/ubuntu/raring/icedtea-web/raring

« back to all changes in this revision

Viewing changes to netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-04 18:19:46 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20120204181946-jngobgzz4mlen9yl
Tags: 1.2~pre1-0ubuntu1
* Update to hg 20120203, taken from the icedtea-web-1.2 release branch.
* Build separate plugin packages for OpenJDK 6 and OpenJDK 7, needed
  to provide the path to the runtime and the mime description in the plugin.
* Use icedtea-<jre version>-plugin as the name for both plugin packages.
* Remove icedtea-web-1.1.4-npapi-fix.patch, fixed upstream.
* Pass -n to gzip when compressing manpages to be Multi-Arch: same safe.
* Build multiarch packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
import javax.swing.JLabel;
67
67
import javax.swing.JOptionPane;
68
68
import javax.swing.JPanel;
 
69
import javax.swing.JPasswordField;
69
70
import javax.swing.JScrollPane;
70
71
import javax.swing.JTabbedPane;
71
72
import javax.swing.JTable;
100
101
            new CertificateType(KeyStores.Type.JSSE_CA_CERTS),
101
102
            new CertificateType(KeyStores.Type.CERTS),
102
103
            new CertificateType(KeyStores.Type.JSSE_CERTS),
 
104
            new CertificateType(KeyStores.Type.CLIENT_CERTS)
103
105
        };
104
106
 
105
107
    JTabbedPane tabbedPane;
301
303
        }
302
304
    }
303
305
 
 
306
    private char[] getPassword(final String label) {
 
307
        JPasswordField jpf = new JPasswordField();
 
308
        int result = JOptionPane.showConfirmDialog(parent,
 
309
                                new Object[]{label, jpf},  R("CVPasswordTitle"),
 
310
                                JOptionPane.OK_CANCEL_OPTION,
 
311
                                JOptionPane.INFORMATION_MESSAGE);
 
312
        if (result == JOptionPane.OK_OPTION)
 
313
            return jpf.getPassword();
 
314
        else
 
315
            return null;
 
316
    }
 
317
 
304
318
    /** Allows storing KeyStores.Types in a JComponent */
305
319
    private static class CertificateType {
306
320
        private final KeyStores.Type type;
364
378
            if (returnVal == JFileChooser.APPROVE_OPTION) {
365
379
                try {
366
380
                    KeyStore ks = keyStore;
367
 
                    CertificateUtils.addToKeyStore(chooser.getSelectedFile(), ks);
 
381
                    if (currentKeyStoreType == KeyStores.Type.CLIENT_CERTS) {
 
382
                        char[] password = getPassword(R("CVImportPasswordMessage"));
 
383
                        if (password != null) {
 
384
                            CertificateUtils.addPKCS12ToKeyStore(
 
385
                                       chooser.getSelectedFile(), ks, password);
 
386
                        } else {
 
387
                            return;
 
388
                        }
 
389
                    } else {
 
390
                        CertificateUtils.addToKeyStore(chooser.getSelectedFile(), ks);
 
391
                    }
368
392
                    File keyStoreFile = new File(KeyStores
369
393
                                        .getKeyStoreLocation(currentKeyStoreLevel, currentKeyStoreType));
370
394
                    if (!keyStoreFile.isFile()) {
408
432
                        String alias = keyStore.getCertificateAlias(certs
409
433
                                                        .get(selectedRow));
410
434
                        if (alias != null) {
411
 
                            Certificate c = keyStore.getCertificate(alias);
412
 
                            PrintStream ps = new PrintStream(chooser.getSelectedFile().getAbsolutePath());
413
 
                            CertificateUtils.dump(c, ps);
 
435
                            if (currentKeyStoreType == KeyStores.Type.CLIENT_CERTS) {
 
436
                                char[] password = getPassword(R("CVExportPasswordMessage"));
 
437
                                if (password != null)
 
438
                                    CertificateUtils.dumpPKCS12(alias, chooser.getSelectedFile(), keyStore, password);
 
439
                            } else {
 
440
                                Certificate c = keyStore.getCertificate(alias);
 
441
                                PrintStream ps = new PrintStream(chooser.getSelectedFile().getAbsolutePath());
 
442
                                CertificateUtils.dump(c, ps);
 
443
                            }
414
444
                            repopulateTables();
415
445
                        }
416
446
                    }