Author: kstam
Date: Wed Sep 14 18:46:25 2011
New Revision: 1170767

URL: http://svn.apache.org/viewvc?rev=1170767&view=rev
Log:
JUDDI-512, support the situation where the endpoints are protected by basic 
authentication.

Modified:
    
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/UDDIServiceWSDL.java
    
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java
    
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/JAXWSTransport.java
    
juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/UDDIServiceWSDLTest.java
    
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/HTTPNotifier.java
    
juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_001_UDDIServiceTest.java

Modified: 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java?rev=1170767&r1=1170766&r2=1170767&view=diff
==============================================================================
--- 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java
 (original)
+++ 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java
 Wed Sep 14 18:46:25 2011
@@ -45,6 +45,8 @@ public class Property 
        public static final String BINDING_DESCRIPTION              = 
"bindingDescription";
        public static final String SERVICE_CATEGORY_BAG             = 
"serviceCategoryBag";
        public static final String BINDING_CATEGORY_BAG             = 
"bindingCategoryBag";
+       public static final String BASIC_AUTH_USERNAME              = 
"basicAuthUsername";
+       public static final String BASIC_AUTH_PASSWORD              = 
"basicAuthPassword";
        
        //Default Values
        public static final String DEFAULT_LANG                     = "en:";

Modified: 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/JAXWSTransport.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/JAXWSTransport.java?rev=1170767&r1=1170766&r2=1170767&view=diff
==============================================================================
--- 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/JAXWSTransport.java
 (original)
+++ 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/JAXWSTransport.java
 Wed Sep 14 18:46:25 2011
@@ -16,13 +16,15 @@
  */
 package org.apache.juddi.v3.client.transport;
 
-import java.net.URL;
+import java.util.Map;
+import java.util.Properties;
 
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
+import javax.xml.ws.BindingProvider;
 
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.juddi.v3.client.JUDDIApiService;
 import org.apache.juddi.v3.client.UDDIService;
-import org.apache.juddi.v3.client.UDDIServiceWSDL;
+import org.apache.juddi.v3.client.config.Property;
 import org.apache.juddi.v3.client.config.UDDIClerkManager;
 import org.apache.juddi.v3.client.config.UDDIClientContainer;
 import org.apache.juddi.v3_service.JUDDIApiPortType;
@@ -35,9 +37,6 @@ import org.uddi.v3_service.UDDISubscript
 
 
 public class JAXWSTransport extends Transport {
-
-       public final static String JUDDI_V3_SERVICE_NAMESPACE    = 
"urn:juddi-apache-org:v3_service";
-       public final static String PUBLISHER_SERVICE             = 
"JUDDIApiService";
        
        String nodeName = null;
        String managerName = null;
@@ -73,9 +72,11 @@ public class JAXWSTransport extends Tran
                                        UDDIClerkManager manager = 
UDDIClientContainer.getUDDIClerkManager(managerName);
                                        endpointURL = 
manager.getClientConfig().getUDDINode(nodeName).getInquiryUrl();
                                }
-                               URL tmpWSDLFile = new 
UDDIServiceWSDL().getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.INQUIRY, 
endpointURL);
-                               UDDIService service = new 
UDDIService(tmpWSDLFile);
+                               UDDIService service = new UDDIService();
                                inquiryService = service.getUDDIInquiryPort();
+                               Map<String, Object> requestContext = 
((BindingProvider) inquiryService).getRequestContext();
+                               
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
+                               setCredentials(requestContext);
                        } catch (Exception e) {
                                throw new TransportException(e.getMessage(), e);
                        }
@@ -91,9 +92,11 @@ public class JAXWSTransport extends Tran
                                        UDDIClerkManager manager = 
UDDIClientContainer.getUDDIClerkManager(managerName);
                                        endpointURL = 
manager.getClientConfig().getUDDINode(nodeName).getSecurityUrl();
                                }
-                               URL tmpWSDLFile = new 
UDDIServiceWSDL().getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.SECURITY, 
endpointURL);
-                               UDDIService service = new 
UDDIService(tmpWSDLFile);
+                               UDDIService service = new UDDIService();
                                securityService = service.getUDDISecurityPort();
+                               Map<String, Object> requestContext = 
((BindingProvider) securityService).getRequestContext();
+                               
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
+                               setCredentials(requestContext);
                        } catch (Exception e) {
                                throw new TransportException(e.getMessage(), e);
                        }
