if (keyStore.exists() && trustStore.exists()) { final KeyStoreFactory keyStoreFactory = new KeyStoreFactory(); keyStoreFactory.setDataFile(keyStore); keyStoreFactory.setPassword(keystorePassword); final KeyStoreFactory trustStoreFactory = new KeyStoreFactory(); trustStoreFactory.setDataFile(trustStore); trustStoreFactory.setPassword(truststorePassword); final KeyStore ks = keyStoreFactory.newInstance(); sslContextFactory.setKeyManagerFactoryKeyStore(ks); final KeyStore ts = trustStoreFactory.newInstance(); sslContextFactory.setTrustManagerFactoryKeyStore(ts); sslContextFactory.setKeyManagerFactoryKeyStorePassword(keystorePassword);
/** * Sets the data which contains the key store. * * @param dataUrl the {@link URL} that contains the key store. * @throws IOException If we can't process the URL */ public void setDataUrl(URL dataUrl) throws IOException { setData(dataUrl.openStream()); } }
/** * Sets the data which contains the key store. * * @param dataUrl the {@link URL} that contains the key store. * @throws IOException If we can't process the URL */ public void setDataUrl(URL dataUrl) throws IOException { setData(dataUrl.openStream()); } }
logger.debug ( "Default TrustManagerFactory: {}", TrustManagerFactory.getDefaultAlgorithm () ); final KeyStoreFactory keyStoreFactory = new KeyStoreFactory (); keyStoreFactory.setDataFile ( keyStoreFile ); keyStoreFactory.setPassword ( keyStorePassword ); final KeyStoreFactory trustStoreFactory = new KeyStoreFactory (); trustStoreFactory.setDataFile ( new File ( trustStoreFile ) ); trustStoreFactory.setPassword ( trustStorePassword ); factory.setKeyManagerFactoryKeyStore ( keyStoreFactory.newInstance () ); factory.setTrustManagerFactoryKeyStore ( trustStoreFactory.newInstance () );
/** * Sets the data which contains the key store. * * @param dataUrl the {@link URL} that contains the key store. */ public void setDataUrl(URL dataUrl) throws IOException { setData(dataUrl.openStream()); } }
logger.debug ( "Default TrustManagerFactory: {}", TrustManagerFactory.getDefaultAlgorithm () ); final KeyStoreFactory keyStoreFactory = new KeyStoreFactory (); keyStoreFactory.setDataFile ( keyStoreFile ); keyStoreFactory.setPassword ( keyStorePassword ); final KeyStoreFactory trustStoreFactory = new KeyStoreFactory (); trustStoreFactory.setDataFile ( new File ( trustStoreFile ) ); trustStoreFactory.setPassword ( trustStorePassword ); factory.setKeyManagerFactoryKeyStore ( keyStoreFactory.newInstance () ); factory.setTrustManagerFactoryKeyStore ( trustStoreFactory.newInstance () );
/** * Sets the data which contains the key store. * * @param dataFile the {@link File} that contains the key store * @throws IOException If we can't process the file */ public void setDataFile(File dataFile) throws IOException { setData(new BufferedInputStream(new FileInputStream(dataFile))); }
final KeyStoreFactory keyStoreFactory = new KeyStoreFactory(); keyStoreFactory.setDataFile(keyStore); keyStoreFactory.setPassword(keystorePassword); final KeyStoreFactory trustStoreFactory = new KeyStoreFactory(); trustStoreFactory.setDataFile(trustStore); trustStoreFactory.setPassword(truststorePassword); final KeyStore ks = keyStoreFactory.newInstance(); sslContextFactory.setKeyManagerFactoryKeyStore(ks); final KeyStore ts = trustStoreFactory.newInstance(); sslContextFactory.setTrustManagerFactoryKeyStore(ts); sslContextFactory.setKeyManagerFactoryKeyStorePassword(keystorePassword);
/** * Sets the data which contains the key store. * * @param dataFile the {@link File} that contains the key store * @throws IOException If we can't process the file */ public void setDataFile(File dataFile) throws IOException { setData(new BufferedInputStream(new FileInputStream(dataFile))); }
/** * Sets the data which contains the key store. * * @param dataFile the {@link File} that contains the key store */ public void setDataFile(File dataFile) throws IOException { setData(new BufferedInputStream(new FileInputStream(dataFile))); }
/** * Sets the data which contains the key store. * * @param dataStream the {@link InputStream} that contains the key store * @throws IOException If we can't process the stream */ private void setData(InputStream dataStream) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { for (;;) { int readByte = dataStream.read(); if (readByte < 0) { break; } out.write(readByte); } setData(out.toByteArray()); } finally { try { dataStream.close(); } catch (IOException e) { // Ignore. } } }
/** * Sets the data which contains the key store. * * @param dataStream the {@link InputStream} that contains the key store */ private void setData(InputStream dataStream) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { for (;;) { int data = dataStream.read(); if (data < 0) { break; } out.write(data); } setData(out.toByteArray()); } finally { try { dataStream.close(); } catch (IOException e) { // Ignore. } } }
/** * Sets the data which contains the key store. * * @param dataStream the {@link InputStream} that contains the key store * @throws IOException If we can't process the stream */ private void setData(InputStream dataStream) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { for (;;) { int readByte = dataStream.read(); if (readByte < 0) { break; } out.write(readByte); } setData(out.toByteArray()); } finally { try { dataStream.close(); } catch (IOException e) { // Ignore. } } }