void destroySlot(final long slotId) { P11SlotIdentifier p11SlotId = null; for (P11SlotIdentifier si : slots.keySet()) { if (CompareUtil.equalsObject(si.id(), slotId)) { p11SlotId = si; break; } } if (p11SlotId != null) { slots.remove(p11SlotId); } }
@Override public P11SlotIdentifier getSlotIdForId(final long id) throws P11UnknownEntityException { for (P11SlotIdentifier slotId : slotIds) { if (slotId.id() == id) { return slotId; } } throw new P11UnknownEntityException("could not find slot with id " + id); }
boolean match(final P11SlotIdentifier slotId) { if (index != null) { if (index.intValue() != slotId.index()) { return false; } } if (id != null) { if (id.longValue() != slotId.id()) { return false; } } return true; }
File slotDir = new File(baseDir, slotId.index() + "-" + slotId.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 vector = new ASN1EncodableVector(); vector.add(new ASN1Integer(slotId.id())); vector.add(new ASN1Integer(slotId.index())); return new DERSequence(vector); }