code: public void engineSetEntry(String alias, KeyStore.Entry entry,
                          KeyStore.ProtectionParameter protParam)
                  throws KeyStoreException {
  
          // get password
          if (protParam != null &&
              !(protParam instanceof KeyStore.PasswordProtection)) {
              throw new KeyStoreException("unsupported protection parameter");
          }
          KeyStore.PasswordProtection pProtect = null;
          if (protParam != null) {
              pProtect = (KeyStore.PasswordProtection)protParam;
          }
  
          char[] password = (pProtect == null) ? null : pProtect.getPassword();
          // set entry
          if (entry instanceof KeyStore.TrustedCertificateEntry) {
              KeyStore.TrustedCertificateEntry tce =
                      (KeyStore.TrustedCertificateEntry)entry;
              engineSetCertificateEntry(alias, tce.getTrustedCertificate());
              return;
          } else if (entry instanceof KeyStore.PrivateKeyEntry) {
              engineSetKeyEntry
                  (alias,
                  ((KeyStore.PrivateKeyEntry)entry).getPrivateKey(),
                  password,
                  ((KeyStore.PrivateKeyEntry)entry).getCertificateChain());
              return;
          } else if (entry instanceof KeyStore.SecretKeyEntry) {
              engineSetKeyEntry
                  (alias,
                  ((KeyStore.SecretKeyEntry)entry).getSecretKey(),
                  password,
                  (Certificate[])null);
              return;
          }
  
          throw new KeyStoreException
                  ("unsupported entry type: " + entry.getClass().getName());
      }
docs: Saves a {@code KeyStore.Entry} under the specified alias.
  The specified protection parameter is used to protect the
  {@code Entry}.
  
  <p> If an entry already exists for the specified alias,
  it is overridden.
  
  @param alias save the {@code KeyStore.Entry} under this alias
  @param entry the {@code Entry} to save
  @param protParam the {@code ProtectionParameter}
  used to protect the {@code Entry},
  which may be {@code null}
  
  @exception KeyStoreException if this operation fails
  
  @since 1.5