Search in sources :

Example 1 with Storage

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;
}
Also used : ValuedSecretKey(iaik.pkcs.pkcs11.objects.ValuedSecretKey) SecretKey(iaik.pkcs.pkcs11.objects.SecretKey) Storage(iaik.pkcs.pkcs11.objects.Storage) ArrayList(java.util.ArrayList)

Example 2 with Storage

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;
}
Also used : RSAPrivateKey(iaik.pkcs.pkcs11.objects.RSAPrivateKey) ECPrivateKey(iaik.pkcs.pkcs11.objects.ECPrivateKey) SM2PrivateKey(iaik.pkcs.pkcs11.objects.SM2PrivateKey) PrivateKey(iaik.pkcs.pkcs11.objects.PrivateKey) DSAPrivateKey(iaik.pkcs.pkcs11.objects.DSAPrivateKey) Storage(iaik.pkcs.pkcs11.objects.Storage) ArrayList(java.util.ArrayList)

Example 3 with Storage

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;
}
Also used : Storage(iaik.pkcs.pkcs11.objects.Storage) X509PublicKeyCertificate(iaik.pkcs.pkcs11.objects.X509PublicKeyCertificate)

Example 4 with Storage

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;
}
Also used : Storage(iaik.pkcs.pkcs11.objects.Storage) PKCS11Object(iaik.pkcs.pkcs11.objects.PKCS11Object) ArrayList(java.util.ArrayList) X509PublicKeyCertificate(iaik.pkcs.pkcs11.objects.X509PublicKeyCertificate)

Aggregations

Storage (iaik.pkcs.pkcs11.objects.Storage)4 ArrayList (java.util.ArrayList)3 X509PublicKeyCertificate (iaik.pkcs.pkcs11.objects.X509PublicKeyCertificate)2 DSAPrivateKey (iaik.pkcs.pkcs11.objects.DSAPrivateKey)1 ECPrivateKey (iaik.pkcs.pkcs11.objects.ECPrivateKey)1 PKCS11Object (iaik.pkcs.pkcs11.objects.PKCS11Object)1 PrivateKey (iaik.pkcs.pkcs11.objects.PrivateKey)1 RSAPrivateKey (iaik.pkcs.pkcs11.objects.RSAPrivateKey)1 SM2PrivateKey (iaik.pkcs.pkcs11.objects.SM2PrivateKey)1 SecretKey (iaik.pkcs.pkcs11.objects.SecretKey)1 ValuedSecretKey (iaik.pkcs.pkcs11.objects.ValuedSecretKey)1