Code example for GeneralSecurityException

0
  private static KeyStore createKeyStore() throws GeneralSecurityException {
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    try { 
      keyStore.load(null, KEYSTORE_PASSWORD);
    } catch (IOException e) {
      throw new GeneralSecurityException("Unable to create empty keyStore", e);
    } 
    return keyStore;
  } 
 
  private void store(KeyStore keyStore) {
    try { 
      FileOutputStream fos =
          mContext.openFileOutput(KEYSTORE_FILENAME, Context.MODE_PRIVATE);
      keyStore.store(fos, KEYSTORE_PASSWORD);
      fos.close();
    } catch (IOException e) {
      throw new IllegalStateException("Unable to store keyStore", e);
    } catch (GeneralSecurityException e) {
      throw new IllegalStateException("Unable to store keyStore", e);
    }