@@ -109,9 +112,11 @@ public class JAXWSTransport extends Tran
                                        UDDIClerkManager manager = 
UDDIClientContainer.getUDDIClerkManager(managerName);
                                        endpointURL = 
manager.getClientConfig().getUDDINode(nodeName).getPublishUrl();
                                }
-                               URL tmpWSDLFile = new 
UDDIServiceWSDL().getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.PUBLISH, 
endpointURL);
-                               UDDIService service = new 
UDDIService(tmpWSDLFile);
+                               UDDIService service = new UDDIService();
                                publishService = 
service.getUDDIPublicationPort();
+                               Map<String, Object> requestContext = 
((BindingProvider) publishService).getRequestContext();
+                               
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
+                               setCredentials(requestContext);
                        } catch (Exception e) {
                                throw new TransportException(e.getMessage(), e);
                        }
@@ -127,9 +132,11 @@ public class JAXWSTransport extends Tran
                                        UDDIClerkManager manager = 
UDDIClientContainer.getUDDIClerkManager(managerName);
                                        endpointURL = 
manager.getClientConfig().getUDDINode(nodeName).getSubscriptionUrl();
                                }
-                               URL tmpWSDLFile = new 
UDDIServiceWSDL().getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.SUBSCRIPTION,
 endpointURL);
-                               UDDIService service = new 
UDDIService(tmpWSDLFile);
+                               UDDIService service = new UDDIService();
                                subscriptionService = 
service.getUDDISubscriptionPort();
+                               Map<String, Object> requestContext = 
((BindingProvider) subscriptionService).getRequestContext();
+                               
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
+                               setCredentials(requestContext);
                        } catch (Exception e) {
                                throw new TransportException(e.getMessage(), e);
                        }
@@ -144,9 +151,11 @@ public class JAXWSTransport extends Tran
                                        UDDIClerkManager manager = 
UDDIClientContainer.getUDDIClerkManager(managerName);
                                        endpointURL = 
manager.getClientConfig().getUDDINode(nodeName).getSubscriptionListenerUrl();
                                }
-                               URL tmpWSDLFile = new 
UDDIServiceWSDL().getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.SUBSCRIPTION_LISTENER,
 endpointURL);
-                               UDDIService service = new 
UDDIService(tmpWSDLFile);
+                               UDDIService service = new UDDIService();
                                subscriptionListenerService = 
service.getUDDISubscriptionListenerPort();
+                               Map<String, Object> requestContext = 
((BindingProvider) subscriptionListenerService).getRequestContext();
+                               
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
+                               setCredentials(requestContext);
                        } catch (Exception e) {
                                throw new TransportException(e.getMessage(), e);
                        }
@@ -161,9 +170,11 @@ public class JAXWSTransport extends Tran
                                        UDDIClerkManager manager = 
UDDIClientContainer.getUDDIClerkManager(managerName);
                                        endpointURL = 
manager.getClientConfig().getUDDINode(nodeName).getCustodyTransferUrl();
                                }
-                               URL tmpWSDLFile = new 
UDDIServiceWSDL().getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.CUSTODY_TRANSFER,
 endpointURL);
-                               UDDIService service = new 
UDDIService(tmpWSDLFile);
+                               UDDIService service = new UDDIService();
                                custodyTransferService = 
service.getUDDICustodyPort();
+                               Map<String, Object> requestContext = 
((BindingProvider) custodyTransferService).getRequestContext();
+                               
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
+                               setCredentials(requestContext);
                        } catch (Exception e) {
                                throw new TransportException(e.getMessage(), e);
                        }
@@ -181,9 +192,11 @@ public class JAXWSTransport extends Tran
                                        UDDIClerkManager manager = 
UDDIClientContainer.getUDDIClerkManager(managerName);
                                        endpointURL = 
manager.getClientConfig().getUDDINode(nodeName).getJuddiApiUrl();
                                }
-                               QName qName = new 
QName(JUDDI_V3_SERVICE_NAMESPACE, PUBLISHER_SERVICE);
-                               Service service = Service.create(new 
URL(endpointURL), qName);
+                               JUDDIApiService service = new JUDDIApiService();
                                publisherService = (JUDDIApiPortType) 
