KeyStoreHandler { public static KeyStoreHandler open(final File keyStoreFile, final char... password) throws IOException, KeyStoreException { if (keyStoreFile == null) { throw new FileNotFoundException(null); } else if (!keyStoreFile.exists()) { throw new FileNotFoundException(keyStoreFile.getAbsolutePath()); } var keystore = KeyStore.getInstance(KEYSTORE_TYPE); try (var inputStream = new FileInputStream(keyStoreFile)) { LOGGER.debug("Opening keystore {}.", keyStoreFile); keystore.load(inputStream, password); return new KeyStoreHandler(keystore, password, keyStoreFile, getSecretKeyFactory(), false); } catch (Exception ex) { throw new IllegalStateException(ex); } } private  KeyStoreHandler(final KeyStore keyStore, final char[] password, final File keyStoreFile,
            final SecretKeyFactory keyFactory); private  KeyStoreHandler(final KeyStore keyStore, final char[] password, final File keyStoreFile,
            final SecretKeyFactory keyFactory, final boolean isDirty); static KeyStoreHandler create(final File keyStoreFile, final char... password); static KeyStoreHandler open(final File keyStoreFile,
            final char... password); boolean set(final String alias, final char... value); Optional<char[]> get(final String alias); boolean delete(final String alias); boolean isDirty(); void save(); void save(final char... secret);  }
@Test void nullFileOnOpen() { assertThatThrownBy(() -> KeyStoreHandler.open(null)) .isInstanceOf(FileNotFoundException.class); }