Search in sources :

Example 36 with XiSecurityException

use of org.xipki.security.exception.XiSecurityException 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;
}
Also used : XiSecurityException(org.xipki.security.exception.XiSecurityException) DfltConcurrentContentSigner(org.xipki.security.DfltConcurrentContentSigner) P11TokenException(org.xipki.security.exception.P11TokenException) ArrayList(java.util.ArrayList) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) XiContentSigner(org.xipki.security.XiContentSigner)

Aggregations

XiSecurityException (org.xipki.security.exception.XiSecurityException)36 P11TokenException (org.xipki.security.exception.P11TokenException)16 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)8 X509Certificate (java.security.cert.X509Certificate)6 ObjectCreationException (org.xipki.common.ObjectCreationException)6 SignerConf (org.xipki.security.SignerConf)6 IOException (java.io.IOException)5 CertificateException (java.security.cert.CertificateException)5 ConcurrentContentSigner (org.xipki.security.ConcurrentContentSigner)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 PublicKey (java.security.PublicKey)4 ArrayList (java.util.ArrayList)4 OperationException (org.xipki.ca.api.OperationException)4 ConfPairs (org.xipki.common.ConfPairs)4 InvalidConfException (org.xipki.common.InvalidConfException)4 P11ObjectIdentifier (org.xipki.security.pkcs11.P11ObjectIdentifier)4 SignatureException (java.security.SignatureException)3 DfltConcurrentContentSigner (org.xipki.security.DfltConcurrentContentSigner)3 XiContentSigner (org.xipki.security.XiContentSigner)3 Session (iaik.pkcs.pkcs11.Session)2