Search in sources :

Example 11 with ValidationException

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

the class CertImportController method validateAndReloadPlatformSource.

private void validateAndReloadPlatformSource() {
    try {
        PlatformKeyStore platformSource = validatePlatformSourceInput();
        getExecutorService().submit(new ReloadTask<PlatformKeyStore>(platformSource) {

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

Example 12 with ValidationException

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

the class CertImportController method validateURLSourceInput.

private URL validateURLSourceInput() throws ValidationException {
    String urlSourceInput = InputValidator.notEmpty(Strings.safeTrim(this.ctlURLSourceInput.getText()), CertImportI18N::formatSTR_MESSAGE_NO_URL);
    URL urlSource;
    try {
        urlSource = new URL(urlSourceInput);
    } catch (MalformedURLException e) {
        throw new ValidationException(CertImportI18N.formatSTR_MESSAGE_INVALID_DIRECTORY(urlSourceInput), e);
    }
    return urlSource;
}
Also used : MalformedURLException(java.net.MalformedURLException) ValidationException(de.carne.jfx.util.validation.ValidationException) URL(java.net.URL)

Example 13 with ValidationException

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

the class BasicConstraintsController method onApply.

private void onApply(ActionEvent evt) {
    try {
        boolean critical = this.ctlCritical.isSelected();
        boolean ca = this.ctlCA.isSelected();
        BigInteger pathLenConstraint = null;
        if (ca) {
            pathLenConstraint = valdiateAndGetPathLenConstraint();
        }
        this.extensionDataResult = new BasicConstraintsExtensionData(critical, ca, pathLenConstraint);
    } catch (ValidationException e) {
        ValidationAlerts.error(e).showAndWait();
        evt.consume();
    }
}
Also used : ValidationException(de.carne.jfx.util.validation.ValidationException) BasicConstraintsExtensionData(de.carne.certmgr.certs.x509.BasicConstraintsExtensionData) BigInteger(java.math.BigInteger)

Example 14 with ValidationException

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

the class SubjectAlternativeNameController method onApply.

private void onApply(ActionEvent evt) {
    try {
        boolean critical = this.ctlCritical.isSelected();
        GeneralNames names = validateAndGetNames();
        this.extensionDataResult = new SubjectAlternativeNameExtensionData(critical, names);
    } catch (ValidationException e) {
        ValidationAlerts.error(e).showAndWait();
        evt.consume();
    }
}
Also used : ValidationException(de.carne.jfx.util.validation.ValidationException) GeneralNames(de.carne.certmgr.certs.x509.GeneralNames) SubjectAlternativeNameExtensionData(de.carne.certmgr.certs.x509.SubjectAlternativeNameExtensionData)

Example 15 with ValidationException

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

the class CertExportController method onCmdExport.

@SuppressWarnings("unused")
@FXML
void onCmdExport(ActionEvent evt) {
    try {
        CertWriter exportFormat = validateAndGetFormat();
        boolean encrypt = this.ctlEncryptOption.isSelected();
        boolean exportCert = this.ctlExportCertOption.isSelected();
        boolean exportChain = this.ctlExportChainOption.isSelected();
        boolean exportChainRoot = this.ctlExportChainRootOption.isSelected();
        boolean exportKey = this.ctlExportKeyOption.isSelected();
        boolean exportCSR = this.ctlExportCSROption.isSelected();
        boolean exportCRL = this.ctlExportCRLOption.isSelected();
        if (this.ctlFileDestinationOption.isSelected()) {
            Path exportFile = validateFileDestinationInput();
            getExecutorService().submit(new ExportTask<Path>(exportCert, exportChain, exportChainRoot, exportKey, exportCSR, exportCRL, exportFormat, exportFile, encrypt) {

                @Override
                protected void export(CertWriter format, @Nullable Path param, CertObjectStore exportObjects, boolean encryptExport) throws IOException {
                    exportToFile(format, Check.notNull(param), exportObjects, encryptExport);
                }
            });
        } else if (this.ctlDirectoryDestinationOption.isSelected()) {
            Path exportDirectory = validateDirectoryDestinationInput();
            getExecutorService().submit(new ExportTask<Path>(exportCert, exportChain, exportChainRoot, exportKey, exportCSR, exportCRL, exportFormat, exportDirectory, encrypt) {

                @Override
                protected void export(CertWriter format, @Nullable Path param, CertObjectStore exportObjects, boolean encryptExport) throws IOException {
                    exportToDirectory(format, Check.notNull(param), exportObjects, encryptExport);
                }
            });
        } else if (this.ctlClipboardDestinationOption.isSelected()) {
            getExecutorService().submit(new ExportTask<Void>(exportCert, exportChain, exportChainRoot, exportKey, exportCSR, exportCRL, exportFormat, null, encrypt) {

                @Override
                protected void export(CertWriter format, @Nullable Void param, CertObjectStore exportObjects, boolean encryptExport) throws IOException {
                    exportToClipboard(format, exportObjects, encryptExport);
                }
            });
        }
    } catch (ValidationException e) {
        ValidationAlerts.error(e).showAndWait();
    }
}
Also used : Path(java.nio.file.Path) ValidationException(de.carne.jfx.util.validation.ValidationException) CertWriter(de.carne.certmgr.certs.spi.CertWriter) CertObjectStore(de.carne.certmgr.certs.CertObjectStore) IOException(java.io.IOException) Nullable(de.carne.check.Nullable) FXML(javafx.fxml.FXML)

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