use of iaik.pkcs.pkcs11.objects.Storage in project xipki by xipki.
the class IaikP11Slot method getAllSecretKeyObjects.
private List<SecretKey> getAllSecretKeyObjects(Session session) throws P11TokenException {
SecretKey template = new SecretKey();
List<Storage> tmpObjects = getObjects(session, template);
if (CollectionUtil.isEmpty(tmpObjects)) {
return Collections.emptyList();
}
final int n = tmpObjects.size();
LOG.info("found {} private keys", n);
List<SecretKey> keys = new ArrayList<>(n);
for (Storage tmpObject : tmpObjects) {
SecretKey key = (SecretKey) tmpObject;
keys.add(key);
}
return keys;
}
use of iaik.pkcs.pkcs11.objects.Storage in project xipki by xipki.
the class IaikP11Slot method getAllPrivateObjects.
private List<PrivateKey> getAllPrivateObjects(Session session) throws P11TokenException {
PrivateKey template = new PrivateKey();
List<Storage> tmpObjects = getObjects(session, template);
if (CollectionUtil.isEmpty(tmpObjects)) {
return Collections.emptyList();
}
final int n = tmpObjects.size();
LOG.info("found {} private keys", n);
List<PrivateKey> privateKeys = new ArrayList<>(n);
for (Storage tmpObject : tmpObjects) {
PrivateKey privateKey = (PrivateKey) tmpObject;
privateKeys.add(privateKey);
}
return privateKeys;
}
use of iaik.pkcs.pkcs11.objects.Storage in project xipki by xipki.
the class IaikP11Slot method getCertificateObjects.
private X509PublicKeyCertificate[] getCertificateObjects(Session session, byte[] keyId, char[] keyLabel) throws P11TokenException {
X509PublicKeyCertificate template = new X509PublicKeyCertificate();
if (keyId != null) {
template.getId().setByteArrayValue(keyId);
}
if (keyLabel != null) {
template.getLabel().setCharArrayValue(keyLabel);
}
List<Storage> tmpObjects = getObjects(session, template);
if (CollectionUtil.isEmpty(tmpObjects)) {
LOG.info("found no certificate identified by {}", getDescription(keyId, keyLabel));
return null;
}
int size = tmpObjects.size();
X509PublicKeyCertificate[] certs = new X509PublicKeyCertificate[size];
for (int i = 0; i < size; i++) {
certs[i] = (X509PublicKeyCertificate) tmpObjects.get(i);
}
return certs;
}
use of iaik.pkcs.pkcs11.objects.Storage in project xipki by xipki.
the class IaikP11Slot method getAllCertificateObjects.
private List<X509PublicKeyCertificate> getAllCertificateObjects(Session session) throws P11TokenException {
X509PublicKeyCertificate template = new X509PublicKeyCertificate();
List<Storage> tmpObjects = getObjects(session, template);
List<X509PublicKeyCertificate> certs = new ArrayList<>(tmpObjects.size());
for (PKCS11Object tmpObject : tmpObjects) {
X509PublicKeyCertificate cert = (X509PublicKeyCertificate) tmpObject;
certs.add(cert);
}
return certs;
}
Aggregations