@Override public P11SlotIdentifier getSlotIdForId(long id) throws P11UnknownEntityException { for (P11SlotIdentifier slotId : slotIds) { if (slotId.getId() == id) { return slotId; } } throw new P11UnknownEntityException("could not find slot with id " + id); }
public P11SlotIdentifier getSlotIdForId(long id) throws P11UnknownEntityException { for (P11SlotIdentifier slotId : slotIds) { if (slotId.getId() == id) { return slotId; } } throw new P11UnknownEntityException("could not find slot with id " + id); }
void destroySlot(long slotId) { P11SlotIdentifier p11SlotId = null; for (P11SlotIdentifier si : slots.keySet()) { if (CompareUtil.equalsObject(si.getId(), slotId)) { p11SlotId = si; break; } } if (p11SlotId != null) { slots.remove(p11SlotId); } }
void destroySlot(long slotId) { P11SlotIdentifier p11SlotId = null; for (P11SlotIdentifier si : slots.keySet()) { if (CompareUtil.equalsObject(si.getId(), slotId)) { p11SlotId = si; break; } } if (p11SlotId != null) { slots.remove(p11SlotId); } }
boolean match(P11SlotIdentifier slotId) { if (index != null) { if (index.intValue() != slotId.getIndex()) { return false; } } if (id != null) { if (id.longValue() != slotId.getId()) { return false; } } return true; }
boolean match(P11SlotIdentifier slotId) { if (index != null) { if (index.intValue() != slotId.getIndex()) { return false; } } if (id != null) { if (id.longValue() != slotId.getId()) { return false; } } return true; }
File slotDir = new File(baseDir, slotId.getIndex() + "-" + slotId.getId());
private void engineLoad(String moduleName) throws P11TokenException, XiSecurityException { P11CryptService p11Service = p11CryptServiceFactory.getP11CryptService(moduleName); P11Module module = p11Service.getModule(); List<P11SlotIdentifier> slotIds = module.getSlotIds(); for (P11SlotIdentifier slotId: slotIds) { P11Slot slot = module.getSlot(slotId); Set<P11ObjectIdentifier> identityIds = slot.getIdentityKeyIds(); 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.getId()); KeyCertEntry keyCertEntry = new KeyCertEntry(key, chain); keyCerts.put(moduleName + "#slotid-" + slotId.getId() + "#keyid-" + objId.getIdHex(), keyCertEntry); keyCerts.put(moduleName + "#slotid-" + slotId.getId() + "#keylabel-" + objId.getLabel(), keyCertEntry); keyCerts.put(moduleName + "#slotindex-" + slotId.getIndex() + "#keyid-" + objId.getIdHex(), keyCertEntry); keyCerts.put(moduleName + "#slotindex-" + slotId.getIndex() + "#keylabel-" + objId.getLabel(), keyCertEntry); } } } // method engineLoad
private void engineLoad(String moduleName) throws P11TokenException, XiSecurityException { P11CryptService p11Service = p11CryptServiceFactory.getP11CryptService(moduleName); P11Module module = p11Service.getModule(); List<P11SlotIdentifier> slotIds = module.getSlotIds(); for (P11SlotIdentifier slotId: slotIds) { P11Slot slot = module.getSlot(slotId); Set<P11ObjectIdentifier> identityIds = slot.getIdentityKeyIds(); 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.getId()); KeyCertEntry keyCertEntry = new KeyCertEntry(key, chain); keyCerts.put(moduleName + "#slotid-" + slotId.getId() + "#keyid-" + objId.getIdHex(), keyCertEntry); keyCerts.put(moduleName + "#slotid-" + slotId.getId() + "#keylabel-" + objId.getLabel(), keyCertEntry); keyCerts.put(moduleName + "#slotindex-" + slotId.getIndex() + "#keyid-" + objId.getIdHex(), keyCertEntry); keyCerts.put(moduleName + "#slotindex-" + slotId.getIndex() + "#keylabel-" + objId.getLabel(), keyCertEntry); } } } // method engineLoad
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new ASN1Integer(value.getId())); vector.add(new ASN1Integer(value.getIndex())); return new DERSequence(vector); }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new ASN1Integer(value.getId())); vector.add(new ASN1Integer(value.getIndex())); return new DERSequence(vector); }