@Test public void testStoreThrowsSecureKeyStoreException() throws Throwable { SimpleKeyFile simpleKeyFile = new SimpleKeyFile(); try { simpleKeyFile.store(); fail("Expected SecureKeyStoreException to be thrown"); } catch (SecureKeyStore.SecureKeyStoreException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertEquals("java.lang.NullPointerException", ex.getMessage(), "ex.getMessage()"); assertNull(ex.getNested().getMessage(), "ex.getNested().getMessage()"); } else { assertEquals("java.lang.NullPointerException: Cannot invoke \"java.io.File.canWrite()\" because \"this.file\" is null", ex.getMessage(), "ex.getMessage()"); assertEquals("Cannot invoke \"java.io.File.canWrite()\" because \"this.file\" is null", ex.getNested().getMessage(), "ex.getNested().getMessage()"); } assertNull(simpleKeyFile.file, "simpleKeyFile.file"); } }
void store () throws SecureKeyStoreException { FileOutputStream out; try { if (!file.canWrite()) throw new SecureKeyStoreException("Can't write to file: " + file.getCanonicalPath()); out = new FileOutputStream(file); props.store(out, header); out.flush(); out.close(); } catch (Exception e) { throw new SecureKeyStoreException(e); } }
SimpleKeyFile implements SecureKeyStore, Configurable, LogSource { void store () throws SecureKeyStoreException { FileOutputStream out; try { if (!file.canWrite()) throw new SecureKeyStoreException("Can't write to file: " + file.getCanonicalPath()); out = new FileOutputStream(file); props.store(out, header); out.flush(); out.close(); } catch (Exception e) { throw new SecureKeyStoreException(e); } } }
SimpleKeyFile implements SecureKeyStore, Configurable, LogSource { void store () throws SecureKeyStoreException { FileOutputStream out; try { if (!file.canWrite()) throw new SecureKeyStoreException("Can't write to file: " + file.getCanonicalPath()); out = new FileOutputStream(file); props.store(out, header); out.flush(); out.close(); } catch (Exception e) { throw new SecureKeyStoreException(e); } } SimpleKeyFile();  SimpleKeyFile(String keyFileName); }
SimpleKeyFile implements SecureKeyStore, Configurable, LogSource { void store () throws SecureKeyStoreException { FileOutputStream out; try { if (!file.canWrite()) throw new SecureKeyStoreException("Can't write to file: " + file.getCanonicalPath()); out = new FileOutputStream(file); props.store(out, header); out.flush(); out.close(); } catch (Exception e) { throw new SecureKeyStoreException(e); } } SimpleKeyFile();  SimpleKeyFile(String keyFileName); void init(String keyFileName); @Override void setLogger(Logger logger, String realm); @Override Logger getLogger(); @Override String getRealm(); @Override void setConfiguration(Configuration cfg); @Override synchronized SecureKey getKey(String alias); @Override synchronized void setKey(String alias, SecureKey secureKey); String getProperty(String alias, String subName); void setProperty(String alias, String subName, String value); @Override Map<String, SecureKey> getKeys(); }
SimpleKeyFile implements SecureKeyStore, Configurable, LogSource { void store () throws SecureKeyStoreException { FileOutputStream out; try { if (!file.canWrite()) throw new SecureKeyStoreException("Can't write to file: " + file.getCanonicalPath()); out = new FileOutputStream(file); props.store(out, header); out.flush(); out.close(); } catch (Exception e) { throw new SecureKeyStoreException(e); } } SimpleKeyFile();  SimpleKeyFile(String keyFileName); void init(String keyFileName); @Override void setLogger(Logger logger, String realm); @Override Logger getLogger(); @Override String getRealm(); @Override void setConfiguration(Configuration cfg); @Override synchronized SecureKey getKey(String alias); @Override synchronized void setKey(String alias, SecureKey secureKey); String getProperty(String alias, String subName); void setProperty(String alias, String subName, String value); @Override Map<String, SecureKey> getKeys();  }