use of org.xipki.security.pkcs11.P11Module in project xipki by xipki.
the class XiKeyStoreSpi 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.getIdentityIdentifiers();
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.getIdentityId());
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);
}
}
}
use of org.xipki.security.pkcs11.P11Module in project xipki by xipki.
the class P11TokenInfoCmd method execute0.
@Override
protected Object execute0() throws Exception {
P11Module module = getP11Module(moduleName);
println("module: " + moduleName);
println(module.getDescription());
List<P11SlotIdentifier> slots = module.getSlotIds();
if (slotIndex == null) {
output(slots);
return null;
}
P11Slot slot = getSlot(moduleName, slotIndex);
println("Details of slot");
slot.showDetails(System.out, verbose);
System.out.println();
System.out.flush();
return null;
}
use of org.xipki.security.pkcs11.P11Module in project xipki by xipki.
the class BSpeedP11Action method getSlot.
protected P11Slot getSlot() throws XiSecurityException, P11TokenException, IllegalCmdParamException {
P11CryptService p11Service = p11CryptServiceFactory.getP11CryptService(moduleName);
if (p11Service == null) {
throw new IllegalCmdParamException("undefined module " + moduleName);
}
P11Module module = p11Service.getModule();
P11SlotIdentifier slotId = module.getSlotIdForIndex(slotIndex);
return module.getSlot(slotId);
}
use of org.xipki.security.pkcs11.P11Module in project xipki by xipki.
the class SecurityAction method getSlot.
protected P11Slot getSlot(String moduleName, int slotIndex) throws XiSecurityException, P11TokenException, IllegalCmdParamException {
P11Module module = getP11Module(moduleName);
P11SlotIdentifier slotId = module.getSlotIdForIndex(slotIndex);
return module.getSlot(slotId);
}
use of org.xipki.security.pkcs11.P11Module in project xipki by xipki.
the class SpeedP11Action method getSlot.
protected P11Slot getSlot() throws XiSecurityException, P11TokenException, IllegalCmdParamException {
P11CryptService p11Service = p11CryptServiceFactory.getP11CryptService(moduleName);
if (p11Service == null) {
throw new IllegalCmdParamException("undefined module " + moduleName);
}
P11Module module = p11Service.getModule();
P11SlotIdentifier slotId = module.getSlotIdForIndex(slotIndex);
return module.getSlot(slotId);
}
Aggregations