Search in sources :

Example 11 with UserCertStoreEntry

use of de.carne.certmgr.certs.UserCertStoreEntry in project certmgr by hdecarne.

the class CertOptionsController method resetStorePresetMenuHelper.

private void resetStorePresetMenuHelper(ObservableList<MenuItem> menuItems, Set<UserCertStoreEntry> storeEntries, String indent) {
    for (UserCertStoreEntry storeEntry : storeEntries) {
        if (storeEntry.hasCRT() || storeEntry.hasCSR()) {
            MenuItem storeEntryMenuItem = new MenuItem(CertOptionsI18N.formatSTR_MENU_STORE_PRESET(indent, storeEntry.id().getAlias(), X500Names.toString(storeEntry.dn())));
            storeEntryMenuItem.setUserData(CertOptionsTemplates.wrap(storeEntry));
            storeEntryMenuItem.setOnAction(this::onCmdApplyTemplate);
            menuItems.add(storeEntryMenuItem);
            String nextIndent = (Strings.notEmpty(indent) ? "  " + indent : " \u21b3");
            resetStorePresetMenuHelper(menuItems, storeEntry.issuedEntries(), nextIndent);
        }
    }
}
Also used : MenuItem(javafx.scene.control.MenuItem) UserCertStoreEntry(de.carne.certmgr.certs.UserCertStoreEntry)

Example 12 with UserCertStoreEntry

use of de.carne.certmgr.certs.UserCertStoreEntry in project certmgr by hdecarne.

the class CertImportController method importSelection.

void importSelection(Set<UserCertStoreEntry> importSelection) throws IOException {
    PasswordCallback newPassword = PasswordDialog.enterNewPassword(this);
    UserCertStore importStore = this.importStoreParam.get();
    for (UserCertStoreEntry importEntry : importSelection) {
        importStore.importEntry(importEntry, newPassword, CertImportI18N.formatSTR_TEXT_ALIASHINT());
    }
}
Also used : PasswordCallback(de.carne.certmgr.certs.PasswordCallback) UserCertStore(de.carne.certmgr.certs.UserCertStore) UserCertStoreEntry(de.carne.certmgr.certs.UserCertStoreEntry)

Example 13 with UserCertStoreEntry

use of de.carne.certmgr.certs.UserCertStoreEntry in project certmgr by hdecarne.

the class StoreController method onCmdRevokeCert.

@SuppressWarnings("unused")
@FXML
void onCmdRevokeCert(ActionEvent evt) {
    UserCertStoreEntry entry = getSelectedStoreEntry();
    if (entry != null) {
        UserCertStoreEntry issuerEntry = entry.issuer();
        if (!entry.isSelfSigned() && issuerEntry.hasPublicKey() && issuerEntry.hasKey()) {
            try {
                CRLOptionsController crlOptionsController = loadStage(CRLOptionsController.class).init(issuerEntry, this.userPreferences.expertMode.getBoolean(false));
                crlOptionsController.revokeStoreEntry(entry, ReasonFlag.UNSPECIFIED);
                crlOptionsController.showAndWait();
                updateStoreEntryView();
            } catch (IOException e) {
                Alerts.unexpected(e).showAndWait();
            }
        } else {
            Alerts.message(AlertType.WARNING, StoreI18N.formatSTR_MESSAGE_CANNOT_REVOKE_CRT(issuerEntry), ButtonType.OK).showAndWait();
        }
    }
}
Also used : CRLOptionsController(de.carne.certmgr.jfx.crloptions.CRLOptionsController) IOException(java.io.IOException) UserCertStoreEntry(de.carne.certmgr.certs.UserCertStoreEntry) FXML(javafx.fxml.FXML)

Example 14 with UserCertStoreEntry

use of de.carne.certmgr.certs.UserCertStoreEntry in project certmgr by hdecarne.

the class StoreController method onCmdExportCert.

