/** * 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 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); }
/** * 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); } }
P11IdentityId identityId = identities.get(objectId).getId(); P11ObjectIdentifier pubKeyId = identityId.getPublicKeyId(); P11ObjectIdentifier certId = identityId.getCertId();
P11IdentityId identityId = identities.get(objectId).getId(); P11ObjectIdentifier pubKeyId = identityId.getPublicKeyId(); P11ObjectIdentifier certId = identityId.getCertId();
/** * 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); }
@Override protected void removeIdentity0(P11IdentityId identityId) throws P11TokenException { P11ObjectIdentifier keyId = identityId.getKeyId(); boolean b1 = true; if (identityId.getCertId() != null) { removePkcs11Entry(certDir, identityId.getCertId()); } boolean b2 = removePkcs11Entry(privKeyDir, keyId); boolean b3 = true; if (identityId.getPublicKeyId() != null) { b3 = removePkcs11Entry(pubKeyDir, identityId.getPublicKeyId()); } boolean b4 = removePkcs11Entry(secKeyDir, keyId); if (! (b1 || b2 || b3 || b4)) { throw new P11UnknownEntityException(slotId, keyId); } }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new SlotIdentifier(value.getSlotId())); vector.add(new ObjectIdentifier(value.getKeyId())); if (value.getPublicKeyId() != null) { String label = value.getPublicKeyId().getLabel(); vector.add(new DERTaggedObject(true, 1, new DERUTF8String(label))); } if (value.getCertId() != null) { String label = value.getCertId().getLabel(); vector.add(new DERTaggedObject(true, 2, new DERUTF8String(label))); } return new DERSequence(vector); }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new Asn1P11SlotIdentifier(value.getSlotId())); vector.add(new Asn1P11ObjectIdentifier(value.getKeyId())); if (value.getPublicKeyId() != null) { String label = value.getPublicKeyId().getLabel(); vector.add(new DERTaggedObject(true, 1, new DERUTF8String(label))); } if (value.getCertId() != null) { String label = value.getCertId().getLabel(); vector.add(new DERTaggedObject(true, 2, new DERUTF8String(label))); } return new DERSequence(vector); }
P11ObjectIdentifier certId = identityId.getCertId(); if (certId != null) { X509PublicKeyCertificate[] certs =