/** * Wrap an existing initialised {@link KeyStore} with a wrapper to track if it is modified. * * @param toWrap the {@link KeyStore} to wrap * @return the wrapper around the {@link KeyStore} * @throws NoSuchAlgorithmException if the keystore could not be loaded due to a missing algorithm * @throws CertificateException if the keystore could not be loaded due to a certificate problem * @throws IOException if the keystore could not be loaded due to an I/O problem * @throws IllegalArgumentException if the {@link KeyStore} being wrapped is {@code null} */ public static ModifyTrackingKeyStore modifyTrackingKeyStore(final KeyStore toWrap) throws NoSuchAlgorithmException, CertificateException, IOException { Assert.checkNotNullParam("toWrap", toWrap); ModifyTrackingKeyStore keyStore = new ModifyTrackingKeyStore(new ModifyTrackingKeyStoreSpi(toWrap), toWrap.getProvider(), toWrap.getType()); keyStore.load(null, null); return keyStore; }
LoadKey load() throws OperationFailedException { try { ROOT_LOGGER.tracef("reloading KeyStore from file [%s]", resolvedPath); AtomicLoadKeyStore.LoadKey loadKey = load(keyStore); long originalSynced = synched; synched = System.currentTimeMillis(); boolean originalModified = trackingKeyStore.isModified(); trackingKeyStore.setModified(false); return new LoadKey(loadKey, originalSynced, originalModified); } catch (Exception e) { throw ROOT_LOGGER.unableToCompleteOperation(e, e.getLocalizedMessage()); } }
void revertLoad(final LoadKey loadKey) { ROOT_LOGGER.trace("reverting load of KeyStore"); keyStore.revert(loadKey.loadKey); synched = loadKey.modifiedTime; trackingKeyStore.setModified(loadKey.modified); }
boolean isModified() { return trackingKeyStore.isModified(); }
this.trackingKeyStore = ModifyTrackingKeyStore.modifyTrackingKeyStore(intermediate); this.unmodifiableKeyStore = UnmodifiableKeyStore.unmodifiableKeyStore(intermediate); } catch (Exception e) {
void save() throws OperationFailedException { if (resolvedPath == null) { throw ROOT_LOGGER.cantSaveWithoutFile(path); } ROOT_LOGGER.tracef("saving KeyStore to the file [%s]", resolvedPath); try (FileOutputStream fos = new FileOutputStream(resolvedPath)) { keyStore.store(fos, resolvePassword()); synched = System.currentTimeMillis(); trackingKeyStore.setModified(false); } catch (Exception e) { throw ROOT_LOGGER.unableToCompleteOperation(e, e.getLocalizedMessage()); } }
/** * Wrap an existing initialised {@link KeyStore} with a wrapper to track if it is modified. * * @param toWrap the {@link KeyStore} to wrap * @return the wrapper around the {@link KeyStore} * @throws NoSuchAlgorithmException if the keystore could not be loaded due to a missing algorithm * @throws CertificateException if the keystore could not be loaded due to a certificate problem * @throws IOException if the keystore could not be loaded due to an I/O problem * @throws IllegalArgumentException if the {@link KeyStore} being wrapped is {@code null} */ public static ModifyTrackingKeyStore modifyTrackingKeyStore(final KeyStore toWrap) throws NoSuchAlgorithmException, CertificateException, IOException { Assert.checkNotNullParam("toWrap", toWrap); ModifyTrackingKeyStore keyStore = new ModifyTrackingKeyStore(new ModifyTrackingKeyStoreSpi(toWrap), toWrap.getProvider(), toWrap.getType()); keyStore.load(null, null); return keyStore; }
/** * Wrap an existing initialised {@link KeyStore} with a wrapper to track if it is modified. * * @param toWrap the {@link KeyStore} to wrap * @return the wrapper around the {@link KeyStore} * @throws NoSuchAlgorithmException if the keystore could not be loaded due to a missing algorithm * @throws CertificateException if the keystore could not be loaded due to a certificate problem * @throws IOException if the keystore could not be loaded due to an I/O problem * @throws IllegalArgumentException if the {@link KeyStore} being wrapped is {@code null} */ public static ModifyTrackingKeyStore modifyTrackingKeyStore(final KeyStore toWrap) throws NoSuchAlgorithmException, CertificateException, IOException { Assert.checkNotNullParam("toWrap", toWrap); ModifyTrackingKeyStore keyStore = new ModifyTrackingKeyStore(new ModifyTrackingKeyStoreSpi(toWrap), toWrap.getProvider(), toWrap.getType()); keyStore.load(null, null); return keyStore; }
/** * Wrap an existing initialised {@link KeyStore} with a wrapper to track if it is modified. * * @param toWrap the {@link KeyStore} to wrap * @return the wrapper around the {@link KeyStore} * @throws NoSuchAlgorithmException if the keystore could not be loaded due to a missing algorithm * @throws CertificateException if the keystore could not be loaded due to a certificate problem * @throws IOException if the keystore could not be loaded due to an I/O problem * @throws IllegalArgumentException if the {@link KeyStore} being wrapped is {@code null} */ public static ModifyTrackingKeyStore modifyTrackingKeyStore(final KeyStore toWrap) throws NoSuchAlgorithmException, CertificateException, IOException { Assert.checkNotNullParam("toWrap", toWrap); ModifyTrackingKeyStore keyStore = new ModifyTrackingKeyStore(new ModifyTrackingKeyStoreSpi(toWrap), toWrap.getProvider(), toWrap.getType()); keyStore.load(null, null); return keyStore; }