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;
}
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();
}
}
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();
}
}
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);
}
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();
}
}
Aggregations