identities.putAll(res.getIdentities()); updateCaCertsOfIdentities();
identities.putAll(res.getIdentities()); updateCaCertsOfIdentities();
/** * Removes the key (private key, public key, secret key, and certificates) associated with * the given identifier {@code objectId}. * * @param keyId * Key identifier. Must not be {@code null}. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public void removeIdentityByKeyId(P11ObjectIdentifier keyId) throws P11TokenException { ParamUtil.requireNonNull("keyId", keyId); assertWritable("removeIdentityByKeyId"); P11IdentityId entityId = null; if (identities.containsKey(keyId)) { entityId = identities.get(keyId).getId(); if (entityId.getCertId() != null) { certificates.remove(entityId.getCertId()); } identities.get(keyId).setCertificates(null); identities.remove(keyId); updateCaCertsOfIdentities(); removeIdentity0(entityId); } }
/** * Removes the key (private key, public key, secret key, and certificates) associated with * the given identifier {@code objectId}. * * @param keyId * Key identifier. Must not be {@code null}. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public void removeIdentityByKeyId(P11ObjectIdentifier keyId) throws P11TokenException { Args.notNull(keyId, "keyId"); assertWritable("removeIdentityByKeyId"); P11IdentityId entityId = null; if (identities.containsKey(keyId)) { entityId = identities.get(keyId).getId(); if (entityId.getCertId() != null) { certificates.remove(entityId.getCertId()); } identities.get(keyId).setCertificates(null); identities.remove(keyId); updateCaCertsOfIdentities(); removeIdentity0(entityId); } }
/** * Removes the key (private key, public key, secret key, and certificates) associated with * the given identifier {@code objectId}. * * @param identityId * Identity identifier. Must not be {@code null}. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public void removeIdentity(P11IdentityId identityId) throws P11TokenException { Args.notNull(identityId, "identityId"); assertWritable("removeIdentity"); P11ObjectIdentifier keyId = identityId.getKeyId(); if (identities.containsKey(keyId)) { if (identityId.getCertId() != null) { certificates.remove(identityId.getCertId()); } identities.get(keyId).setCertificates(null); identities.remove(keyId); updateCaCertsOfIdentities(); } removeIdentity0(identityId); }
/** * Removes the key (private key, public key, secret key, and certificates) associated with * the given identifier {@code objectId}. * * @param identityId * Identity identifier. Must not be {@code null}. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public void removeIdentity(P11IdentityId identityId) throws P11TokenException { ParamUtil.requireNonNull("identityId", identityId); assertWritable("removeIdentity"); P11ObjectIdentifier keyId = identityId.getKeyId(); if (identities.containsKey(keyId)) { if (identityId.getCertId() != null) { certificates.remove(identityId.getCertId()); } identities.get(keyId).setCertificates(null); identities.remove(keyId); updateCaCertsOfIdentities(); } removeIdentity0(identityId); }
/** * TODO. * @param objectId * Object identifier. Must not be {@code null}. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public void removeCerts(P11ObjectIdentifier objectId) throws P11TokenException { Args.notNull(objectId, "objectId"); assertWritable("removeCerts"); P11ObjectIdentifier keyId = null; for (P11ObjectIdentifier m : identities.keySet()) { P11Identity identity = identities.get(m); if (objectId.equals(identity.getId().getCertId())) { keyId = m; break; } } if (keyId != null) { certificates.remove(objectId); identities.get(keyId).setCertificates(null); } else if (certificates.containsKey(objectId)) { certificates.remove(objectId); } else { throw new P11UnknownEntityException(slotId, objectId); } updateCaCertsOfIdentities(); removeCerts0(objectId); }
/** * TODO. * @param objectId * Object identifier. Must not be {@code null}. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public void removeCerts(P11ObjectIdentifier objectId) throws P11TokenException { ParamUtil.requireNonNull("objectId", objectId); assertWritable("removeCerts"); P11ObjectIdentifier keyId = null; for (P11ObjectIdentifier m : identities.keySet()) { P11Identity identity = identities.get(m); if (objectId.equals(identity.getId().getCertId())) { keyId = m; break; } } if (keyId != null) { certificates.remove(objectId); identities.get(keyId).setCertificates(null); } else if (certificates.containsKey(objectId)) { certificates.remove(objectId); } else { throw new P11UnknownEntityException(slotId, objectId); } updateCaCertsOfIdentities(); removeCerts0(objectId); }
updateCaCertsOfIdentities(); LOG.info("updated certificate for key {}", keyId);
/** * Adds the certificate to the PKCS#11 token under the given identifier {@code objectId}. * * @param cert * Certificate to be added. Must not be {@code null}. * @param control * Control of the object creation process. Must not be {@code null}. * @throws CertificateException * if process with certificate fails. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public P11ObjectIdentifier addCert(X509Certificate cert, P11NewObjectControl control) throws P11TokenException, CertificateException { Args.notNull(cert, "cert"); Args.notNull(control, "control"); assertWritable("addCert"); if (control.getLabel() == null) { String cn = X509Util.getCommonName(cert.getSubjectX500Principal()); control = new P11NewObjectControl(control.getId(), generateLabel(cn)); } P11ObjectIdentifier objectId = addCert0(cert, control); certificates.put(objectId, new X509Cert(cert)); updateCaCertsOfIdentities(); LOG.info("added certificate {}", objectId); return objectId; }
identityId.setCertLabel(keyId.getLabel()); identity.setCertificates(new X509Certificate[]{newCert}); updateCaCertsOfIdentities(); LOG.info("updated certificate for key {}", keyId);
/** * Adds the certificate to the PKCS#11 token under the given identifier {@code objectId}. * * @param cert * Certificate to be added. Must not be {@code null}. * @param control * Control of the object creation process. Must not be {@code null}. * @throws CertificateException * if process with certificate fails. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public P11ObjectIdentifier addCert(X509Certificate cert, P11NewObjectControl control) throws P11TokenException, CertificateException { ParamUtil.requireNonNull("cert", cert); ParamUtil.requireNonNull("control", control); assertWritable("addCert"); if (control.getLabel() == null) { String cn = X509Util.getCommonName(cert.getSubjectX500Principal()); control = new P11NewObjectControl(control.getId(), generateLabel(cn)); } P11ObjectIdentifier objectId = addCert0(cert, control); certificates.put(objectId, new X509Cert(cert)); updateCaCertsOfIdentities(); LOG.info("added certificate {}", objectId); return objectId; }