Search in sources :

Example 6 with ValidationException

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

the class CertOptionsController method validateAndGetDN.

private X500Principal validateAndGetDN() throws ValidationException {
    String dnInput = InputValidator.notEmpty(Strings.safeTrim(this.ctlDNInput.getText()), CertOptionsI18N::formatSTR_MESSAGE_NO_DN);
    X500Principal dn;
    try {
        dn = X500Names.fromString(dnInput);
    } catch (IllegalArgumentException e) {
        throw new ValidationException(CertOptionsI18N.formatSTR_MESSAGE_INVALID_DN(dnInput), e);
    }
    return dn;
}
Also used : ValidationException(de.carne.jfx.util.validation.ValidationException) X500Principal(javax.security.auth.x500.X500Principal)

Example 7 with ValidationException

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

the class CertOptionsController method onCmdGenerate.

@SuppressWarnings("unused")
@FXML
void onCmdGenerate(ActionEvent evt) {
    try {
        String alias = validateAndGetAlias();
        CertGenerator generator = validateAndGetGenerator();
        GenerateCertRequest generateRequest = validateAndGetGenerateRequest(generator);
        getExecutorService().submit(new GenerateEntryTask(generator, generateRequest, alias));
    } catch (ValidationException e) {
        ValidationAlerts.error(e).showAndWait();
    }
}
Also used : CertGenerator(de.carne.certmgr.certs.spi.CertGenerator) ValidationException(de.carne.jfx.util.validation.ValidationException) GenerateCertRequest(de.carne.certmgr.certs.x509.GenerateCertRequest) FXML(javafx.fxml.FXML)

Example 8 with ValidationException

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

the class CertImportController method validateAndReloadDirectorySource.

private void validateAndReloadDirectorySource() {
    try {
        Path directorySource = validateDirectorySourceInput();
        getExecutorService().submit(new ReloadTask<Path>(directorySource) {

            @Override
            protected UserCertStore createStore(Path params) throws IOException {
                List<Path> files;
                try (Stream<Path> filesStream = Files.walk(params)) {
                    files = filesStream.filter(Files::isRegularFile).collect(Collectors.toList());
                }
                return UserCertStore.createFromFiles(files, 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) List(java.util.List) ArrayList(java.util.ArrayList) Stream(java.util.stream.Stream) IOException(java.io.IOException) UserCertStore(de.carne.certmgr.certs.UserCertStore)

Example 9 with ValidationException

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

the class CertImportController method validateServerSourceInput.

private ServerParams validateServerSourceInput() throws ValidationException {
    SSLPeer.Protocol protocol = InputValidator.notNull(this.ctlServerSourceProtocolInput.getValue(), CertImportI18N::formatSTR_MESSAGE_NO_SERVERPROTOCOL);
    String serverSourceInput = InputValidator.notEmpty(Strings.safeTrim(this.ctlServerSourceInput.getText()), CertImportI18N::formatSTR_MESSAGE_NO_SERVER);
    String[] serverSourceGroups = InputValidator.matches(serverSourceInput, SERVER_INPUT_PATTERN, CertImportI18N::formatSTR_MESSAGE_INVALID_SERVER);
    String host = serverSourceGroups[0];
    String portInput = serverSourceGroups[1];
    int port;
    if (portInput != null) {
        try {
            port = Integer.valueOf(portInput).intValue();
        } catch (NumberFormatException e) {
            throw new ValidationException(CertImportI18N.formatSTR_MESSAGE_INVALID_SERVER(serverSourceInput), e);
        }
    } else {
        port = protocol.defaultPort();
    }
    return new ServerParams(protocol, host, port);
}
Also used : SSLPeer(de.carne.certmgr.certs.net.SSLPeer) ValidationException(de.carne.jfx.util.validation.ValidationException)

Example 10 with ValidationException

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

the class CertImportController method validateAndReloadURLSource.

private void validateAndReloadURLSource() {
    try {
        URL urlSource = validateURLSourceInput();
        getExecutorService().submit(new ReloadTask<URL>(urlSource) {

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

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