Search in sources :

Example 6 with UserCertStorePreferences

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

the class CRLOptionsController method init.

/**
 * Initialize the dialog for CRL options editing.
 *
 * @param issuerEntry The CRL issuer to edit the options for.
 * @param expertModeParam Whether to run in expert mode ({@code true}) or not ({@code false}).
 * @return This controller.
 * @throws IOException if an I/O error occurs during initialization.
 */
public CRLOptionsController init(UserCertStoreEntry issuerEntry, boolean expertModeParam) throws IOException {
    this.issuerEntryParam.set(issuerEntry);
    this.ctlIssuerField.setText(issuerEntry.getName());
    UserCertStorePreferences preferences = Check.notNull(issuerEntry.store().storePreferences());
    initSigAlgOptions(preferences, expertModeParam);
    initUpdateOptions(preferences);
    initEntries();
    return this;
}
Also used : UserCertStorePreferences(de.carne.certmgr.certs.UserCertStorePreferences)

Example 7 with UserCertStorePreferences

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

the class StorePreferencesController method onDefKeyAlgChanged.

private void onDefKeyAlgChanged(KeyPairAlgorithm keyAlg) {
    Integer keySizeDefaultHint = null;
    String sigAlgDefaultHint = null;
    if (this.storePreferencesParam.toOptional().isPresent()) {
        UserCertStorePreferences storePreferences = this.storePreferencesParam.get();
        if (keyAlg.algorithm().equals(storePreferences.defaultKeyPairAlgorithm.get())) {
            keySizeDefaultHint = storePreferences.defaultKeySize.get();
            sigAlgDefaultHint = storePreferences.defaultSignatureAlgorithm.get();
        }
    }
    Controls.resetComboBoxOptions(this.ctlDefKeySizeOption, keyAlg.getStandardKeySizes(keySizeDefaultHint), (o1, o2) -> o1.compareTo(o2));
    Controls.resetComboBoxOptions(this.ctlDefSigAlgOption, SignatureAlgorithm.getDefaultSet(keyAlg.algorithm(), sigAlgDefaultHint, this.expertModeParam), (o1, o2) -> o1.toString().compareTo(o2.toString()));
}
Also used : UserCertStorePreferences(de.carne.certmgr.certs.UserCertStorePreferences)

Example 8 with UserCertStorePreferences

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

the class StorePreferencesController method onApply.

private void onApply(ActionEvent evt) {
    if (!this.storeParam.toOptional().isPresent()) {
        try {
            Path storeHome = validateStoreHomeInput();
            this.storeParam.set(UserCertStore.createStore(storeHome));
            this.storePreferencesParam.set(Check.notNull(this.storeParam.get().storePreferences()));
        } catch (ValidationException e) {
            ValidationAlerts.error(e).showAndWait();
            evt.consume();
        } catch (Exception e) {
            Alerts.unexpected(e).showAndWait();
            evt.consume();
        }
    }
    if (this.storePreferencesParam.toOptional().isPresent()) {
        try {
            UserCertStorePreferences storePreferences = this.storePreferencesParam.get();
            storePreferences.defaultCRTValidityPeriod.put(validateDefCRTValidityInput().days().count());
            storePreferences.defaultCRLUpdatePeriod.put(validateDefCRLUpdateInput().days().count());
            storePreferences.defaultKeyPairAlgorithm.put(validateDefKeyAlgInput().algorithm());
            storePreferences.defaultKeySize.put(validateDefKeySizeInput());
            storePreferences.defaultSignatureAlgorithm.put(validateDefSigAlgInput().algorithm());
            storePreferences.sync();
        } catch (ValidationException e) {
            ValidationAlerts.error(e).showAndWait();
            evt.consume();
        } catch (Exception e) {
            Alerts.unexpected(e).showAndWait();
            evt.consume();
        }
    }
}
Also used : Path(java.nio.file.Path) UserCertStorePreferences(de.carne.certmgr.certs.UserCertStorePreferences) ValidationException(de.carne.jfx.util.validation.ValidationException) ValidationException(de.carne.jfx.util.validation.ValidationException)

Aggregations

UserCertStorePreferences (de.carne.certmgr.certs.UserCertStorePreferences)8 SignatureAlgorithm (de.carne.certmgr.certs.security.SignatureAlgorithm)2 UserCertStore (de.carne.certmgr.certs.UserCertStore)1 UserCertStoreEntry (de.carne.certmgr.certs.UserCertStoreEntry)1 UserCertStoreEntryId (de.carne.certmgr.certs.UserCertStoreEntryId)1 UpdateCRLRequest (de.carne.certmgr.certs.x509.UpdateCRLRequest)1 ValidationException (de.carne.jfx.util.validation.ValidationException)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 BackingStoreException (java.util.prefs.BackingStoreException)1 Test (org.junit.Test)1