public P11Identity getIdentity(P11SlotIdentifier slotId, P11ObjectIdentifier keyId) throws P11TokenException { P11Slot slot = module.getSlot(slotId); return (slot == null) ? null : slot.getIdentity(keyId); }
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
signatureAlgId = AlgorithmUtil.getSigAlgId(null, conf); } else { PublicKey pubKey = slot.getIdentity(identityId.getKeyId()).getPublicKey(); signatureAlgId = AlgorithmUtil.getSigAlgId(pubKey, conf);
public P11Identity getIdentity(P11SlotIdentifier slotId, P11ObjectIdentifier keyId) throws P11TokenException { P11Slot slot = module.getSlot(slotId); return (slot == null) ? null : slot.getIdentity(keyId); }
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
signatureAlgId = AlgorithmUtil.getSigAlgId(null, conf); } else { PublicKey pubKey = slot.getIdentity(identityId.getKeyId()).getPublicKey(); signatureAlgId = AlgorithmUtil.getSigAlgId(pubKey, conf);
public P11Identity getIdentity(final P11EntityIdentifier identityId) throws P11TokenException { ParamUtil.requireNonNull("identityId", identityId); return module.getSlot(identityId.slotId()).getIdentity(identityId.objectId()); }
/** * Exports the certificate of the given identifier {@code objectId}. * * @param objectId * Object identifier. Must not be {@code null}. * @return the exported certificate * @throws CertificateException * if process with certificate fails. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public X509Certificate exportCert(P11ObjectIdentifier objectId) throws P11TokenException { Args.notNull(objectId, "objectId"); try { return getIdentity(objectId).getCertificate(); } catch (P11UnknownEntityException ex) { // CHECKSTYLE:SKIP } X509Cert cert = certificates.get(objectId); if (cert == null) { throw new P11UnknownEntityException(slotId, objectId); } return cert.getCert(); }
/** * Exports the certificate of the given identifier {@code objectId}. * * @param objectId * Object identifier. Must not be {@code null}. * @return the exported certificate * @throws CertificateException * if process with certificate fails. * @throws P11TokenException * if PKCS#11 token exception occurs. */ public X509Certificate exportCert(P11ObjectIdentifier objectId) throws P11TokenException { ParamUtil.requireNonNull("objectId", objectId); try { return getIdentity(objectId).getCertificate(); } catch (P11UnknownEntityException ex) { // CHECKSTYLE:SKIP } X509Cert cert = certificates.get(objectId); if (cert == null) { throw new P11UnknownEntityException(slotId, objectId); } return cert.getCert(); }
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
signatureAlgId = AlgorithmUtil.getSigAlgId(null, conf); } else { PublicKey pubKey = slot.getIdentity(p11ObjId).publicKey(); signatureAlgId = AlgorithmUtil.getSigAlgId(pubKey, conf);