/** * Prepare url for authentication and ssl if necessary and returns the input stream from the url. * * @param url url to prepare * @param acceptAnyCertificate true if the certicate check should be skipped * * @return input stream from url * * @throws IOException re-thrown */ public static InputStream prepareInputStream( final URL url, final boolean acceptAnyCertificate ) throws IOException { final URLConnection conn = url.openConnection(); prepareForAuthentication( conn ); prepareHttpHeaders( conn ); if( acceptAnyCertificate ) { prepareForSSL( conn ); } return conn.getInputStream(); }