/**
* Process PKCS12 input stream into the private key and certificate chain.
*/
public void load(InputStream is, String pword)
throws IOException, PKCSException, CertificateException {
PKCS12 p12 = new PKCS12(is);
is.close();
p12.decrypt(pword.toCharArray());
KeyBag keyBag = p12.getKeyBag();
if (null == keyBag) {
throw new PKCSException("No private key found");
}
byte[] keyBagLocalKeyId = keyBag.getLocalKeyID();
this.key = keyBag.getPrivateKey();
CertificateBag[] certBags = p12.getCertificateBags();
if ((null == certBags) || (certBags.length == 0)) {
throw new PKCSException("No certificates found");
}
this.alias = new String(keyBagLocalKeyId);