use of de.carne.check.Nullable in project certmgr by hdecarne.
the class UserCertStore method matchPKCS10CertificateRequest.
@Nullable
private Entry matchPKCS10CertificateRequest(PKCS10CertificateRequest csr) throws IOException {
X500Principal csrDN = csr.getSubjectX500Principal();
PublicKey csrPublicKey = csr.getPublicKey();
Entry matchingEntry = null;
for (Entry entry : this.storeEntries.values()) {
if (csrDN.equals(entry.dn()) && entry.hasPublicKey() && Arrays.equals(csrPublicKey.getEncoded(), entry.getPublicKey().getEncoded())) {
matchingEntry = entry;
break;
}
if (entry.hasCRL() && X509CRLHelper.isCRLSignedBy(entry.getCRL(), csrPublicKey)) {
matchingEntry = entry;
break;
}
}
return matchingEntry;
}
use of de.carne.check.Nullable in project certmgr by hdecarne.
the class KeyPairAlgorithm method getDefaultSet.
/**
* Get the available key pair algorithms.
*
* @param defaultHint The default to return (may be {@code null}). If this algorithm is contained in the default
* set, it is also set as the default.
* @param expertMode Whether only standard algorithms are considered ({@code false}) or all algorithms available on
* the current platform ({@code true}).
* @return The available key pair algorithms
*/
public static DefaultSet<KeyPairAlgorithm> getDefaultSet(@Nullable String defaultHint, boolean expertMode) {
DefaultSet<KeyPairAlgorithm> keyPairAlgorithms = new DefaultSet<>();
DefaultSet<String> defaultNames = SecurityDefaults.getKeyAlgorithmNames();
@Nullable String defaultName = (defaultHint != null && defaultNames.contains(defaultHint) ? defaultHint : defaultNames.getDefault());
for (Provider provider : SecurityDefaults.getProviders(expertMode)) {
for (Provider.Service service : provider.getServices()) {
if (!SERVICE_TYPE_KEY_PAIR_GENERATOR.equals(service.getType())) {
continue;
}
String algorithm = service.getAlgorithm();
if (!expertMode && !defaultNames.contains(algorithm)) {
continue;
}
KeyPairAlgorithm keyPairAlgorithm = (expertMode ? new ExpertKeyPairAlgorithm(service) : new StandardKeyPairAlgorithm(service));
if (algorithm.equals(defaultName)) {
keyPairAlgorithms.addDefault(keyPairAlgorithm);
} else {
keyPairAlgorithms.add(keyPairAlgorithm);
}
}
}
return keyPairAlgorithms;
}
use of de.carne.check.Nullable in project certmgr by hdecarne.
the class CertMgrApplication method evalCmdLine.
@Nullable
private File evalCmdLine() {
CmdLineProcessor cmdLine = new CmdLineProcessor("certmgr", getParameters().getRaw());
List<String> defaultArgs = new ArrayList<>();
cmdLine.onSwitch((s) -> applyLogConfig(Logs.CONFIG_VERBOSE)).arg("--verbose");
cmdLine.onSwitch((s) -> applyLogConfig(Logs.CONFIG_DEBUG)).arg("--debug");
cmdLine.onUnnamedOption((s) -> defaultArgs.add(s));
try {
cmdLine.process();
LOG.info("Running command line ''{0}''", cmdLine);
} catch (CmdLineException e) {
LOG.warning(e, "Invalid command line ''{0}''; ", cmdLine);
}
File defaultStoreHome = null;
for (String defaultArg : defaultArgs) {
if (defaultStoreHome == null) {
defaultStoreHome = new File(defaultArg);
} else {
LOG.warning("Ignoring extra store home argument ''{0}''", defaultStoreHome);
}
}
return defaultStoreHome;
}
use of de.carne.check.Nullable in project certmgr by hdecarne.
the class PreferencesController method call.
@Override
@Nullable
public UserPreferences call(@Nullable ButtonType param) {
UserPreferences dialogResult = null;
if (param != null && ButtonType.APPLY.getButtonData() == param.getButtonData()) {
this.preferencesParam.get().expertMode.put(this.ctlExpertModeOption.isSelected());
try {
this.preferencesParam.get().sync();
dialogResult = this.preferencesParam.get();
} catch (BackingStoreException e) {
Alerts.unexpected(e).showAndWait();
}
}
return dialogResult;
}
use of de.carne.check.Nullable in project certmgr by hdecarne.
the class StoreController method setupStage.
@Override
protected void setupStage(Stage stage) {
stage.getIcons().addAll(Images.STORE32, Images.STORE16);
stage.setTitle(StoreI18N.formatSTR_STAGE_TITLE());
this.cmdStorePreferences.disableProperty().bind(this.storeProperty.isNull());
this.cmdCopyEntry.disableProperty().bind(this.ctlStoreEntryView.getSelectionModel().selectedItemProperty().isNull());
this.cmdDeleteEntry.disableProperty().bind(this.ctlStoreEntryView.getSelectionModel().selectedItemProperty().isNull());
this.cmdNewCert.disableProperty().bind(this.storeProperty.isNull());
this.cmdRevokeCert.disableProperty().bind(this.ctlStoreEntryView.getSelectionModel().selectedItemProperty().isNull());
this.cmdManageCRL.disableProperty().bind(this.ctlStoreEntryView.getSelectionModel().selectedItemProperty().isNull());
this.cmdExportCert.disableProperty().bind(this.ctlStoreEntryView.getSelectionModel().selectedItemProperty().isNull());
this.cmdImportCerts.disableProperty().bind(this.storeProperty.isNull());
this.cmdStorePreferencesButton.disableProperty().bind(this.storeProperty.isNull());
this.cmdCopyEntryButton.disableProperty().bind(this.cmdCopyEntry.disableProperty());
this.cmdDeleteEntryButton.disableProperty().bind(this.cmdDeleteEntry.disableProperty());
this.cmdNewCertButton.disableProperty().bind(this.cmdNewCert.disableProperty());
this.cmdRevokeCertButton.disableProperty().bind(this.cmdRevokeCert.disableProperty());
this.cmdManageCRLButton.disableProperty().bind(this.cmdManageCRL.disableProperty());
this.cmdExportCertButton.disableProperty().bind(this.cmdExportCert.disableProperty());
this.cmdImportCertsButton.disableProperty().bind(this.cmdImportCerts.disableProperty());
ContextMenu storeEntryViewMenu = this.ctlStoreEntryView.getContextMenu();
this.ctlStoreEntryView.setContextMenu(null);
this.ctlStoreEntryView.setRowFactory(param -> {
ContextMenu menu = storeEntryViewMenu;
return new TreeTableRow<StoreEntryModel>() {
@Override
protected void updateItem(@Nullable StoreEntryModel item, boolean empty) {
super.updateItem(item, empty);
if (!empty) {
setContextMenu(menu);
} else {
setContextMenu(null);
}
}
};
});
Tooltip storeEntryViewTooltip = this.ctlStoreEntryView.getTooltip();
this.ctlStoreEntryTooltipExternalCrt.managedProperty().bind(this.ctlStoreEntryTooltipExternalCrt.visibleProperty());
this.ctlStoreEntryTooltipPublicCrt.managedProperty().bind(this.ctlStoreEntryTooltipPublicCrt.visibleProperty());
this.ctlStoreEntryTooltipPrivateCrt.managedProperty().bind(this.ctlStoreEntryTooltipPrivateCrt.visibleProperty());
this.ctlStoreEntryTooltipCsr.managedProperty().bind(this.ctlStoreEntryTooltipCsr.visibleProperty());
this.ctlStoreEntryTooltipCrl.managedProperty().bind(this.ctlStoreEntryTooltipCrl.visibleProperty());
this.ctlStoreEntryTooltipKey.managedProperty().bind(this.ctlStoreEntryTooltipKey.visibleProperty());
this.ctlStoreEntryTooltipRevokedCrt.managedProperty().bind(this.ctlStoreEntryTooltipRevokedCrt.visibleProperty());
this.ctlStoreEntryTooltipInvalidCrt.managedProperty().bind(this.ctlStoreEntryTooltipInvalidCrt.visibleProperty());
this.ctlStoreEntryView.setTooltip(null);
this.ctlStoreEntryViewId.setCellFactory(param -> {
return new TreeTableCell<StoreEntryModel, String>() {
Tooltip tooltip = storeEntryViewTooltip;
@Override
protected void updateItem(@Nullable String item, boolean empty) {
if (!empty) {
setTooltip(this.tooltip);
setOnMouseEntered(StoreController.this::onStoreViewItemMouseEntered);
setText(item);
} else {
setTooltip(null);
setOnMouseEntered(null);
setText(null);
}
}
};
});
this.ctlStoreEntryViewId.setCellValueFactory(new TreeItemPropertyValueFactory<>("id"));
this.ctlStoreEntryViewName.setCellValueFactory(new TreeItemPropertyValueFactory<>("name"));
this.ctlStoreEntryViewSerial.setCellValueFactory(new TreeItemPropertyValueFactory<>("serial"));
this.ctlStoreEntryViewExpires.setCellValueFactory(new TreeItemPropertyValueFactory<>("expires"));
ContextMenu detailsViewMenu = this.ctlDetailsView.getContextMenu();
this.ctlDetailsView.setContextMenu(null);
this.ctlDetailsView.setRowFactory(param -> {
ContextMenu menu = detailsViewMenu;
return new TreeTableRow<AttributeModel>() {
@Override
protected void updateItem(@Nullable AttributeModel item, boolean empty) {
super.updateItem(item, empty);
if (!empty) {
setContextMenu(menu);
} else {
setContextMenu(null);
}
}
};
});
this.ctlDetailsViewName.setCellValueFactory(new TreeItemPropertyValueFactory<>("name"));
this.ctlDetailsViewValue.setCellValueFactory(new TreeItemPropertyValueFactory<>("value"));
this.ctlStoreEntryView.getSelectionModel().selectedItemProperty().addListener((p, o, n) -> onStoreViewSelectionChanged(n));
Windows.onHiding(stage, (ScheduledFuture<?> f) -> f.cancel(true), getExecutorService().scheduleAtFixedRate(PlatformHelper.runLaterRunnable(() -> onUpdateHeapStatus()), 0, 500, TimeUnit.MILLISECONDS));
}
Aggregations