use of de.carne.certmgr.certs.x509.PKCS10CertificateRequest in project certmgr by hdecarne.
the class RemoteCertGenerator method generateCert.
@Override
public CertObjectStore generateCert(GenerateCertRequest request, PasswordCallback password) throws IOException {
KeyPair key = KeyHelper.generateKey(request.keyPairAlgorithm(), request.keySize());
SignatureAlgorithm signatureAlgorithm = requiredParameter(request.getSignatureAlgorithm(), "SignatureAlgorithm");
PKCS10CertificateRequest csr = PKCS10CertificateRequest.generateCSR(request.dn(), key, request.getExtensions(), signatureAlgorithm);
CertObjectStore certObjects = new CertObjectStore();
certObjects.addKey(key);
certObjects.addCSR(csr);
return certObjects;
}
use of de.carne.certmgr.certs.x509.PKCS10CertificateRequest in project certmgr by hdecarne.
the class StoreController method updateDetailsView.
private void updateDetailsView(@Nullable TreeItem<StoreEntryModel> selection) {
TreeItem<AttributeModel> rootItem = null;
if (selection != null) {
rootItem = new TreeItem<>();
rootItem.setExpanded(true);
UserCertStoreEntry entry = selection.getValue().getEntry();
updateDetailsViewHelper(rootItem, Attributes.toAttributes(entry), true);
if (entry.hasCRT()) {
try {
X509Certificate crt = entry.getCRT();
updateDetailsViewHelper(rootItem, X509CertificateHelper.toAttributes(crt), true);
} catch (IOException e) {
Exceptions.warn(e);
}
}
if (entry.hasCSR()) {
try {
PKCS10CertificateRequest csr = entry.getCSR();
updateDetailsViewHelper(rootItem, csr.toAttributes(), true);
} catch (IOException e) {
Exceptions.ignore(e);
}
}
if (entry.hasCRL()) {
try {
X509CRL crl = entry.getCRL();
updateDetailsViewHelper(rootItem, X509CRLHelper.toAttributes(crl), true);
} catch (IOException e) {
Exceptions.ignore(e);
}
}
}
this.ctlDetailsView.setRoot(rootItem);
}
use of de.carne.certmgr.certs.x509.PKCS10CertificateRequest in project certmgr by hdecarne.
the class DERCertReaderWriter method readBinary.
@Override
@Nullable
public CertObjectStore readBinary(IOResource<InputStream> in, PasswordCallback password) throws IOException {
LOG.debug("Trying to read DER objects from: ''{0}''...", in);
CertObjectStore certObjects = null;
try (ASN1InputStream derStream = new ASN1InputStream(in.io())) {
ASN1Primitive derObject;
while ((derObject = derStream.readObject()) != null) {
X509Certificate crt = tryDecodeCRT(derObject);
if (crt != null) {
if (certObjects == null) {
certObjects = new CertObjectStore();
}
certObjects.addCRT(crt);
continue;
}
KeyPair key = tryDecodeKey(derObject, in.resource(), password);
if (key != null) {
if (certObjects == null) {
certObjects = new CertObjectStore();
}
certObjects.addKey(key);
continue;
}
PKCS10CertificateRequest csr = tryDecodeCSR(derObject);
if (csr != null) {
if (certObjects == null) {
certObjects = new CertObjectStore();
}
certObjects.addCSR(csr);
continue;
}
X509CRL crl = tryDecodeCRL(derObject);
if (crl != null) {
if (certObjects == null) {
certObjects = new CertObjectStore();
}
certObjects.addCRL(crl);
continue;
}
LOG.warning(CertIOI18N.STR_DER_UNKNOWN_OBJECT, derObject.getClass().getName());
}
} catch (ClassCastException e) {
// the file is not a DER stream
throw new CertProviderException(e);
}
return certObjects;
}
use of de.carne.certmgr.certs.x509.PKCS10CertificateRequest in project certmgr by hdecarne.
the class UserCertStore method loadPersistentEntries.
private synchronized void loadPersistentEntries(Map<UserCertStoreEntryId, PersistentEntry> entries) throws IOException {
for (Map.Entry<UserCertStoreEntryId, PersistentEntry> persistentEntryPathsEntry : entries.entrySet()) {
UserCertStoreEntryId entryId = persistentEntryPathsEntry.getKey();
PersistentEntry entry = persistentEntryPathsEntry.getValue();
CertObjectHolder<X509Certificate> crtHolder = entry.crt();
SecureCertObjectHolder<KeyPair> keyHolder = entry.key();
CertObjectHolder<PKCS10CertificateRequest> csrHolder = entry.csr();
CertObjectHolder<X509CRL> crlHolder = entry.crl();
X500Principal entryDN = null;
if (crtHolder != null) {
entryDN = crtHolder.get().getSubjectX500Principal();
} else if (csrHolder != null) {
entryDN = csrHolder.get().getSubjectX500Principal();
} else if (crlHolder != null) {
entryDN = crlHolder.get().getIssuerX500Principal();
} else {
LOG.warning("Ignoring incompliete store entry ''{0}''", entryId);
}
if (entryDN != null) {
Entry storeEntry = new Entry(entryId, entryDN, crtHolder, keyHolder, csrHolder, crlHolder);
this.storeEntries.put(entryId, storeEntry);
}
}
resetIssuers();
}
Aggregations