/** * 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); }
/** * 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); }
/** * 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); }
/** * 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; }