public void flush() throws CredentialStoreException { synchronized (data) { final File location = this.location; if (location != null) { try (final AtomicFileOutputStream os = new AtomicFileOutputStream(location)) { try (final VaultObjectOutputStream oos = new VaultObjectOutputStream(os)) { oos.writeObject(new SecurityVaultData(data)); } catch (Throwable t) { os.cancel(); throw t; } } catch (IOException e) { throw log.cannotWriteCredentialToStore(e); } } } }
void cancel() throws IOException { if (casCurrent(this, CLOSED)) { delegate.close(); final Path newPath = path.resolveSibling(path.getFileName() + ".new"); Files.deleteIfExists(newPath); } } }
public void flush() throws CredentialStoreException { try (Hold hold = lockForWrite()) { final Path dataLocation = externalPath == null ? location : externalPath; log.tracef("KeyStoreCredentialStore: flushing into %s", dataLocation); if (dataLocation != null) try { final char[] storePassword = getStorePassword(protectionParameter); try (AtomicFileOutputStream os = new AtomicFileOutputStream(dataLocation)) { try { if (useExternalStorage) { externalStorage.store(os); } else { keyStore.store(os, storePassword); } } catch (Throwable t) { try { os.cancel(); } catch (IOException e) { e.addSuppressed(t); throw e; } } } } catch (IOException e) { throw log.cannotFlushCredentialStore(e); } } }
void close() throws IOException { if (casCurrent(this, CLOSED)) { // atomic cleanup operation: close out our stream delegate.close(); final Path path = this.path; final Path newPath = path.resolveSibling(path.getFileName() + ".new"); try { // move new file in Files.move(newPath, path, REPLACE_EXISTING, ATOMIC_MOVE); } catch (Throwable t) { try { // didn't work, gotta delete our temp copy Files.deleteIfExists(newPath); } catch (Throwable problem) { problem.addSuppressed(t); throw problem; } throw t; } } }
public void flush() throws CredentialStoreException { synchronized (data) { final File location = this.location; if (location != null) { try (final AtomicFileOutputStream os = new AtomicFileOutputStream(location)) { try (final VaultObjectOutputStream oos = new VaultObjectOutputStream(os)) { oos.writeObject(new SecurityVaultData(data)); } catch (Throwable t) { os.cancel(); throw t; } } catch (IOException e) { throw log.cannotWriteCredentialToStore(e); } } } }
void cancel() throws IOException { if (casCurrent(this, CLOSED)) { delegate.close(); final Path newPath = path.resolveSibling(path.getFileName() + ".new"); Files.deleteIfExists(newPath); } } }
public void flush() throws CredentialStoreException { synchronized (data) { final File location = this.location; if (location != null) { try (final AtomicFileOutputStream os = new AtomicFileOutputStream(location)) { try (final VaultObjectOutputStream oos = new VaultObjectOutputStream(os)) { oos.writeObject(new SecurityVaultData(data)); } catch (Throwable t) { os.cancel(); throw t; } } catch (IOException e) { throw log.cannotWriteCredentialToStore(e); } } } }
void cancel() throws IOException { if (casCurrent(this, CLOSED)) { delegate.close(); final Path newPath = path.resolveSibling(path.getFileName() + ".new"); Files.deleteIfExists(newPath); } } }
public void flush() throws CredentialStoreException { synchronized (data) { final File location = this.location; if (location != null) { try (final AtomicFileOutputStream os = new AtomicFileOutputStream(location)) { try (final VaultObjectOutputStream oos = new VaultObjectOutputStream(os)) { oos.writeObject(new SecurityVaultData(data)); } catch (Throwable t) { os.cancel(); throw t; } } catch (IOException e) { throw log.cannotWriteCredentialToStore(e); } } } }
void cancel() throws IOException { if (casCurrent(this, CLOSED)) { delegate.close(); final Path newPath = path.resolveSibling(path.getFileName() + ".new"); Files.deleteIfExists(newPath); } } }
public void flush() throws CredentialStoreException { try (Hold hold = lockForWrite()) { final Path dataLocation = externalPath == null ? location : externalPath; log.tracef("KeyStoreCredentialStore: flushing into %s", dataLocation); if (dataLocation != null) try { final char[] storePassword = getStorePassword(protectionParameter); try (AtomicFileOutputStream os = new AtomicFileOutputStream(dataLocation)) { try { if (useExternalStorage) { externalStorage.store(os); } else { keyStore.store(os, storePassword); } } catch (Throwable t) { try { os.cancel(); } catch (IOException e) { e.addSuppressed(t); throw e; } } } } catch (IOException e) { throw log.cannotFlushCredentialStore(e); } } }
void close() throws IOException { if (casCurrent(this, CLOSED)) { // atomic cleanup operation: close out our stream delegate.close(); final Path path = this.path; final Path newPath = path.resolveSibling(path.getFileName() + ".new"); try { // move new file in Files.move(newPath, path, REPLACE_EXISTING, ATOMIC_MOVE); } catch (Throwable t) { try { // didn't work, gotta delete our temp copy Files.deleteIfExists(newPath); } catch (Throwable problem) { problem.addSuppressed(t); throw problem; } throw t; } } }
public void flush() throws CredentialStoreException { try (Hold hold = lockForWrite()) { final Path dataLocation = externalPath == null ? location : externalPath; log.tracef("KeyStoreCredentialStore: flushing into %s", dataLocation); if (dataLocation != null) try { final char[] storePassword = getStorePassword(protectionParameter); try (AtomicFileOutputStream os = new AtomicFileOutputStream(dataLocation)) { try { if (useExternalStorage) { externalStorage.store(os); } else { keyStore.store(os, storePassword); } } catch (Throwable t) { try { os.cancel(); } catch (IOException e) { e.addSuppressed(t); throw e; } } } } catch (IOException e) { throw log.cannotFlushCredentialStore(e); } } }
void close() throws IOException { if (casCurrent(this, CLOSED)) { // atomic cleanup operation: close out our stream delegate.close(); final Path path = this.path; final Path newPath = path.resolveSibling(path.getFileName() + ".new"); try { // move new file in Files.move(newPath, path, REPLACE_EXISTING, ATOMIC_MOVE); } catch (Throwable t) { try { // didn't work, gotta delete our temp copy Files.deleteIfExists(newPath); } catch (Throwable problem) { problem.addSuppressed(t); throw problem; } throw t; } } }
public void flush() throws CredentialStoreException { try (Hold hold = lockForWrite()) { final Path dataLocation = externalPath == null ? location : externalPath; log.tracef("KeyStoreCredentialStore: flushing into %s", dataLocation); if (dataLocation != null) try { final char[] storePassword = getStorePassword(protectionParameter); try (AtomicFileOutputStream os = new AtomicFileOutputStream(dataLocation)) { try { if (useExternalStorage) { externalStorage.store(os); } else { keyStore.store(os, storePassword); } } catch (Throwable t) { try { os.cancel(); } catch (IOException e) { e.addSuppressed(t); throw e; } } } } catch (IOException e) { throw log.cannotFlushCredentialStore(e); } } }
void close() throws IOException { if (casCurrent(this, CLOSED)) { // atomic cleanup operation: close out our stream delegate.close(); final Path path = this.path; final Path newPath = path.resolveSibling(path.getFileName() + ".new"); try { // move new file in Files.move(newPath, path, REPLACE_EXISTING, ATOMIC_MOVE); } catch (Throwable t) { try { // didn't work, gotta delete our temp copy Files.deleteIfExists(newPath); } catch (Throwable problem) { problem.addSuppressed(t); throw problem; } throw t; } } }