- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {FileOutputStream f =
File file;new FileOutputStream(file)
String name;new FileOutputStream(name)
File file;new FileOutputStream(file, true)
- Smart code suggestions by Codota
}
/** * Reads a DER or PEM-encoded public key from a file. * * @param path Path to DER or PEM-encoded public key file. * * @return Public key. * * @throws EncodingException on key encoding errors. * @throws StreamException on IO errors. */ public static PublicKey readPublicKey(final String path) throws EncodingException, StreamException { return readPublicKey(new File(path)); }
/** {@inheritDoc} */ @Override public PublicKey getObject() throws Exception { if (key == null) { if (resource == null) { throw new BeanCreationException("Public key resource must be provided in order to use this factory."); } try (InputStream is = resource.getInputStream()) { key = KeyPairUtil.readPublicKey(is); } } return key; }
/** * Reads a DER or PEM-encoded public key from a file. * * @param file DER or PEM-encoded public key file. * * @return Public key. * * @throws EncodingException on key encoding errors. * @throws StreamException on IO errors. */ public static PublicKey readPublicKey(final File file) throws EncodingException, StreamException { try { return readPublicKey(new FileInputStream(file)); } catch (FileNotFoundException e) { throw new StreamException("File not found: " + file); } }
@Override public PublicKey newInstance() throws EncodingException, StreamException { try { return KeyPairUtil.readPublicKey(resource.getInputStream()); } catch (IOException e) { throw new StreamException(e); } } }
/** {@inheritDoc} */ @Override @Nullable protected PublicKey getPublicKey() { if (null == getPublicKeyInfo()) { return null; } try (InputStream is = getPublicKeyInfo().getInputStream()) { return KeyPairUtil.readPublicKey(is); } catch (final IOException e) { log.error("{}: Could not decode public key", getConfigDescription(), e); throw new FatalBeanException("Could not decode public key", e); } }
/** * Get the configured certificates. * * @return the certificates null */ @Nullable @NonnullElements protected List<Credential> getCredentials() { final List<Credential> credentials = new ArrayList<>(keyResources.size() + certificateResources.size()); for (final Resource f : keyResources) { try(final InputStream is = f.getInputStream()) { credentials.add(new BasicCredential(KeyPairUtil.readPublicKey(is))); } catch (final EncodingException|StreamException|IOException e) { log.error("Could not decode public key from {}", f.getDescription(), e); throw new FatalBeanException("Could not decode public key from: " + f.getDescription(), e); } } for (final Resource f : certificateResources) { try(final InputStream is = f.getInputStream()) { final Collection<X509Certificate> raw = X509Support.decodeCertificates(is); for (final X509Certificate x : Collections2.filter(raw, Predicates.notNull())) { credentials.add(new BasicX509Credential(x)); } } catch (final CertificateException | IOException e) { log.error("Could not decode certificate from {}", f.getDescription(), e); throw new FatalBeanException("Could not decode certificate from: " + f.getDescription(), e); } } return credentials; }
credentials.add(new BasicCredential(KeyPairUtil.readPublicKey(is))); } catch (final EncodingException|StreamException|IOException e) { log.error("Could not decode public key from {}", f.getDescription(), e);