@Override public P11ObjectIdentifier getObjectIdForLabel(final String label) { for (P11ObjectIdentifier objectId : identities.keySet()) { if (objectId.label().equals(label)) { return objectId; } } for (P11ObjectIdentifier objectId : certificates.keySet()) { if (objectId.label().equals(label)) { return objectId; } } return null; }
protected String generateLabel(final String label) throws P11TokenException { String tmpLabel = label; int idx = 0; while (true) { boolean duplicated = false; for (P11ObjectIdentifier objectId : identities.keySet()) { if (objectId.label().equals(label)) { duplicated = true; break; } } if (!duplicated) { for (P11ObjectIdentifier objectId : certificates.keySet()) { if (objectId.label().equals(label)) { duplicated = true; break; } } } if (!duplicated) { return tmpLabel; } idx++; tmpLabel = label + "-" + idx; } }
public boolean match(final P11SlotIdentifier slotId, final String objectLabel) { ParamUtil.requireNonNull("objectLabel", objectLabel); return this.slotId.equals(slotId) && objectLabel.equals(this.objectId.label()); }
@Override protected void addCert0(final P11ObjectIdentifier objectId, final X509Certificate cert) throws P11TokenException, CertificateException { savePkcs11Cert(objectId.id(), objectId.label(), cert); }
for (int i = 0; i < size; i++) { P11ObjectIdentifier objectId = sortedObjectIds.get(i); sb.append("\t").append(i + 1).append(". ").append(objectId.label()); sb.append(" (").append("id: ").append(objectId.idHex()).append(")\n"); P11Identity identity = identities.get(objectId); for (int i = 0; i < size; i++) { P11ObjectIdentifier objectId = sortedObjectIds.get(i); sb.append("\tCert-").append(i + 1).append(". ").append(objectId.label()); sb.append(" (").append("id: ").append(objectId.label()).append(")\n"); formatString(null, verbose, sb, certificates.get(objectId).cert());
private boolean removePkcs11Entry(final File dir, final P11ObjectIdentifier objectId) throws P11TokenException { byte[] id = objectId.id(); String label = objectId.label(); if (id != null) { String hextId = Hex.toHexString(id);
private void engineLoad(final String moduleName) throws P11TokenException, XiSecurityException { P11CryptService p11Service = p11CryptServiceFactory.getP11CryptService(moduleName); P11Module module = p11Service.module(); List<P11SlotIdentifier> slotIds = module.slotIdentifiers(); for (P11SlotIdentifier slotId: slotIds) { P11Slot slot = module.getSlot(slotId); Set<P11ObjectIdentifier> identityIds = slot.identityIdentifiers(); for (P11ObjectIdentifier objId : identityIds) { P11Identity identity = slot.getIdentity(objId); X509Certificate[] chain = identity.certificateChain(); if (chain == null || chain.length == 0) { continue; } P11PrivateKey key = new P11PrivateKey(p11Service, identity.identityId()); KeyCertEntry keyCertEntry = new KeyCertEntry(key, chain); keyCerts.put(moduleName + "#slotid-" + slotId.id() + "#keyid-" + objId.idHex(), keyCertEntry); keyCerts.put(moduleName + "#slotid-" + slotId.id() + "#keylabel-" + objId.label(), keyCertEntry); keyCerts.put(moduleName + "#slotindex-" + slotId.index() + "#keyid-" + objId.idHex(), keyCertEntry); keyCerts.put(moduleName + "#slotindex-" + slotId.index() + "#keylabel-" + objId.label(), keyCertEntry); } } } // method engineLoad
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vec = new ASN1EncodableVector(); vec.add(new DEROctetString(objectId.id())); vec.add(new DERUTF8String(objectId.label())); return new DERSequence(vec); }