service.getPort(JUDDIApiPortType.class);
+                               Map<String, Object> requestContext = 
((BindingProvider) publisherService).getRequestContext();
+                               
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
+                               setCredentials(requestContext);
                        } catch (Exception e) {
                                throw new TransportException(e.getMessage(), e);
                        }
@@ -199,6 +212,29 @@ public class JAXWSTransport extends Tran
                this.nodeName = nodeName;
        }
        
-       
+       /**
+        * Sets the credentials on the RequestContext if the services are 
protected
+        * by Basic Authentication. The username and password are obtained from 
the 
+        * uddi.xml.
+        * 
+        * @param requestContext
+        * @throws ConfigurationException
+        */
+       private void setCredentials(Map<String, Object> requestContext) throws 
ConfigurationException {
+               UDDIClerkManager manager = 
UDDIClientContainer.getUDDIClerkManager(managerName);
+               Properties properties = 
manager.getClientConfig().getUDDINode(nodeName).getProperties();
+               String username = null;
+               String password = null;
+               if (properties.containsKey(Property.BASIC_AUTH_USERNAME)) {
+                       username = 
properties.getProperty(Property.BASIC_AUTH_USERNAME);
+               }
+               if (properties.containsKey(Property.BASIC_AUTH_PASSWORD)) {
+                       password = 
properties.getProperty(Property.BASIC_AUTH_PASSWORD);
+               }
+               if (username!=null && password!=null) {
+                       requestContext.put(BindingProvider.USERNAME_PROPERTY, 
username);
+                       requestContext.put(BindingProvider.PASSWORD_PROPERTY, 
password);
+               }
+       }
 
 }

Modified: 
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/HTTPNotifier.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/HTTPNotifier.java?rev=1170767&r1=1170766&r2=1170767&view=diff
==============================================================================
--- 
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/HTTPNotifier.java
 (original)
+++ 
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/HTTPNotifier.java
 Wed Sep 14 18:46:25 2011
@@ -3,8 +3,10 @@ package org.apache.juddi.subscription.no
 import java.io.IOException;
 import java.net.URL;
 import java.rmi.RemoteException;
+import java.util.Map;
 
 import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Service;
 
 import org.apache.commons.logging.Log;
@@ -12,7 +14,6 @@ import org.apache.commons.logging.LogFac
 import org.apache.juddi.api_v3.AccessPointType;
 import org.apache.juddi.model.BindingTemplate;
 import org.apache.juddi.v3.client.UDDIService;
-import org.apache.juddi.v3.client.UDDIServiceWSDL;
 import org.uddi.api_v3.DispositionReport;
 import org.uddi.subr_v3.NotifySubscriptionListener;
 import org.uddi.v3_service.DispositionReportFaultMessage;
@@ -41,9 +42,11 @@ public class HTTPNotifier implements Not
                        subscriptionListenerPort = 
(UDDISubscriptionListenerPortType) 
service.getPort(UDDISubscriptionListenerPortType.class);
                } else if 
(AccessPointType.END_POINT.toString().equalsIgnoreCase(bindingTemplate.getAccessPointType()))
 {
                        //endpoint deployment type
-                       URL tmpWSDLFile = new 
UDDIServiceWSDL().getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.SUBSCRIPTION_LISTENER,
 accessPointUrl);
-                       UDDIService uddiService = new UDDIService(tmpWSDLFile);
+                       UDDIService uddiService = new UDDIService();
                        subscriptionListenerPort =  
uddiService.getUDDISubscriptionListenerPort();
+                       Map<String, Object> requestContext = ((BindingProvider) 
subscriptionListenerPort).getRequestContext();
+                       
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, accessPointUrl);
+                       
                }
        }
 

Modified: 
juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_001_UDDIServiceTest.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_001_UDDIServiceTest.java?rev=1170767&r1=1170766&r2=1170767&view=diff
==============================================================================
--- 
juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_001_UDDIServiceTest.java
 (original)
+++ 
juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_001_UDDIServiceTest.java
 Wed Sep 14 18:46:25 2011
@@ -7,7 +7,6 @@ import java.net.URL;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.juddi.v3.client.UDDIService;
-import org.apache.juddi.v3.client.UDDIServiceWSDL;
 import org.apache.juddi.v3.client.config.UDDIClerkManager;
 import org.apache.juddi.v3.client.config.UDDINode;
 import org.junit.AfterClass;
