Author: alexoree
Date: Mon May 20 22:55:26 2013
New Revision: 1484621
URL: http://svn.apache.org/r1484621
Log:
Adding in some additional changes from the 3.2 branch that were missed (svn?).
specifically, WSDL2UDDI changes
Modified:
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ReadWSDL.java
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/WSDLLocatorImpl.java
juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDL2UDDITest.java
juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDLinaUDDIRegistryTest.java
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java
juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_051_BindingTemplateWSDLTest.java
Modified:
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ReadWSDL.java
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ReadWSDL.java?rev=1484621&r1=1484620&r2=1484621&view=diff
==============================================================================
---
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ReadWSDL.java
(original)
+++
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ReadWSDL.java
Mon May 20 22:55:26 2013
@@ -37,9 +37,10 @@ import com.ibm.wsdl.factory.WSDLFactoryI
*/
public class ReadWSDL {
+ private boolean IgnoreSSLErrors = false;
private final Log log = LogFactory.getLog(this.getClass());
- public Definition readWSDL(String fileName) throws WSDLException {
+ public Definition readWSDL(String fileName) throws Exception {
Definition wsdlDefinition = null;
WSDLFactory factory = WSDLFactoryImpl.newInstance();
@@ -65,20 +66,34 @@ public class ReadWSDL {
* @return a Definition object representing the WSDL
* @throws WSDLException
*/
- public Definition readWSDL(URL wsdlUrl, String username, String
password) throws WSDLException {
+ public Definition readWSDL(URL wsdlUrl, String username, String
password) throws WSDLException, Exception {
Definition wsdlDefinition = null;
WSDLFactory factory = WSDLFactoryImpl.newInstance();
WSDLReader reader = factory.newWSDLReader();
+ URI uri=null;
try {
- URI uri = wsdlUrl.toURI();
- WSDLLocator locator = new WSDLLocatorImpl(uri);
- wsdlDefinition = reader.readWSDL(locator);
- } catch (URISyntaxException e) {
+ uri = wsdlUrl.toURI();
+ } catch (Exception e) {
log.error(e.getMessage(),e);
+ throw new WSDLException("Unable to parse the URL",
null, e);
+ }
+ WSDLLocatorImpl locator = new WSDLLocatorImpl(uri, username,
password, IgnoreSSLErrors );
+ try{
+ wsdlDefinition = reader.readWSDL(locator);
+ } catch (Exception e) {
+ log.error(e.getMessage(),e);
+ if (locator.getLastException()!=null)
+ {
+
log.error(e.getMessage(),locator.getLastException());
+ throw locator.getLastException();
+ }
+ throw e;
+ //throw new WSDLException("Error loading from " +
wsdlUrl.toString(), null, e);
}
return wsdlDefinition;
}
+
/**
* Reads a WSDL file, assumes that credentials are not required. This
is a convenience wrapper for
* readWSDL(URL wsdlUrl, null, null, null)
@@ -86,9 +101,17 @@ public class ReadWSDL {
* @return a Definition object representing the WSDL
* @throws WSDLException
*/
- public Definition readWSDL(URL wsdlUrl) throws WSDLException {
+ public Definition readWSDL(URL wsdlUrl) throws Exception {
return readWSDL(wsdlUrl, null, null);
}
+
+ public boolean isIgnoreSSLErrors() {
+ return IgnoreSSLErrors;
+ }
+
+ public void setIgnoreSSLErrors(boolean IgnoreSSLErrors) {
+ this.IgnoreSSLErrors = IgnoreSSLErrors;
+ }
Modified:
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/WSDLLocatorImpl.java
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/WSDLLocatorImpl.java?rev=1484621&r1=1484620&r2=1484621&view=diff
==============================================================================
---
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/WSDLLocatorImpl.java
(original)
+++
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/WSDLLocatorImpl.java
Mon May 20 22:55:26 2013
@@ -22,32 +22,34 @@ import java.io.InputStream;
import java.io.StringReader;
import java.net.URI;
import java.net.URL;
-
import javax.wsdl.xml.WSDLLocator;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.BasicClientConnectionManager;
import org.xml.sax.InputSource;
/**
* Implementation of the interface {@link WSDLLocatorImpl}.
*
- * @author <a href="mailto:[email protected]">Kurt T Stam</a> Modified for
- * supporting http based credentials by Alex O'Ree
+ * @author <a href="mailto:[email protected]">Kurt T Stam</a>
+ * @author Alex O'Ree - Modified for supporting http based credentials
*/
public class WSDLLocatorImpl implements WSDLLocator {
-
+ private Exception lastException=null;
private final Log log = LogFactory.getLog(this.getClass());
private InputStream inputStream = null;
private URI baseURI;
+ private boolean ignoreSSLErrors = false;
private String latestImportURI;
private String username = null, password = null;
@@ -59,6 +61,7 @@ public class WSDLLocatorImpl implements
*/
public WSDLLocatorImpl(URI baseURI) {
this.baseURI = baseURI;
+ this.ignoreSSLErrors = ignoreSSLErrors;
}
/**
@@ -71,10 +74,11 @@ public class WSDLLocatorImpl implements
* @param password
* @param domain
*/
- public WSDLLocatorImpl(URI baseURI, String username, String password) {
+ public WSDLLocatorImpl(URI baseURI, String username, String password,
boolean ignoreSSLErrors) {
this.baseURI = baseURI;
this.username = username;
this.password = password;
+ this.ignoreSSLErrors = ignoreSSLErrors;
}
/**
@@ -116,23 +120,35 @@ public class WSDLLocatorImpl implements
private InputSource getImportFromUrl(String url) {
InputSource inputSource = null;
- DefaultHttpClient httpclient = new DefaultHttpClient();
+ DefaultHttpClient httpclient = null;
try {
URL url2 = new URL(url);
if (!url.toLowerCase().startsWith("http")) {
return getImportFromFile(url);
}
+ boolean usessl = false;
+ int port = 80;
+ if (url.toLowerCase().startsWith("https://")) {
+ port = 443;
+ usessl = true;
+ }
+
+ if (url2.getPort() > 0) {
+ port = url2.getPort();
+ }
+
+ if (ignoreSSLErrors && usessl) {
+ SchemeRegistry schemeRegistry = new SchemeRegistry();
+ schemeRegistry.register(new Scheme("https", port, new
MockSSLSocketFactory()));
+ ClientConnectionManager cm = new
BasicClientConnectionManager(schemeRegistry);
+ httpclient = new DefaultHttpClient(cm);
+ } else {
+ httpclient = new DefaultHttpClient();
+ }
if (username != null && username.length() > 0
&& password != null && password.length() > 0) {
- int port = 80;
- if (url.toLowerCase().startsWith("https://")) {
- port = 443;
- }
-
- if (url2.getPort() > 0) {
- port = url2.getPort();
- }
+
httpclient.getCredentialsProvider().setCredentials(
new AuthScope(url2.getHost(), port),
@@ -162,8 +178,11 @@ public class WSDLLocatorImpl implements
latestImportURI = url;
} catch (Exception e) {
log.error(e.getMessage(), e);
+ lastException = e;
} finally {
- httpclient.getConnectionManager().shutdown();
+ if (httpclient != null) {
+ httpclient.getConnectionManager().shutdown();
+ }
}
return inputSource;
}
@@ -178,6 +197,7 @@ public class WSDLLocatorImpl implements
return getImportFromUrl(importUrl.toExternalForm());
} catch (Exception e) {
log.error(e.getMessage(), e);
+ lastException=e;
}
return inputSource;
}
@@ -191,6 +211,7 @@ public class WSDLLocatorImpl implements
baseURIStr = baseURI.toURL().toExternalForm();
} catch (IOException e) {
log.error(e.getMessage(), e);
+ lastException=e;
}
return baseURIStr;
}
@@ -211,6 +232,7 @@ public class WSDLLocatorImpl implements
inputStream.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
+ lastException=e;
}
}
}
@@ -224,7 +246,17 @@ public class WSDLLocatorImpl implements
latestImportURI = importUrl.toExternalForm();
} catch (Exception e) {
log.error(e.getMessage(), e);
+ lastException=e;
}
return inputSource;
}
+
+ /**
+ * Returns the last exception or null if there wasn't any. This was done
because the authors of WSDLLocator apparently thought it would always work
+ * @return
+ */
+ public Exception getLastException()
+ {
+ return lastException;
+ }
}
Modified:
juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDL2UDDITest.java
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDL2UDDITest.java?rev=1484621&r1=1484620&r2=1484621&view=diff
==============================================================================
---
juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDL2UDDITest.java
(original)
+++
juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDL2UDDITest.java
Mon May 20 22:55:26 2013
@@ -41,7 +41,7 @@ public class WSDL2UDDITest {
ReadWSDL rw = new ReadWSDL();
@Test
- public void testUDDIBindingModel() throws WSDLException, JAXBException,
ConfigurationException {
+ public void testUDDIBindingModel() throws WSDLException, JAXBException,
ConfigurationException , Exception{
// Reading the WSDL
Definition wsdlDefinition = rw.readWSDL("wsdl/HelloWorld.wsdl");
@@ -64,7 +64,7 @@ public class WSDL2UDDITest {
}
@Test
- public void testWSDLBindingModel() throws WSDLException, JAXBException,
ConfigurationException {
+ public void testWSDLBindingModel() throws WSDLException, JAXBException,
ConfigurationException, Exception {
// Reading the WSDL
Definition wsdlDefinition = rw.readWSDL("wsdl/HelloWorld.wsdl");
Modified:
juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDLinaUDDIRegistryTest.java
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDLinaUDDIRegistryTest.java?rev=1484621&r1=1484620&r2=1484621&view=diff
==============================================================================
---
juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDLinaUDDIRegistryTest.java
(original)
+++
juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDLinaUDDIRegistryTest.java
Mon May 20 22:55:26 2013
@@ -53,7 +53,7 @@ public class WSDLinaUDDIRegistryTest {
@BeforeClass
- public static void before() {
+ public static void before() throws Exception{
try {
wsdlDefinition = rw.readWSDL("wsdl/sample.wsdl");
properties.put("keyDomain", "uddi.joepublisher.com");
Modified:
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java?rev=1484621&r1=1484620&r2=1484621&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java
(original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java
Mon May 20 22:55:26 2013
@@ -57,4 +57,8 @@ public interface Property {
public final static String HBM_DDL_AUTO = "hibernate.hbm2ddl.auto";
public final static String DEFAULT_SCHEMA = "hibernate.default_schema";
public final static String HIBERNATE_DIALECT = "hibernate.dialect";
+ /**
+ * @since 3.2
+ */
+ public final static String JUDDI_FINE_GRAIN_ACCESS_CONTROL_PROVIDER =
"juddi.fineGrainAccessControlProvider";
}
Modified:
juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_051_BindingTemplateWSDLTest.java
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_051_BindingTemplateWSDLTest.java?rev=1484621&r1=1484620&r2=1484621&view=diff
==============================================================================
---
juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_051_BindingTemplateWSDLTest.java
(original)
+++
juddi/trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_051_BindingTemplateWSDLTest.java
Mon May 20 22:55:26 2013
@@ -81,7 +81,7 @@ public class API_051_BindingTemplateWSDL
}
@Test
- public void testDirectCall() throws ConfigurationException,
WSDLException, RemoteException, TransportException, MalformedURLException {
+ public void testDirectCall() throws ConfigurationException,
WSDLException, RemoteException, TransportException, MalformedURLException,
Exception {
try {
tckTModel.saveJoePublisherTmodel(authInfoJoe);
tckBusiness.saveJoePublisherBusiness(authInfoJoe);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]