this.privKey = privKey;
this.provider = provider;
digestAlgorithm = allowedDigests.get(hashAlgorithm.toUpperCase());
if (digestAlgorithm == null)
throw new NoSuchAlgorithmException(MessageLocalization.getComposedMessage("unknown.hash.algorithm.1", hashAlgorithm));
version = signerversion = 1;
certs = new ArrayList<Certificate>();
crls = new ArrayList<CRL>();
digestalgos = new HashSet<String>();
digestalgos.add(digestAlgorithm);
//
// Copy in the certificates and crls used to sign the private key.
//
signCert = (X509Certificate)certChain[0];
for (Certificate element : certChain) {
certs.add(element);
}
if (crlList != null) {
for (CRL element : crlList) {
crls.add(element);
}
}
if (privKey != null) {
//
// Now we have private key, find out what the digestEncryptionAlgorithm is.
//
digestEncryptionAlgorithm = privKey.getAlgorithm();
if (digestEncryptionAlgorithm.equals("RSA")) {
digestEncryptionAlgorithm = ID_RSA;
}
else if (digestEncryptionAlgorithm.equals("DSA")) {
digestEncryptionAlgorithm = ID_DSA;
}
else {
throw new NoSuchAlgorithmException(MessageLocalization.getComposedMessage("unknown.key.algorithm.1", digestEncryptionAlgorithm));
}
}
if (hasRSAdata) {
RSAdata = new byte[0];
if (provider == null || provider.startsWith("SunPKCS11"))