/** * 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 ) ); }
public static String getFtpProxyPort( boolean considerBaseConfig ) { String result = System.getProperty( FTP_PROXY_PORT ); if ( considerBaseConfig && result == null ) { result = getProxyPort(); } return result; }
/** * Sets/augments the VM's proxy configuration. * * @param config */ public synchronized static void setupProxyParameters( ProxyConfiguration config ) { String proxyHost = config.getProxyHost(); String httpProxyHost = config.getHttpProxyHost(); String ftpProxyHost = config.getFtpProxyHost(); int proxyPort = config.getProxyPort() != null ? config.getProxyPort().intValue() : -1; int httpProxyPort = config.getHttpProxyPort() != null ? config.getHttpProxyPort().intValue() : -1; int ftpProxyPort = config.getFtpProxyPort() != null ? config.getFtpProxyPort().intValue() : -1; String proxyUser = config.getProxyUser(); String httpProxyUser = config.getHttpProxyUser(); String ftpProxyUser = config.getFtpProxyUser(); String proxyPassword = config.getProxyPassword(); String httpProxyPassword = config.getHttpProxyPassword(); String ftpProxyPassword = config.getFtpProxyPassword(); String nonProxyHosts = config.getNonProxyHosts(); String httpNonProxyHosts = config.getHttpNonProxyHosts(); String ftpNonProxyHosts = config.getFtpNonProxyHosts(); setupProxyParameters( proxyHost, httpProxyHost, ftpProxyHost, proxyPort, httpProxyPort, ftpProxyPort, proxyUser, httpProxyUser, ftpProxyUser, proxyPassword, httpProxyPassword, ftpProxyPassword, nonProxyHosts, httpNonProxyHosts, ftpNonProxyHosts, config.isOverrideSystemSettings() ); }
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 ); }
workspace ); if ( proxyConfig != null ) { setupProxyParameters( proxyConfig ); throw new ResourceInitException( msg, e ); logProxyConfiguration( LOG ); LOG.info( "" );
public static String getFtpNonProxyHosts( boolean considerBaseConfig ) { String result = System.getProperty( FTP_NON_PROXY_HOSTS ); if ( considerBaseConfig && result == null ) { result = getNonProxyHosts(); } return result; }
public static String getHttpProxyUser( boolean considerBaseConfig ) { String result = System.getProperty( HTTP_PROXY_USER ); if ( considerBaseConfig && result == null ) { result = getProxyUser(); } return result; }
public static String getHttpProxyHost( boolean considerBaseConfig ) { String result = System.getProperty( HTTP_PROXY_HOST ); if ( considerBaseConfig && result == null ) { result = getProxyHost(); } return result; }
public static String getHttpProxyPassword( boolean considerBaseConfig ) { String result = System.getProperty( HTTP_PROXY_PASSWORD ); if ( considerBaseConfig && result == null ) { result = getProxyPassword(); } return result; }
setProperty( PROXY_HOST, proxyHost ); setProperty( HTTP_PROXY_HOST, httpProxyHost ); setProperty( FTP_PROXY_HOST, ftpProxyHost ); setProperty( PROXY_PORT, "" + proxyPort ); } else { setProperty( PROXY_PORT, null ); setProperty( HTTP_PROXY_PORT, "" + httpProxyPort ); } else { setProperty( HTTP_PROXY_PORT, null ); setProperty( FTP_PROXY_PORT, "" + ftpProxyPort ); } else { setProperty( FTP_PROXY_PORT, null ); setProperty( PROXY_USER, proxyUser ); setProperty( HTTP_PROXY_USER, httpProxyUser ); setProperty( FTP_PROXY_USER, ftpProxyUser ); setProperty( PROXY_PASSWORD, proxyPassword ); setProperty( HTTP_PROXY_PASSWORD, httpProxyPassword ); setProperty( FTP_PROXY_PASSWORD, ftpProxyPassword );
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() ) ); } }
public static String getHttpProxyPort( boolean considerBaseConfig ) { String result = System.getProperty( HTTP_PROXY_PORT ); if ( considerBaseConfig && result == null ) { result = getProxyPort(); } return result; }
public static String getHttpNonProxyHosts( boolean considerBaseConfig ) { String result = System.getProperty( HTTP_NON_PROXY_HOSTS ); if ( considerBaseConfig && result == null ) { result = getNonProxyHosts(); } return result; }
public static String getFtpProxyUser( boolean considerBaseConfig ) { String result = System.getProperty( FTP_PROXY_USER ); if ( considerBaseConfig && result == null ) { result = getProxyUser(); } return result; }
public static String getFtpProxyHost( boolean considerBaseConfig ) { String result = System.getProperty( FTP_PROXY_HOST ); if ( considerBaseConfig && result == null ) { result = getProxyHost(); } return result; }
public static String getFtpProxyPassword( boolean considerBaseConfig ) { String result = System.getProperty( FTP_PROXY_PASSWORD ); if ( considerBaseConfig && result == null ) { result = getProxyPassword(); } return result; }
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() ); } }