Search in sources :

Example 1 with ValidationException

use of de.carne.jfx.util.validation.ValidationException in project certmgr by hdecarne.

the class CertImportController method validateAndReloadFileSource.

private void validateAndReloadFileSource() {
    try {
        Path fileSource = validateFileSourceInput();
        getExecutorService().submit(new ReloadTask<Path>(fileSource) {

            @Override
            protected UserCertStore createStore(Path params) throws IOException {
                return UserCertStore.createFromFile(params, PasswordDialog.enterPassword(CertImportController.this));
            }
        });
    } catch (ValidationException e) {
        ValidationAlerts.error(e).showAndWait();
    }
}
Also used : Path(java.nio.file.Path) ValidationException(de.carne.jfx.util.validation.ValidationException) IOException(java.io.IOException) UserCertStore(de.carne.certmgr.certs.UserCertStore)

Example 2 with ValidationException

use of de.carne.jfx.util.validation.ValidationException in project certmgr by hdecarne.

the class CRLOptionsController method onCmdUpdate.

@SuppressWarnings("unused")
@FXML
void onCmdUpdate(ActionEvent evt) {
    try {
        UpdateCRLRequest updateRequest = validateAndGetUpdateRequest();
        getExecutorService().submit(new UpdateCRLTask(updateRequest));
    } catch (ValidationException e) {
        ValidationAlerts.error(e).showAndWait();
    }
}
Also used : ValidationException(de.carne.jfx.util.validation.ValidationException) UpdateCRLRequest(de.carne.certmgr.certs.x509.UpdateCRLRequest) FXML(javafx.fxml.FXML)

Example 3 with ValidationException

use of de.carne.jfx.util.validation.ValidationException in project certmgr by hdecarne.

the class DNEditorController method validateAndGetDN.

private X500Principal validateAndGetDN() throws ValidationException {
    LdapName ldapDN = new LdapName(this.ctlRdnEntries.getItems());
    X500Principal x500DN;
    try {
        x500DN = X500Names.fromString(ldapDN.toString());
    } catch (IllegalArgumentException e) {
        throw new ValidationException(DNEditorI18N.formatSTR_MESSAGE_INVALID_DN(e.getLocalizedMessage()), e);
    }
    return x500DN;
}
Also used : ValidationException(de.carne.jfx.util.validation.ValidationException) X500Principal(javax.security.auth.x500.X500Principal) LdapName(javax.naming.ldap.LdapName)

Example 4 with ValidationException

use of de.carne.jfx.util.validation.ValidationException 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)

Example 5 with ValidationException

use of de.carne.jfx.util.validation.ValidationException in project certmgr by hdecarne.

the class CRLDistributionPointsController method onApply.

private void onApply(ActionEvent evt) {
    try {
        boolean critical = this.ctlCritical.isSelected();
        DistributionPoint distributionPoint = validateAndGetDistributionPoint();
        this.extensionDataResult = new CRLDistributionPointsExtensionData(critical);
        this.extensionDataResult.addDistributionPoint(distributionPoint);
    } catch (ValidationException e) {
        ValidationAlerts.error(e).showAndWait();
        evt.consume();
    }
}
Also used : ValidationException(de.carne.jfx.util.validation.ValidationException) CRLDistributionPointsExtensionData(de.carne.certmgr.certs.x509.CRLDistributionPointsExtensionData) DistributionPoint(de.carne.certmgr.certs.x509.DistributionPoint)

Aggregations

ValidationException (de.carne.jfx.util.validation.ValidationException)15 IOException (java.io.IOException)5 UserCertStore (de.carne.certmgr.certs.UserCertStore)4 Path (java.nio.file.Path)4 FXML (javafx.fxml.FXML)3 URL (java.net.URL)2 X500Principal (javax.security.auth.x500.X500Principal)2 CertObjectStore (de.carne.certmgr.certs.CertObjectStore)1 UserCertStorePreferences (de.carne.certmgr.certs.UserCertStorePreferences)1 SSLPeer (de.carne.certmgr.certs.net.SSLPeer)1 PlatformKeyStore (de.carne.certmgr.certs.security.PlatformKeyStore)1 CertGenerator (de.carne.certmgr.certs.spi.CertGenerator)1 CertWriter (de.carne.certmgr.certs.spi.CertWriter)1 BasicConstraintsExtensionData (de.carne.certmgr.certs.x509.BasicConstraintsExtensionData)1 CRLDistributionPointsExtensionData (de.carne.certmgr.certs.x509.CRLDistributionPointsExtensionData)1 DistributionPoint (de.carne.certmgr.certs.x509.DistributionPoint)1 GeneralNames (de.carne.certmgr.certs.x509.GeneralNames)1 GenerateCertRequest (de.carne.certmgr.certs.x509.GenerateCertRequest)1 SubjectAlternativeNameExtensionData (de.carne.certmgr.certs.x509.SubjectAlternativeNameExtensionData)1 UpdateCRLRequest (de.carne.certmgr.certs.x509.UpdateCRLRequest)1