/** * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} or the specified type, obtained from the supplied {@link Provider}. * * @param type the type of the {@link KeyStore} to wrap * @param provider the {@link Provider} to use to create the {@link KeyStore} instance. * @return the new {@link AtomicLoadKeyStore} instance */ public static AtomicLoadKeyStore newInstance(final String type, final Provider provider) { AtomicLoadKeyStoreSpi keyStoreSpi = new AtomicLoadKeyStoreSpi(() -> KeyStore.getInstance(type, provider)); ElytronMessages.tls.tracef("AtomicLoadKeyStore creating: type = %s, provider = %s", type, provider); return new AtomicLoadKeyStore(keyStoreSpi, provider, type); }
/** * Performs the same action as {@link #load(InputStream, char[])} except a {@link LoadKey} is returned that can be used to revert the load. * * @param inputStream the stream to load from or {@code null} * @param password the password used to protect the contents of the {@link KeyStore} or {@code null} * @return a {@link LoadKey} that can be used to revert the load and restore the previous {@link KeyStore} state * @throws NoSuchAlgorithmException if the keystore cannot be read due to a missing algorithm * @throws CertificateException if the keystore cannot be read due to a certificate problem * @throws IOException if the keystore cannot be read due to an I/O problem */ public LoadKey revertibleLoad(final InputStream inputStream, final char[] password) throws NoSuchAlgorithmException, CertificateException, IOException { KeyStore current = keyStoreSpi.getCurrentKeyStore(); if (current == null) { throw log.reversibleLoadNotPossible(); } load(inputStream, password); return new LoadKey(current); }
/** * Atomically evert the keystore to a previous state. * * @param key the load key */ public void revert(LoadKey key) { keyStoreSpi.restoreKeyStore(key.keyStore); }
/** * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} or the specified type, obtained from the supplied {@link Provider}. * * @param type the type of the {@link KeyStore} to wrap * @param provider the {@link Provider} to use to create the {@link KeyStore} instance. * @return the new {@link AtomicLoadKeyStore} instance */ public static AtomicLoadKeyStore newInstance(final String type, final Provider provider) { AtomicLoadKeyStoreSpi keyStoreSpi = new AtomicLoadKeyStoreSpi(() -> KeyStore.getInstance(type, provider)); ElytronMessages.tls.tracef("AtomicLoadKeyStore creating: type = %s, provider = %s", type, provider); return new AtomicLoadKeyStore(keyStoreSpi, provider, type); }
/** * Atomically evert the keystore to a previous state. * * @param key the load key */ public void revert(LoadKey key) { keyStoreSpi.restoreKeyStore(key.keyStore); }
/** * Performs the same action as {@link #load(InputStream, char[])} except a {@link LoadKey} is returned that can be used to revert the load. * * @param inputStream the stream to load from or {@code null} * @param password the password used to protect the contents of the {@link KeyStore} or {@code null} * @return a {@link LoadKey} that can be used to revert the load and restore the previous {@link KeyStore} state * @throws NoSuchAlgorithmException if the keystore cannot be read due to a missing algorithm * @throws CertificateException if the keystore cannot be read due to a certificate problem * @throws IOException if the keystore cannot be read due to an I/O problem */ public LoadKey revertibleLoad(final InputStream inputStream, final char[] password) throws NoSuchAlgorithmException, CertificateException, IOException { KeyStore current = keyStoreSpi.getCurrentKeyStore(); if (current == null) { throw log.reversibleLoadNotPossible(); } load(inputStream, password); return new LoadKey(current); }
/** * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} or the specified type, obtained from the supplied {@link Provider}. * * @param type the type of the {@link KeyStore} to wrap * @param provider the {@link Provider} to use to create the {@link KeyStore} instance. * @return the new {@link AtomicLoadKeyStore} instance */ public static AtomicLoadKeyStore newInstance(final String type, final Provider provider) { AtomicLoadKeyStoreSpi keyStoreSpi = new AtomicLoadKeyStoreSpi(() -> KeyStore.getInstance(type, provider)); ElytronMessages.tls.tracef("AtomicLoadKeyStore creating: type = %s, provider = %s", type, provider); return new AtomicLoadKeyStore(keyStoreSpi, provider, type); }
/** * Atomically evert the keystore to a previous state. * * @param key the load key */ public void revert(LoadKey key) { keyStoreSpi.restoreKeyStore(key.keyStore); }
/** * Performs the same action as {@link #load(InputStream, char[])} except a {@link LoadKey} is returned that can be used to revert the load. * * @param inputStream the stream to load from or {@code null} * @param password the password used to protect the contents of the {@link KeyStore} or {@code null} * @return a {@link LoadKey} that can be used to revert the load and restore the previous {@link KeyStore} state * @throws NoSuchAlgorithmException if the keystore cannot be read due to a missing algorithm * @throws CertificateException if the keystore cannot be read due to a certificate problem * @throws IOException if the keystore cannot be read due to an I/O problem */ public LoadKey revertibleLoad(final InputStream inputStream, final char[] password) throws NoSuchAlgorithmException, CertificateException, IOException { KeyStore current = keyStoreSpi.getCurrentKeyStore(); if (current == null) { throw log.reversibleLoadNotPossible(); } load(inputStream, password); return new LoadKey(current); }
/** * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} or the specified type, obtained from the supplied {@link Provider}. * * @param type the type of the {@link KeyStore} to wrap * @param provider the {@link Provider} to use to create the {@link KeyStore} instance. * @return the new {@link AtomicLoadKeyStore} instance */ public static AtomicLoadKeyStore newInstance(final String type, final Provider provider) { AtomicLoadKeyStoreSpi keyStoreSpi = new AtomicLoadKeyStoreSpi(() -> KeyStore.getInstance(type, provider)); ElytronMessages.tls.tracef("AtomicLoadKeyStore creating: type = %s, provider = %s", type, provider); return new AtomicLoadKeyStore(keyStoreSpi, provider, type); }
/** * Atomically evert the keystore to a previous state. * * @param key the load key */ public void revert(LoadKey key) { keyStoreSpi.restoreKeyStore(key.keyStore); }
/** * Performs the same action as {@link #load(InputStream, char[])} except a {@link LoadKey} is returned that can be used to revert the load. * * @param inputStream the stream to load from or {@code null} * @param password the password used to protect the contents of the {@link KeyStore} or {@code null} * @return a {@link LoadKey} that can be used to revert the load and restore the previous {@link KeyStore} state * @throws NoSuchAlgorithmException if the keystore cannot be read due to a missing algorithm * @throws CertificateException if the keystore cannot be read due to a certificate problem * @throws IOException if the keystore cannot be read due to an I/O problem */ public LoadKey revertibleLoad(final InputStream inputStream, final char[] password) throws NoSuchAlgorithmException, CertificateException, IOException { KeyStore current = keyStoreSpi.getCurrentKeyStore(); if (current == null) { throw log.reversibleLoadNotPossible(); } load(inputStream, password); return new LoadKey(current); }
/** * Create a new {@code AtomicLoadKeyStore} instance that wraps specified {@link KeyStore}. * * @param keyStore the {@link KeyStore} to be wrapped * @return the new {@code AtomicLoadKeyStore} instance */ public static AtomicLoadKeyStore atomize(KeyStore keyStore) throws CertificateException, NoSuchAlgorithmException, IOException { final String type = keyStore.getType(); final Provider provider = keyStore.getProvider(); AtomicLoadKeyStoreSpi keyStoreSpi = new AtomicLoadKeyStoreSpi(() -> KeyStore.getInstance(type, provider)); AtomicLoadKeyStore result = new AtomicLoadKeyStore(keyStoreSpi, provider, type); result.load(null, null); result.setKeyStore(keyStore); return result; }
private void setKeyStore(KeyStore keyStore) { this.keyStoreSpi.restoreKeyStore(keyStore); }