/** * This method should be used everywhere instead of <code>URL.openConnection()</code>, as it copes with proxies that * require user authentication. This method will retrieve the configured password and user name. * * @param url * @return connection * @throws IOException */ public static URLConnection openURLConnection( URL url ) throws IOException { return openURLConnection( url, getProxyUser(), getProxyPassword() ); }
public static void logProxyConfiguration( Logger log ) { log.info( "- proxyHost=" + getProxyHost() + ", http.proxyHost=" + getHttpProxyHost( false ) + ", ftp.proxyHost=" + getFtpProxyHost( false ) ); log.info( "- proxyPort=" + getProxyPort() + ", http.proxyPort=" + getHttpProxyPort( false ) + ", ftp.proxyPort=" + getFtpProxyPort( false ) ); log.info( "- proxyUser=" + getProxyUser() + ", http.proxyUser=" + getHttpProxyUser( false ) + ", ftp.proxyUser=" + getFtpProxyUser( false ) ); log.info( "- proxyPassword=" + getProxyPassword() + ", http.proxyPassword=" + getHttpProxyPassword( false ) + ", ftp.proxyPassword=" + getFtpProxyPassword( false ) ); log.info( "- nonProxyHosts=" + getNonProxyHosts() + ", http.nonProxyHosts=" + getHttpNonProxyHosts( false ) + ", ftp.nonProxyHosts=" + getFtpNonProxyHosts( false ) ); }
URLConnection conn = ProxySettings.openURLConnection( theUrl, getHttpProxyUser( true ), getHttpProxyPassword( true ), httpBasicUser, httpBasicPass ); conn.setConnectTimeout( connectionTimeout * 1000 );
/** * Validates the specified XML instance document according to the contained schema references ( * <code>xsi:schemaLocation</code> attribute) and/or to the explicitly specified schema references. * * @param url * provides the XML document to be validated, must not be null * @param schemaUris * URIs of schema documents to be considered, can be null (only the <code>xsi:schemaLocation</code> * attribute is considered then) * @return list of validation events (errors/warnings) that occured, never null, size of 0 means valid document * @throws IOException * @throws MalformedURLException */ public static List<SchemaValidationEvent> validate( String url, String... schemaUris ) throws MalformedURLException, IOException { InputStream is = ProxySettings.openURLConnection( new URL( url ), null, null ).getInputStream(); return validate( new XMLInputSource( null, null, null, is, null ), schemaUris ); }
URLConnection conn = ProxySettings.openURLConnection( theUrl, ProxySettings.getHttpProxyUser( true ), ProxySettings.getHttpProxyPassword( true ), httpBasicUser, httpBasicPass ); conn.setConnectTimeout( connectionTimeout * 1000 );
/** * Creates a new {@link GMLStreamReader} instance for reading GML of the specified version. * * @param version * GML version, must not be <code>null</code> * @param url * URL used to read the input, must not be <code>null</code> * @return initialized {@link GMLStreamReader} * @throws IOException * @throws FactoryConfigurationError * @throws XMLStreamException */ public static GMLStreamReader createGMLStreamReader( GMLVersion version, URL url ) throws XMLStreamException, FactoryConfigurationError, IOException { URLConnection conn = ProxySettings.openURLConnection( url ); InputStream is = conn.getInputStream(); XMLStreamReader xmlStream = XMLInputFactory.newInstance().createXMLStreamReader( is ); // skip START_DOCUMENT event xmlStream.nextTag(); return new GMLStreamReader( version, new XMLStreamReaderWrapper( xmlStream, url.toString() ) ); } }
private void openReader() { try { synchronized ( LOCK ) { configStream = ProxySettings.openURLConnection( configURL ).getInputStream(); this.configReader = XMLInputFactory.newInstance().createXMLStreamReader( configURL.toExternalForm(), this.configStream ); // move from start document. XMLStreamUtils.nextElement( configReader ); if ( !expectedRootName().equals( configReader.getName() ) ) { LOG.error( "The root element of the crs configuration at location: " + configURL + " is not the expected: " + expectedRootName() + " is your configuration correct?" ); } } } catch ( XMLStreamException e ) { LOG.debug( "Could not read config file from url: " + configURL + ", stack trace.", e ); LOG.error( "Could not read config file from url: " + configURL + " because: " + e.getLocalizedMessage() ); } catch ( FactoryConfigurationError e ) { LOG.debug( "Could not read config file from url: " + configURL + ", stack trace.", e ); LOG.error( "Could not read config file from url: " + configURL + " because: " + e.getLocalizedMessage() ); } catch ( IOException e ) { LOG.debug( "Could not read config file from url: " + configURL + ", stack trace.", e ); LOG.error( "Could not read config file from url: " + configURL + " because: " + e.getLocalizedMessage() ); } }