Search in sources :

Example 1 with PemBuilder

use of org.jivesoftware.sparkimpl.certificates.PemHelper.PemBuilder in project Spark by igniterealtime.

the class MutualAuthenticationSettingsPanel method createSelfSignedCertificate.

private void createSelfSignedCertificate() {
    idControll.setUpData(commonNameField.getText(), organizationUnitField.getText(), organizationField.getText(), countryField.getText(), cityField.getText());
    try {
        KeyPair keyPair = idControll.createKeyPair();
        PemBuilder pemBuilder = new PemHelper().new PemBuilder();
        X509Certificate cert = idControll.createSelfSignedCertificate(keyPair);
        pemBuilder.add(keyPair.getPrivate());
        pemBuilder.add(cert);
        pemBuilder.saveToPemFile(IdentityController.CERT_FILE);
        JOptionPane.showMessageDialog(null, Res.getString("dialog.self.signed.certificate.has.been.created") + IdentityController.SECURITY_DIRECTORY.toString());
    } catch (NoSuchAlgorithmException | NoSuchProviderException | IOException | OperatorCreationException | CertificateException e1) {
        Log.error("Couldn't create Self Signed Certificate", e1);
    }
}
Also used : KeyPair(java.security.KeyPair) PemHelper(org.jivesoftware.sparkimpl.certificates.PemHelper) CertificateException(java.security.cert.CertificateException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) PemBuilder(org.jivesoftware.sparkimpl.certificates.PemHelper.PemBuilder) NoSuchProviderException(java.security.NoSuchProviderException) OperatorCreationException(org.bouncycastle.operator.OperatorCreationException) X509Certificate(java.security.cert.X509Certificate)

Aggregations

IOException (java.io.IOException)1 KeyPair (java.security.KeyPair)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 NoSuchProviderException (java.security.NoSuchProviderException)1 CertificateException (java.security.cert.CertificateException)1 X509Certificate (java.security.cert.X509Certificate)1 OperatorCreationException (org.bouncycastle.operator.OperatorCreationException)1 PemHelper (org.jivesoftware.sparkimpl.certificates.PemHelper)1 PemBuilder (org.jivesoftware.sparkimpl.certificates.PemHelper.PemBuilder)1