try { CertificateFactory fact = CertificateFactory.getInstance("X.509"); ((IPrivateKeyring) keyring).putCertPath(alias, chain); } catch (CertificateException ce) { throw new KeyStoreException(ce.toString()); } ((IPrivateKeyring) keyring).putPrivateKey(alias, key, password);
log.exiting(this.getClass().getName(), "engineSetKeyEntry");
  public void engineSetKeyEntry(String alias, Key key, char[] password,                                Certificate[] chain) throws KeyStoreException  {    if (!loaded)      {        throw new IllegalStateException ("not loaded");      }    if (keyring == null)      {        keyring = new GnuPrivateKeyring("HMAC-SHA-1", 20, "AES", "OFB", 16);      }    if (!(keyring instanceof IPrivateKeyring))      {        throw new IllegalStateException("not a private keyring");      }    if (key instanceof PublicKey)      {        ((IPrivateKeyring) keyring).putPublicKey(alias, (PublicKey) key);        return;      }    if (!(key instanceof PrivateKey) && !(key instanceof SecretKey))      {        throw new KeyStoreException("cannot store keys of type "                                    + key.getClass().getName());      }    try      {        CertificateFactory fact = CertificateFactory.getInstance("X.509");        ((IPrivateKeyring) keyring).putCertPath(alias, chain);      }    catch (CertificateException ce)      {        throw new KeyStoreException(ce.toString());      }    ((IPrivateKeyring) keyring).putPrivateKey(alias, key, password);  }