View Javadoc
1   /*
2    * Copyright 2001-2008 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   */
17  package org.apache.juddi.subscription.notify;
18  
19  import java.io.IOException;
20  import java.net.URL;
21  import java.rmi.RemoteException;
22  import java.util.Map;
23  
24  import javax.xml.namespace.QName;
25  import javax.xml.ws.BindingProvider;
26  import javax.xml.ws.Service;
27  
28  import org.apache.commons.logging.Log;
29  import org.apache.commons.logging.LogFactory;
30  import org.apache.juddi.api_v3.AccessPointType;
31  import org.apache.juddi.model.BindingTemplate;
32  import org.apache.juddi.v3.client.UDDIService;
33  import org.uddi.api_v3.DispositionReport;
34  import org.uddi.subr_v3.NotifySubscriptionListener;
35  import org.uddi.v3_service.DispositionReportFaultMessage;
36  import org.uddi.v3_service.UDDISubscriptionListenerPortType;
37  
38  public class HTTPNotifier implements Notifier {
39  
40      private static String SUBR_V3_NAMESPACE = "urn:uddi-org:v3_service";
41      private static String SUBSCRIPTION_LISTENER_SERVICE = "UDDISubscriptionListenerImplPort";
42      Log log = LogFactory.getLog(this.getClass());
43      UDDISubscriptionListenerPortType subscriptionListenerPort = null;
44  
45      public HTTPNotifier(BindingTemplate bindingTemplate) throws IOException {
46          super();
47          String accessPointUrl = bindingTemplate.getAccessPointUrl().toLowerCase();
48          if (!accessPointUrl.startsWith("http")) {
49              log.warn("http accessPointUrl for bindingTemplate " + bindingTemplate.getEntityKey()
50                      + " should start with 'http' or 'https'");
51          }
52          //fix for JIRA JUDDI-597
53          accessPointUrl = bindingTemplate.getAccessPointUrl();
54          if (AccessPointType.WSDL_DEPLOYMENT.toString().equalsIgnoreCase(bindingTemplate.getAccessPointType())) {
55              //WSDL deployment type
56              //TODO, let user override the SUBSCRIPTION_LISTENER_SERVICE setting
57              QName qName = new QName(SUBR_V3_NAMESPACE, SUBSCRIPTION_LISTENER_SERVICE);
58              Service service = Service.create(new URL(bindingTemplate.getAccessPointUrl()), qName);
59              subscriptionListenerPort = (UDDISubscriptionListenerPortType) service.getPort(UDDISubscriptionListenerPortType.class);
60          } else if (AccessPointType.END_POINT.toString().equalsIgnoreCase(bindingTemplate.getAccessPointType())) {
61              //endpoint deployment type
62              UDDIService uddiService = new UDDIService();
63              subscriptionListenerPort = uddiService.getUDDISubscriptionListenerPort();
64              Map<String, Object> requestContext = ((BindingProvider) subscriptionListenerPort).getRequestContext();
65              requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, accessPointUrl);
66          }
67          /*if (accessPointUrl.toLowerCase().startsWith("https://")) {
68              try {
69                  String file = AppConfig.getConfiguration().getString(Property.JUDDI_SUBSCRIPTION_TRUSTSTORE_FILE);
70                  String type = AppConfig.getConfiguration().getString(Property.JUDDI_SUBSCRIPTION_TRUSTSTORE_TYPE);
71                  String password = AppConfig.getConfiguration().getString(Property.JUDDI_SUBSCRIPTION_TRUSTSTORE_PASSWORD);
72                  if (AppConfig.getConfiguration().getBoolean(Property.JUDDI_SUBSCRIPTION_TRUSTSTORE_ENCRYPTED, false)) {
73                      password = CryptorFactory.getCryptor(AppConfig.getConfiguration().getString(Property.JUDDI_SUBSCRIPTION_TRUSTSTORE_CRYPTOPROVIDER)).decrypt(password);
74                  }
75                  
76              } catch (Exception ex) {
77                  log.error(null, ex);
78              }
79  
80          }*/
81      }
82  
83      public DispositionReport notifySubscriptionListener(NotifySubscriptionListener body) throws DispositionReportFaultMessage, RemoteException {
84          return subscriptionListenerPort.notifySubscriptionListener(body);
85      }
86  }