Code example for KeyStore

Methods: containsAlias, deleteEntry, store

0
    FileOutputStream file;
    try 
    { 
      file = new FileOutputStream(filename);
 
      keyStore.store(file, password.getPassword());
      file.close();
    } 
    catch (KeyStoreException e)
    { 
      throw new KeyAccessException("The keystore could not be correctly initialized.", e);
    } 
    catch (FileNotFoundException e)
    { 
      throw new KeyAccessException("The keystore file could not be found.", e);
    } 
    catch (NoSuchAlgorithmException e)
    { 
      throw new KeyAccessException("The algorithm used to check the integrity of the keystore cannot be found.", e);
    } 
    catch (CertificateException e)
    { 
      throw new KeyAccessException("The keystore could not be correctly initialized due to an improper certificate issue.", e);
    } 
    catch (IOException e)
    { 
      throw new KeyAccessException("The keystore could not be correctly initialized due to a problem with IO.", e);
    } 
  } 
 
  /** 
   * Deletes the keystore entry given by the specified alias 
   *  
   * @param alias 
   */ 
  public void deleteKey(String alias)
  { 
    try 
    { 
      if (keyStore.containsAlias(alias))
      { 
        keyStore.deleteEntry(alias);
        saveKeyStore(); 
      } 
    } 
    catch (KeyStoreException e)
    {