@SuppressWarnings("unused")
@FXML
void onCmdExportCert(ActionEvent evt) {
    UserCertStoreEntry exportEntry = getSelectedStoreEntry();
    if (exportEntry != null) {
        try {
            CertExportController exportController = loadStage(CertExportController.class).init(exportEntry);
            exportController.showAndWait();
            updateStoreEntryView();
        } catch (IOException e) {
            Alerts.unexpected(e).showAndWait();
        }
    }
}
Also used : CertExportController(de.carne.certmgr.jfx.certexport.CertExportController) IOException(java.io.IOException) UserCertStoreEntry(de.carne.certmgr.certs.UserCertStoreEntry) FXML(javafx.fxml.FXML)

Example 15 with UserCertStoreEntry

use of de.carne.certmgr.certs.UserCertStoreEntry in project certmgr by hdecarne.

the class StoreController method updateDetailsView.

private void updateDetailsView(@Nullable TreeItem<StoreEntryModel> selection) {
    TreeItem<AttributeModel> rootItem = null;
    if (selection != null) {
        rootItem = new TreeItem<>();
        rootItem.setExpanded(true);
        UserCertStoreEntry entry = selection.getValue().getEntry();
        updateDetailsViewHelper(rootItem, Attributes.toAttributes(entry), true);
        if (entry.hasCRT()) {
            try {
                X509Certificate crt = entry.getCRT();
                updateDetailsViewHelper(rootItem, X509CertificateHelper.toAttributes(crt), true);
            } catch (IOException e) {
                Exceptions.warn(e);
            }
        }
        if (entry.hasCSR()) {
            try {
                PKCS10CertificateRequest csr = entry.getCSR();
                updateDetailsViewHelper(rootItem, csr.toAttributes(), true);
            } catch (IOException e) {
                Exceptions.ignore(e);
            }
        }
        if (entry.hasCRL()) {
            try {
                X509CRL crl = entry.getCRL();
                updateDetailsViewHelper(rootItem, X509CRLHelper.toAttributes(crl), true);
            } catch (IOException e) {
                Exceptions.ignore(e);
            }
        }
    }
    this.ctlDetailsView.setRoot(rootItem);
}
Also used : X509CRL(java.security.cert.X509CRL) PKCS10CertificateRequest(de.carne.certmgr.certs.x509.PKCS10CertificateRequest) IOException(java.io.IOException) X509Certificate(java.security.cert.X509Certificate) UserCertStoreEntry(de.carne.certmgr.certs.UserCertStoreEntry)

Aggregations

UserCertStoreEntry (de.carne.certmgr.certs.UserCertStoreEntry)19 IOException (java.io.IOException)10 FXML (javafx.fxml.FXML)6 UserCertStore (de.carne.certmgr.certs.UserCertStore)4 BigInteger (java.math.BigInteger)4 Date (java.util.Date)4 CRLOptionsController (de.carne.certmgr.jfx.crloptions.CRLOptionsController)3 X509CRL (java.security.cert.X509CRL)3 X509Certificate (java.security.cert.X509Certificate)3 CertObjectStore (de.carne.certmgr.certs.CertObjectStore)2 SignatureAlgorithm (de.carne.certmgr.certs.security.SignatureAlgorithm)2 PKCS10CertificateRequest (de.carne.certmgr.certs.x509.PKCS10CertificateRequest)2 ReasonFlag (de.carne.certmgr.certs.x509.ReasonFlag)2 CertExportController (de.carne.certmgr.jfx.certexport.CertExportController)2 Path (java.nio.file.Path)2 ButtonType (javafx.scene.control.ButtonType)2 Test (org.junit.Test)2 PasswordCallback (de.carne.certmgr.certs.PasswordCallback)1 UserCertStoreEntryId (de.carne.certmgr.certs.UserCertStoreEntryId)1 UserCertStorePreferences (de.carne.certmgr.certs.UserCertStorePreferences)1