/** * 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} of the type specified. * * @param type the type of {@link KeyStore} to be wrapped * @return the new {@code AtomicLoadKeyStore} instance * @throws KeyStoreException If there is a problem creating the {@link KeyStore} */ public static AtomicLoadKeyStore newInstance(final String type) throws KeyStoreException { try { return newInstance(type, (String) null); } catch (NoSuchProviderException e) { throw new KeyStoreException(e); } }
/** * 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); }
/** * 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; }
try { Provider provider = resolveProvider(); AtomicLoadKeyStore keyStore = AtomicLoadKeyStore.newInstance(type, provider); if (path != null) { pathResolver = pathResolver(); keyStore.load(is, password); } else { synchronized (EmptyProvider.getInstance()) { keyStore.load(null, password);
private AtomicLoadKeyStore.LoadKey load(AtomicLoadKeyStore keyStore) throws Exception { try (InputStream is = resolvedPath != null ? new FileInputStream(resolvedPath) : null) { AtomicLoadKeyStore.LoadKey loadKey = keyStore.revertibleLoad(is, resolvePassword()); checkCertificatesValidity(keyStore); return loadKey; } }
void revertLoad(final LoadKey loadKey) { ROOT_LOGGER.trace("reverting load of KeyStore"); keyStore.revert(loadKey.loadKey); synched = loadKey.modifiedTime; trackingKeyStore.setModified(loadKey.modified); }
/** * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} of the type specified. * * @param type the type of {@link KeyStore} to be wrapped * @param provider the provide to use to create the {@link KeyStore} * @return the new {@code AtomicLoadKeyStore} instance * @throws KeyStoreException If there is a problem creating the {@link KeyStore} * @throws NoSuchProviderException if the provider specified can not be found. */ public static AtomicLoadKeyStore newInstance(final String type, final String provider) throws KeyStoreException, NoSuchProviderException { KeyStore keyStore = provider != null ? KeyStore.getInstance(type, provider) : KeyStore.getInstance(type); final Provider resolvedProvider = keyStore.getProvider(); return newInstance(type, resolvedProvider); }
/** * 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); }
/** * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} of the type specified. * * @param type the type of {@link KeyStore} to be wrapped * @return the new {@code AtomicLoadKeyStore} instance * @throws KeyStoreException If there is a problem creating the {@link KeyStore} */ public static AtomicLoadKeyStore newInstance(final String type) throws KeyStoreException { try { return newInstance(type, (String) null); } catch (NoSuchProviderException e) { throw new KeyStoreException(e); } }
/** * 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); }
/** * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} of the type specified. * * @param type the type of {@link KeyStore} to be wrapped * @param provider the provide to use to create the {@link KeyStore} * @return the new {@code AtomicLoadKeyStore} instance * @throws KeyStoreException If there is a problem creating the {@link KeyStore} * @throws NoSuchProviderException if the provider specified can not be found. */ public static AtomicLoadKeyStore newInstance(final String type, final String provider) throws KeyStoreException, NoSuchProviderException { KeyStore keyStore = provider != null ? KeyStore.getInstance(type, provider) : KeyStore.getInstance(type); final Provider resolvedProvider = keyStore.getProvider(); return newInstance(type, resolvedProvider); }
/** * 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); }
/** * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} of the type specified. * * @param type the type of {@link KeyStore} to be wrapped * @return the new {@code AtomicLoadKeyStore} instance * @throws KeyStoreException If there is a problem creating the {@link KeyStore} */ public static AtomicLoadKeyStore newInstance(final String type) throws KeyStoreException { try { return newInstance(type, (String) null); } catch (NoSuchProviderException e) { throw new KeyStoreException(e); } }
/** * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} of the type specified. * * @param type the type of {@link KeyStore} to be wrapped * @param provider the provide to use to create the {@link KeyStore} * @return the new {@code AtomicLoadKeyStore} instance * @throws KeyStoreException If there is a problem creating the {@link KeyStore} * @throws NoSuchProviderException if the provider specified can not be found. */ public static AtomicLoadKeyStore newInstance(final String type, final String provider) throws KeyStoreException, NoSuchProviderException { KeyStore keyStore = provider != null ? KeyStore.getInstance(type, provider) : KeyStore.getInstance(type); final Provider resolvedProvider = keyStore.getProvider(); return newInstance(type, resolvedProvider); }
/** * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} of the type specified. * * @param type the type of {@link KeyStore} to be wrapped * @return the new {@code AtomicLoadKeyStore} instance * @throws KeyStoreException If there is a problem creating the {@link KeyStore} */ public static AtomicLoadKeyStore newInstance(final String type) throws KeyStoreException { try { return newInstance(type, (String) null); } catch (NoSuchProviderException e) { throw new KeyStoreException(e); } }
/** * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} of the type specified. * * @param type the type of {@link KeyStore} to be wrapped * @param provider the provide to use to create the {@link KeyStore} * @return the new {@code AtomicLoadKeyStore} instance * @throws KeyStoreException If there is a problem creating the {@link KeyStore} * @throws NoSuchProviderException if the provider specified can not be found. */ public static AtomicLoadKeyStore newInstance(final String type, final String provider) throws KeyStoreException, NoSuchProviderException { KeyStore keyStore = provider != null ? KeyStore.getInstance(type, provider) : KeyStore.getInstance(type); final Provider resolvedProvider = keyStore.getProvider(); return newInstance(type, resolvedProvider); }