code: public final void setKeyEntry(String alias, Key key, char[] password,
                                    Certificate[] chain)
          throws KeyStoreException
      {
          if (!initialized) {
              throw new KeyStoreException("Uninitialized keystore");
          }
          if ((key instanceof PrivateKey) &&
              (chain == null || chain.length == 0)) {
              throw new IllegalArgumentException("Private key must be "
                                                 + "accompanied by certificate "
                                                 + "chain");
          }
          keyStoreSpi.engineSetKeyEntry(alias, key, password, chain);
      }
docs: Assigns the given key to the given alias, protecting it with the given
  password.
  
  <p>If the given key is of type <code>java.security.PrivateKey</code>,
  it must be accompanied by a certificate chain certifying the
  corresponding public key.
  
  <p>If the given alias already exists, the keystore information
  associated with it is overridden by the given key (and possibly
  certificate chain).
  
  @param alias the alias name
  @param key the key to be associated with the alias
  @param password the password to protect the key
  @param chain the certificate chain for the corresponding public
  key (only required if the given key is of type
  <code>java.security.PrivateKey</code>).
  
  @exception KeyStoreException if the keystore has not been initialized
  (loaded), the given key cannot be protected, or this operation fails
  for some other reason