use of de.carne.check.Nullable in project certmgr by hdecarne.
the class DNEditorController method getRdnInput.
@Nullable
Rdn getRdnInput() {
String typeInput = Strings.safeTrim(this.ctlTypeInput.getValue());
String valueInput = Strings.safeTrim(this.ctlValueInput.getText());
Rdn rdn = null;
if (Strings.isEmpty(typeInput)) {
Tooltips.show(this.ctlTypeInput, DNEditorI18N.formatSTR_MESSAGE_NO_TYPE(), Images.WARNING16);
} else if (Strings.isEmpty(valueInput)) {
Tooltips.show(this.ctlValueInput, DNEditorI18N.formatSTR_MESSAGE_NO_VALUE(), Images.WARNING16);
} else {
try {
rdn = new Rdn(typeInput, valueInput);
} catch (InvalidNameException e) {
Tooltips.show(this.ctlValueInput, DNEditorI18N.formatSTR_MESSAGE_INVALID_RDN(e.getLocalizedMessage()), Images.WARNING16);
}
}
return rdn;
}
use of de.carne.check.Nullable in project certmgr by hdecarne.
the class PasswordDialog method queryPasswordHelper.
@Nullable
private char[] queryPasswordHelper(Supplier<PasswordResult> query, boolean requery) {
PasswordResult passwordResult;
if (this.cancelAll) {
passwordResult = PasswordResult.CANCEL;
} else if (!requery && this.rememberedPassword != null) {
passwordResult = new PasswordResult(ButtonType.YES, this.rememberedPassword, true);
} else {
passwordResult = PlatformHelper.runLater(query);
}
ButtonData dialogResultData = passwordResult.dialogResult().getButtonData();
if (dialogResultData == ButtonData.YES) {
this.cancelAll = false;
this.rememberedPassword = (passwordResult.rememberPassword() ? passwordResult.password() : null);
} else if (dialogResultData == ButtonData.NO) {
this.cancelAll = false;
this.rememberedPassword = null;
} else {
this.cancelAll = true;
this.rememberedPassword = null;
}
return passwordResult.password();
}
use of de.carne.check.Nullable in project certmgr by hdecarne.
the class CertOptionsTemplates method load.
public static List<Template> load() {
List<Template> templates = new ArrayList<>();
try {
Preferences templateStore;
if (TEMPLATE_STORE_INITIALIZED.getBoolean(false)) {
templateStore = TEMPLATE_STORE;
} else {
try (InputStream standardTemplatesStream = getStandardTemplatesUrl().openStream()) {
Properties standardTemplates = new Properties();
standardTemplates.load(standardTemplatesStream);
templateStore = FilePreferencesFactory.customRoot(standardTemplates);
}
}
String[] templateNodeNames = templateStore.childrenNames();
Arrays.sort(templateNodeNames);
for (String templateNodeName : templateNodeNames) {
Preferences templateNode = templateStore.node(templateNodeName);
@Nullable Template template = loadTemplate(templateNode);
if (template != null) {
templates.add(template);
}
}
} catch (IOException | BackingStoreException e) {
Exceptions.warn(e);
}
return templates;
}
use of de.carne.check.Nullable in project certmgr by hdecarne.
the class CertOptionsTemplates method loadTemplate.
@Nullable
private static Template loadTemplate(Preferences templateNode) {
@Nullable Template template = null;
@Nullable String name = templateNode.get(Template.KEY_NAME, null);
@Nullable String aliasInput = templateNode.get(Template.KEY_ALIAS, null);
@Nullable String dnInput = templateNode.get(Template.KEY_DN, null);
if (Strings.notEmpty(name) && Strings.notEmpty(aliasInput) && Strings.notEmpty(dnInput)) {
assert name != null;
assert aliasInput != null;
assert dnInput != null;
template = new Template(name, new CertOptionsPreset(aliasInput, dnInput));
@Nullable String keyAlg = templateNode.get(Template.KEY_KEYALG, null);
if (keyAlg != null) {
template.setKeyAlg(KeyHelper.getKeyAlg(keyAlg));
}
int keySize = templateNode.getInt(Template.KEY_KEYSIZE, 0);
if (keySize != 0) {
template.setKeySize(keySize);
}
try {
String[] extensionNodeNames = templateNode.childrenNames();
for (String extensionNodeName : extensionNodeNames) {
Preferences extensionNode = templateNode.node(extensionNodeName);
@Nullable String oid = extensionNode.get(Template.KEY_EXTENSION_OID, null);
boolean criticial = extensionNode.getBoolean(Template.KEY_EXTENSION_CRITICAL, false);
@Nullable byte[] data = extensionNode.getByteArray(Template.KEY_EXTENSION_DATA, null);
if (Strings.notEmpty(oid) && data != null) {
assert oid != null;
template.addExtension(X509ExtensionData.decode(oid, criticial, data));
} else {
LOG.warning("Ignoring incomplete extension node ''{0}''", extensionNode.absolutePath());
}
}
} catch (BackingStoreException | IOException e) {
LOG.warning(e, "Ignoring inaccessible extension data for template node ''{0}''", templateNode.absolutePath());
}
} else {
LOG.warning("Ignoring incomplete template node ''{0}''", templateNode.absolutePath());
}
return template;
}
use of de.carne.check.Nullable in project certmgr by hdecarne.
the class CRLOptionsController method validateAndGetNextUpdate.
@Nullable
private Date validateAndGetNextUpdate(Date lastUpdate) throws ValidationException {
LocalDate localNextUpdate = this.ctlNextUpdateInput.getValue();
Date nextUpdate = (localNextUpdate != null ? Date.from(localNextUpdate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) : null);
if (nextUpdate != null) {
InputValidator.isTrue(nextUpdate.compareTo(lastUpdate) > 0, (a) -> CRLOptionsI18N.formatSTR_MESSAGE_INVALID_UPDATEDATES(lastUpdate, nextUpdate));
}
return nextUpdate;
}
Aggregations