### Eclipse Workspace Patch 1.0 #P org.eclipse.wst.xml.core Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/META-INF/MANIFEST.MF,v retrieving revision 1.54 diff -u -r1.54 MANIFEST.MF --- META-INF/MANIFEST.MF 13 Oct 2009 19:03:44 -0000 1.54 +++ META-INF/MANIFEST.MF 22 Apr 2010 11:25:50 -0000 @@ -71,6 +71,8 @@ org.eclipse.emf.ecore.xmi;bundle-version="[2.4.0,3.0.0)";resolution:=optional, org.eclipse.wst.common.emfworkbench.integration;bundle-version="[1.1.300,1.3.0)";resolution:=optional, org.eclipse.wst.common.core;bundle-version="[1.1.201,1.3.0)", - org.eclipse.osgi.services;bundle-version="[3.2.0,4.0.0)" + org.eclipse.osgi.services;bundle-version="[3.2.0,4.0.0)", + org.eclipse.core.net;bundle-version="1.2.100", + org.apache.commons.codec;bundle-version="1.3.0" Bundle-ActivationPolicy: lazy; exclude:="org.eclipse.wst.xml.core.internal.contenttype" Bundle-RequiredExecutionEnvironment: J2SE-1.4 Index: src-validation/org/eclipse/wst/xml/core/internal/validation/ValidatorHelper.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/ValidatorHelper.java,v retrieving revision 1.14 diff -u -r1.14 ValidatorHelper.java --- src-validation/org/eclipse/wst/xml/core/internal/validation/ValidatorHelper.java 11 Dec 2008 01:31:12 -0000 1.14 +++ src-validation/org/eclipse/wst/xml/core/internal/validation/ValidatorHelper.java 22 Apr 2010 11:25:50 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2008 IBM Corporation and others. + * Copyright (c) 2001, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,15 +11,22 @@ package org.eclipse.wst.xml.core.internal.validation; +import java.io.IOException; import java.io.InputStream; import java.io.Reader; +import java.net.URISyntaxException; import java.net.URL; +import java.net.URLConnection; import java.util.List; import java.util.Vector; +import org.apache.commons.codec.binary.Base64; +import org.eclipse.core.net.proxy.IProxyData; +import org.eclipse.core.net.proxy.IProxyService; import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver; import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin; import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -270,7 +277,7 @@ try { URL url = new URL(location); - is = url.openStream(); + is = getProxiedInputStream(url); isGrammarEncountered = true; } catch(Exception e) @@ -358,4 +365,23 @@ } return string; } + + private static InputStream getProxiedInputStream(final URL url) throws IOException, URISyntaxException { + final IProxyService proxyService = XMLCorePlugin.getDefault().getProxyService(); + final IProxyData[] proxyDatas = proxyService.select(url.toURI()); + if (proxyDatas.length > 0) { + final IProxyData proxyData = proxyDatas[0]; + if (proxyData.isRequiresAuthentication()) { + final String user = proxyData.getUserId(); + final String password = proxyData.getPassword(); + final String proxyAuthorizationValue = "Basic " + Base64.encodeBase64((user + ":" + password).getBytes()); //$NON-NLS-1$ //$NON-NLS-2$ + final URLConnection conn= url.openConnection(); + conn.setRequestProperty("Proxy-Authorization", proxyAuthorizationValue); //$NON-NLS-1$ + conn.connect(); + return conn.getInputStream(); + } + } + return url.openConnection().getInputStream(); + } + } Index: src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java,v retrieving revision 1.11 diff -u -r1.11 XMLCorePlugin.java --- src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java 10 Apr 2007 20:05:35 -0000 1.11 +++ src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java 22 Apr 2010 11:25:50 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2006 IBM Corporation and others. + * Copyright (c) 2001, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,12 +12,15 @@ *******************************************************************************/ package org.eclipse.wst.xml.core.internal; +import org.eclipse.core.net.proxy.IProxyService; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.Plugin; import org.eclipse.wst.xml.core.internal.catalog.Catalog; import org.eclipse.wst.xml.core.internal.catalog.CatalogSet; import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; /** @@ -31,7 +34,7 @@ public static final String SYSTEM_CATALOG_ID = "system_catalog"; //$NON-NLS-1$ private CatalogSet catalogSet = null; private String defaultCatalogFileStateLocation; - + private IProxyService proxyService; /** * Returns the shared instance. @@ -46,6 +49,13 @@ public static IWorkspace getWorkspace() { return ResourcesPlugin.getWorkspace(); } + + /** + * Returns proxy service to fetch XML schema file if proxy configured. See bug #299232. + */ + public IProxyService getProxyService() { + return proxyService; + } /** * The constructor. @@ -77,4 +87,10 @@ return catalogSet.lookupOrCreateCatalog(DEFAULT_CATALOG_ID, defaultCatalogFileStateLocation); } + public void start(BundleContext context) throws Exception { + super.start(context); + ServiceReference reference = context.getServiceReference(IProxyService.class.getName()); + IProxyService proxyService = (IProxyService) context.getService(reference); + this.proxyService = proxyService; + } }