use of org.xipki.security.exception.P11TokenException in project xipki by xipki.
the class P11Identity method setCertificates.
public void setCertificates(X509Certificate[] certificateChain) throws P11TokenException {
if (CollectionUtil.isEmpty(certificateChain)) {
this.certificateChain = null;
} else {
PublicKey pk = certificateChain[0].getPublicKey();
if (!this.publicKey.equals(pk)) {
throw new P11TokenException("certificateChain is not for the key");
}
this.certificateChain = certificateChain;
}
}
use of org.xipki.security.exception.P11TokenException in project xipki by xipki.
the class P11MacContentSignerBuilder method createSigner.
// constructor
public ConcurrentContentSigner createSigner(AlgorithmIdentifier signatureAlgId, int parallelism) throws XiSecurityException, P11TokenException {
ParamUtil.requireMin("parallelism", parallelism, 1);
List<XiContentSigner> signers = new ArrayList<>(parallelism);
for (int i = 0; i < parallelism; i++) {
XiContentSigner signer = new P11MacContentSigner(cryptService, identityId, signatureAlgId);
signers.add(signer);
}
// end for
final boolean mac = true;
DfltConcurrentContentSigner concurrentSigner;
try {
concurrentSigner = new DfltConcurrentContentSigner(mac, signers, null);
} catch (NoSuchAlgorithmException ex) {
throw new XiSecurityException(ex.getMessage(), ex);
}
try {
byte[] sha1HashOfKey = cryptService.getIdentity(identityId).digestSecretKey(PKCS11Constants.CKM_SHA_1);
concurrentSigner.setSha1DigestOfMacKey(sha1HashOfKey);
} catch (P11TokenException | XiSecurityException ex) {
LogUtil.warn(LOG, ex, "could not compute the digest of secret key " + identityId);
}
return concurrentSigner;
}
Aggregations