@@ -46,11 +45,7 @@ public class UDDI_001_UDDIServiceTest {
        
        @Test
        public void findSecurityPort() throws IOException {
-               String url = uddiServer.getSecurityUrl();
-               UDDIServiceWSDL uddiServiceWSDL = new UDDIServiceWSDL();
-               URL tmpWSDLFile = 
uddiServiceWSDL.getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.SECURITY, url);
-               System.out.println("WSDL File: " + tmpWSDLFile);
-               UDDIService uddiService = new UDDIService(tmpWSDLFile);
+               UDDIService uddiService = new UDDIService();
                UDDISecurityPortType port = uddiService.getUDDISecurityPort();
            assertNotNull(port);
            GetAuthToken body = new GetAuthToken();
@@ -62,30 +57,21 @@ public class UDDI_001_UDDIServiceTest {
        
        @Test
        public void findInquiryPort() throws IOException {
-               UDDIServiceWSDL uddiServiceWSDL = new UDDIServiceWSDL();
-               String url = uddiServer.getSecurityUrl();
-               URL tmpWSDLFile = 
uddiServiceWSDL.getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.INQUIRY, url);
-               UDDIService uddiService = new UDDIService(tmpWSDLFile);
+               UDDIService uddiService = new UDDIService();
                UDDIInquiryPortType port = uddiService.getUDDIInquiryPort();
            assertNotNull(port);
        }
        
        @Test
        public void findPublicationPort() throws IOException {
-               UDDIServiceWSDL uddiServiceWSDL = new UDDIServiceWSDL();
-               String url = uddiServer.getSecurityUrl();
-               URL tmpWSDLFile = 
uddiServiceWSDL.getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.PUBLISH, url);
-               UDDIService uddiService = new UDDIService(tmpWSDLFile);
+               UDDIService uddiService = new UDDIService();
                UDDIPublicationPortType port = 
uddiService.getUDDIPublicationPort();
            assertNotNull(port);
        }
        
        @Test
        public void findSubscriptionPort() throws IOException {
-               UDDIServiceWSDL uddiServiceWSDL = new UDDIServiceWSDL();
-               String url = uddiServer.getSecurityUrl();
-               URL tmpWSDLFile = 
uddiServiceWSDL.getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.SUBSCRIPTION, 
url);
-               UDDIService uddiService = new UDDIService(tmpWSDLFile);
+               UDDIService uddiService = new UDDIService();
                UDDISubscriptionPortType port = 
uddiService.getUDDISubscriptionPort();
            assertNotNull(port);
        }
@@ -94,9 +80,7 @@ public class UDDI_001_UDDIServiceTest {
        public void findReplicationPort() throws IOException {
                String url = uddiServer.getSecurityUrl();
                if (url!=null) { //Replication is option, but if it is 
configured in the uddi.xml then we assume it is implemented
-                       UDDIServiceWSDL uddiServiceWSDL = new UDDIServiceWSDL();
-                       URL tmpWSDLFile = 
uddiServiceWSDL.getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.REPLICATION,url);
-                       UDDIService uddiService = new UDDIService(tmpWSDLFile);
+                       UDDIService uddiService = new UDDIService();
                        UDDIReplicationPortType port = 
uddiService.getUDDIReplicationPort();
                    assertNotNull(port);
                }
@@ -106,9 +90,7 @@ public class UDDI_001_UDDIServiceTest {
        public void findSubscriptionListenerPort() throws IOException {
                String url = uddiServer.getSecurityUrl();
                if (url!=null) { //Subscription Listener is client side, but if 
it is configured in the uddi.xml then we assume it is implemented
-                       UDDIServiceWSDL uddiServiceWSDL = new UDDIServiceWSDL();
-                       URL tmpWSDLFile = 
uddiServiceWSDL.getWSDLFilePath(UDDIServiceWSDL.WSDLEndPointType.SUBSCRIPTION_LISTENER,
 url);
-                       UDDIService uddiService = new UDDIService(tmpWSDLFile);
+                       UDDIService uddiService = new UDDIService();
                        UDDISubscriptionListenerPortType port = 
uddiService.getUDDISubscriptionListenerPort();
                    assertNotNull(port);
                }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to