use of de.carne.certmgr.certs.UserCertStoreEntry in project certmgr by hdecarne.
the class CertExportController method getExportObjectList.
CertObjectStore getExportObjectList(boolean exportCert, boolean exportChain, boolean exportChainRoot, boolean exportKey, boolean exportCSR, boolean exportCRL) throws IOException {
CertObjectStore exportObjects = new CertObjectStore();
UserCertStoreEntry exportEntry = this.exportEntryParam.get();
String exportEntryAlias = exportEntry.id().getAlias();
if (exportKey) {
exportObjects.addKey(exportEntryAlias, exportEntry.getKey(PasswordDialog.enterPassword(this)));
}
if (exportCert) {
exportObjects.addCRT(exportEntryAlias, exportEntry.getCRT());
if (exportChain && !exportEntry.isSelfSigned()) {
UserCertStoreEntry issuer = exportEntry.issuer();
while (!issuer.isSelfSigned()) {
if (issuer.hasCRT()) {
exportObjects.addCRT(issuer.id().getAlias(), issuer.getCRT());
}
issuer = issuer.issuer();
}
if (exportChainRoot && issuer.hasCRT()) {
exportObjects.addCRT(issuer.id().getAlias(), issuer.getCRT());
}
}
}
if (exportCSR) {
exportObjects.addCSR(exportEntryAlias, exportEntry.getCSR());
}
if (exportCRL) {
exportObjects.addCRL(exportEntryAlias, exportEntry.getCRL());
}
return exportObjects;
}
use of de.carne.certmgr.certs.UserCertStoreEntry in project certmgr by hdecarne.
the class CertImportController method validateImportSelection.
private Set<UserCertStoreEntry> validateImportSelection() throws ValidationException {
Set<UserCertStoreEntry> importSelection = new HashSet<>();
forAllImportEntries(this.ctlImportEntryView.getRoot(), (i) -> {
ImportEntryModel importEntry = i.getValue();
if (importEntry != null && importEntry.getSelected().booleanValue()) {
UserCertStoreEntry selectedEntry = importEntry.getEntry();
if (!selectedEntry.isExternal()) {
importSelection.add(selectedEntry);
}
}
});
InputValidator.isTrue(!importSelection.isEmpty(), CertImportI18N::formatSTR_MESSAGE_EMPTY_IMPORT_SELECTION);
return importSelection;
}
use of de.carne.certmgr.certs.UserCertStoreEntry in project certmgr by hdecarne.
the class LocalCertGenerator method generateCert.
@Override
public CertObjectStore generateCert(GenerateCertRequest request, PasswordCallback password) throws IOException {
KeyPair key = KeyHelper.generateKey(request.keyPairAlgorithm(), request.keySize());
Issuer issuer = requiredParameter(request.getIssuer(), "Issuer");
BigInteger serial = BigInteger.ONE;
X500Principal issuerDN = null;
KeyPair issuerKey = null;
X500Principal dn = request.dn();
if (!this.selfSignedIssuer.equals(issuer)) {
UserCertStoreEntry issuerEntry = Check.notNull(issuer.storeEntry());
serial = getNextSerial(issuerEntry);
issuerDN = issuerEntry.dn();
issuerKey = issuerEntry.getKey(password);
} else {
issuerKey = key;
issuerDN = dn;
}
Date notBefore = requiredParameter(request.getNotBefore(), "NotBefore");
Date notAfter = requiredParameter(request.getNotAfter(), "NotAfter");
SignatureAlgorithm signatureAlgorithm = requiredParameter(request.getSignatureAlgorithm(), "SignatureAlgorithm");
X509Certificate crt = X509CertificateHelper.generateCRT(dn, key, serial, notBefore, notAfter, request.getExtensions(), issuerDN, issuerKey, signatureAlgorithm);
CertObjectStore certObjects = new CertObjectStore();
certObjects.addKey(key);
certObjects.addCRT(crt);
return certObjects;
}
use of de.carne.certmgr.certs.UserCertStoreEntry in project certmgr by hdecarne.
the class LocalCertGenerator method getIssuers.
@Override
public DefaultSet<Issuer> getIssuers(UserCertStore store, @Nullable UserCertStoreEntry defaultHint) {
DefaultSet<Issuer> issuers = new DefaultSet<>();
issuers.addDefault(this.selfSignedIssuer);
if (store != null) {
for (UserCertStoreEntry storeEntry : store.getEntries()) {
if (storeEntry.canIssue()) {
if (storeEntry.equals(defaultHint)) {
issuers.addDefault(new LocalIssuer(storeEntry));
} else {
issuers.add(new LocalIssuer(storeEntry));
}
}
}
}
return issuers;
}
use of de.carne.certmgr.certs.UserCertStoreEntry in project certmgr by hdecarne.
the class StoreController method onCmdCopyEntry.
@SuppressWarnings("unused")
@FXML
void onCmdCopyEntry(ActionEvent evt) {
UserCertStoreEntry entry = getSelectedStoreEntry();
if (entry != null) {
List<Path> entryFilePaths = entry.getFilePaths();
if (!entryFilePaths.isEmpty()) {
List<File> entryFiles = entryFilePaths.stream().map((p) -> p.toFile()).collect(Collectors.toList());
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putFiles(entryFiles);
clipboard.setContent(content);
}
}
}
Aggregations