d042c9eb1961d7111bd37ce1dc4f39c77fd0b905
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7  * ================================================================================
8  * Modifications Copyright (C) 2018 IBM.
9  * Modifications Copyright (c) 2019 Samsung
10  * ================================================================================
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  * 
15  *      http://www.apache.org/licenses/LICENSE-2.0
16  * 
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.so.adapters.network;
26
27
28 import java.net.MalformedURLException;
29 import java.net.URL;
30 import java.security.GeneralSecurityException;
31 import java.util.Collections;
32 import java.util.HashMap;
33 import java.util.List;
34 import java.util.Map;
35 import javax.jws.WebService;
36 import javax.xml.bind.DatatypeConverter;
37 import javax.xml.namespace.QName;
38 import javax.xml.ws.BindingProvider;
39 import javax.xml.ws.Holder;
40 import javax.xml.ws.handler.MessageContext;
41 import org.onap.so.adapters.network.async.client.CreateNetworkNotification;
42 import org.onap.so.adapters.network.async.client.MsoExceptionCategory;
43 import org.onap.so.adapters.network.async.client.NetworkAdapterNotify;
44 import org.onap.so.adapters.network.async.client.NetworkAdapterNotify_Service;
45 import org.onap.so.adapters.network.async.client.QueryNetworkNotification;
46 import org.onap.so.adapters.network.async.client.UpdateNetworkNotification;
47 import org.onap.so.adapters.network.exceptions.NetworkException;
48 import org.onap.so.entity.MsoRequest;
49 import org.onap.so.logger.ErrorCode;
50 import org.onap.so.logger.MessageEnum;
51 import org.onap.so.openstack.beans.NetworkRollback;
52 import org.onap.so.openstack.beans.NetworkStatus;
53 import org.onap.so.openstack.beans.Subnet;
54 import org.onap.so.utils.CryptoUtils;
55 import org.slf4j.Logger;
56 import org.slf4j.LoggerFactory;
57 import org.springframework.beans.factory.annotation.Autowired;
58 import org.springframework.core.env.Environment;
59 import org.springframework.stereotype.Component;
60
61 @Component
62 @WebService(serviceName = "NetworkAdapterAsync",
63         endpointInterface = "org.onap.so.adapters.network.MsoNetworkAdapterAsync",
64         targetNamespace = "http://org.onap.so/networkA")
65 public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync {
66
67     private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterAsyncImpl.class);
68
69     private static final String BPEL_AUTH_PROP = "org.onap.so.adapters.network.bpelauth";
70     private static final String ENCRYPTION_KEY_PROP = "mso.msoKey";
71     private static final String NETWORK_EXCEPTION_MSG = "Got a NetworkException on createNetwork: ";
72     private static final String CREATE_NETWORK_ERROR_LOGMSG = "{} {} Error sending createNetwork notification {} ";
73     private static final String FAULT_INFO_ERROR_LOGMSG = "{} {} Exception - fault info ";
74     private static final String SHARED = "shared";
75
76     @Autowired
77     private Environment environment;
78
79     @Autowired
80     private MsoNetworkAdapter networkAdapter;
81
82     /**
83      * Health Check web method. Does nothing but return to show the adapter is deployed.
84      */
85     @Override
86     public void healthCheckA() {
87         logger.debug("Health check call in Network Adapter");
88     }
89
90     /**
91      * This is the "Create Network" web service implementation. It will create a new Network of the requested type in
92      * the specified cloud and tenant. The tenant must exist at the time this service is called.
93      *
94      * If a network with the same name already exists, this can be considered a success or failure, depending on the
95      * value of the 'failIfExists' parameter.
96      *
97      * There will be a pre-defined set of network types defined in the MSO Catalog. All such networks will have a
98      * similar configuration, based on the allowable Openstack networking definitions. This includes basic networks,
99      * provider networks (with a single VLAN), and multi-provider networks (one or more VLANs)
100      *
101      * Initially, all provider networks must be "vlan" type, and multiple segments in a multi-provider network must be
102      * multiple VLANs on the same physical network.
103      *
104      * This service supports two modes of Network creation/update: - via Heat Templates - via Neutron API The network
105      * orchestration mode for each network type is declared in its catalog definition. All Heat-based templates must
106      * support some subset of the same input parameters: network_name, physical_network, vlan(s).
107      *
108      * The method returns the network ID and a NetworkRollback object. This latter object can be passed as-is to the
109      * rollbackNetwork operation to undo everything that was created. This is useful if a network is successfully
110      * created but the orchestration fails on a subsequent operation.
111      */
112     @Override
113     public void createNetworkA(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
114             String networkName, String physicalNetworkName, List<Integer> vlans, Boolean failIfExists, Boolean backout,
115             List<Subnet> subnets, Map<String, String> networkParams, String messageId, MsoRequest msoRequest,
116             String notificationUrl) {
117
118         logger.debug("Async Create Network: {} of type {} in {}/{}", networkName, networkType, cloudSiteId, tenantId);
119
120         // Use the synchronous method to perform the actual Create
121
122
123         // Synchronous Web Service Outputs
124         Holder<String> networkId = new Holder<>();
125         Holder<String> neutronNetworkId = new Holder<>();
126         Holder<NetworkRollback> networkRollback = new Holder<>();
127         Holder<Map<String, String>> subnetIdMap = new Holder<>();
128
129         HashMap<String, String> params = (HashMap<String, String>) networkParams;
130         if (params == null)
131             params = new HashMap<>();
132         String shared = null;
133         String external = null;
134         if (params.containsKey(SHARED))
135             shared = params.get(SHARED);
136         if (params.containsKey("external"))
137             external = params.get("external");
138
139         try {
140             networkAdapter.createNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkName,
141                     physicalNetworkName, vlans, shared, external, failIfExists, backout, subnets, params, msoRequest,
142                     networkId, neutronNetworkId, subnetIdMap, networkRollback);
143         } catch (NetworkException e) {
144             logger.debug(NETWORK_EXCEPTION_MSG, e);
145             MsoExceptionCategory exCat = null;
146             String eMsg = null;
147             try {
148                 eMsg = e.getFaultInfo().getMessage();
149                 exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name());
150             } catch (Exception e1) {
151                 logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, ErrorCode.DataError.getValue(),
152                         e1);
153             }
154             // Build and send Asynchronous error response
155             try {
156                 NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
157                 notifyPort.createNetworkNotification(messageId, false, exCat, eMsg, null, null, null, null);
158             } catch (Exception e1) {
159                 logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
160                         ErrorCode.DataError.getValue(), e1.getMessage(), e1);
161
162             }
163             return;
164         }
165         logger.debug("Async Create Network:Name {} physicalNetworkName:{}", networkName, physicalNetworkName);
166         // Build and send Asynchronous response
167         try {
168             NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
169             notifyPort.createNetworkNotification(messageId, true, null, null, networkId.value, neutronNetworkId.value,
170                     copyCreateSubnetIdMap(subnetIdMap), copyNrb(networkRollback));
171         } catch (Exception e) {
172             logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
173                     ErrorCode.DataError.getValue(), e.getMessage(), e);
174
175         }
176         return;
177     }
178
179     /**
180      * This is the "Update Network" web service implementation. It will update an existing Network of the requested type
181      * in the specified cloud and tenant. The typical use will be to replace the VLANs with the supplied list (to add or
182      * remove a VLAN), but other properties may be updated as well.
183      *
184      * There will be a pre-defined set of network types defined in the MSO Catalog. All such networks will have a
185      * similar configuration, based on the allowable Openstack networking definitions. This includes basic networks,
186      * provider networks (with a single VLAN), and multi-provider networks (one or more VLANs).
187      *
188      * Initially, all provider networks must currently be "vlan" type, and multi-provider networks must be multiple
189      * VLANs on the same physical network.
190      *
191      * This service supports two modes of Network update: - via Heat Templates - via Neutron API The network
192      * orchestration mode for each network type is declared in its catalog definition. All Heat-based templates must
193      * support some subset of the same input parameters: network_name, physical_network, vlan, segments.
194      *
195      * The method returns a NetworkRollback object. This object can be passed as-is to the rollbackNetwork operation to
196      * undo everything that was updated. This is useful if a network is successfully updated but orchestration fails on
197      * a subsequent operation.
198      */
199     @Override
200     public void updateNetworkA(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
201             String networkId, String networkName, String physicalNetworkName, List<Integer> vlans, List<Subnet> subnets,
202             Map<String, String> networkParams, String messageId, MsoRequest msoRequest, String notificationUrl) {
203
204         logger.debug("Async Update Network: {} of type {} in {}/{}", networkId, networkType, cloudSiteId, tenantId);
205
206         // Use the synchronous method to perform the actual Create
207
208
209         // Synchronous Web Service Outputs
210         Holder<NetworkRollback> networkRollback = new Holder<>();
211         Holder<Map<String, String>> subnetIdMap = new Holder<>();
212
213         HashMap<String, String> params = (HashMap<String, String>) networkParams;
214         if (params == null)
215             params = new HashMap<>();
216         String shared = null;
217         String external = null;
218         if (params.containsKey(SHARED))
219             shared = params.get(SHARED);
220         if (params.containsKey("external"))
221             external = params.get("external");
222
223         try {
224             networkAdapter.updateNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId,
225                     networkName, physicalNetworkName, vlans, shared, external, subnets, params, msoRequest, subnetIdMap,
226                     networkRollback);
227         } catch (NetworkException e) {
228             logger.debug("Got a NetworkException on updateNetwork: ", e);
229             MsoExceptionCategory exCat = null;
230             String eMsg = null;
231             try {
232                 eMsg = e.getFaultInfo().getMessage();
233                 exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name());
234             } catch (Exception e1) {
235                 logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, ErrorCode.DataError.getValue(),
236                         e1);
237             }
238             // Build and send Asynchronous error response
239             try {
240                 NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
241                 notifyPort.updateNetworkNotification(messageId, false, exCat, eMsg, null, copyNrb(networkRollback));
242             } catch (Exception e1) {
243                 logger.error("{} {} Error sending updateNetwork notification {} ",
244                         MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, ErrorCode.DataError.getValue(), e1.getMessage(), e1);
245
246             }
247             return;
248         }
249         logger.debug("Async Update Network:Name {} NetworkId:{}", networkName, networkId);
250         // Build and send Asynchronous response
251         try {
252             NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
253             notifyPort.updateNetworkNotification(messageId, true, null, null, copyUpdateSubnetIdMap(subnetIdMap),
254                     copyNrb(networkRollback));
255         } catch (Exception e) {
256             logger.error("{} {} Error sending updateNotification request {} ", MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
257                     ErrorCode.DataError.getValue(), e.getMessage(), e);
258         }
259         return;
260     }
261
262     /**
263      * This is the queryNetwork method. It returns the existence and status of the specified network, along with its
264      * Neutron UUID and list of VLANs. This method attempts to find the network using both Heat and Neutron. Heat stacks
265      * are first searched based on the provided network name/id. If none is found, the Neutron is directly queried.
266      */
267     @Override
268     public void queryNetworkA(String cloudSiteId, String tenantId, String networkNameOrId, String messageId,
269             MsoRequest msoRequest, String notificationUrl) {
270
271         logger.debug("Async Query Network {} in {}/{}", networkNameOrId, cloudSiteId, tenantId);
272         String errorCreateNetworkMessage = "{} {} Error sending createNetwork notification {} ";
273
274         // Use the synchronous method to perform the actual Create
275
276
277         // Synchronous Web Service Outputs
278         Holder<Boolean> networkExists = new Holder<>();
279         Holder<String> networkId = new Holder<>();
280         Holder<String> neutronNetworkId = new Holder<>();
281         Holder<NetworkStatus> status = new Holder<>();
282         Holder<List<Integer>> vlans = new Holder<>();
283         Holder<Map<String, String>> subnetIdMap = new Holder<>();
284
285         try {
286             networkAdapter.queryNetwork(cloudSiteId, tenantId, networkNameOrId, msoRequest, networkExists, networkId,
287                     neutronNetworkId, status, vlans, subnetIdMap);
288         } catch (NetworkException e) {
289             logger.debug(NETWORK_EXCEPTION_MSG, e);
290             MsoExceptionCategory exCat = null;
291             String eMsg = null;
292             try {
293                 eMsg = e.getFaultInfo().getMessage();
294                 exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name());
295             } catch (Exception e1) {
296                 logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, ErrorCode.DataError.getValue(),
297                         e1);
298             }
299             // Build and send Asynchronous error response
300             try {
301                 NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
302                 notifyPort.queryNetworkNotification(messageId, false, exCat, eMsg, null, null, null, null, null, null);
303             } catch (Exception e1) {
304                 logger.error(errorCreateNetworkMessage, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
305                         ErrorCode.DataError.getValue(), e1.getMessage(), e1);
306             }
307             return;
308         }
309         logger.debug("Async Query Network:NameOrId {} tenantId:{}", networkNameOrId, tenantId);
310         // Build and send Asynchronous response
311         try {
312             NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
313             org.onap.so.adapters.network.async.client.NetworkStatus networkS =
314                     org.onap.so.adapters.network.async.client.NetworkStatus.fromValue(status.value.name());
315             notifyPort.queryNetworkNotification(messageId, true, null, null, networkExists.value, networkId.value,
316                     neutronNetworkId.value, networkS, vlans.value, copyQuerySubnetIdMap(subnetIdMap));
317         } catch (Exception e) {
318             logger.error(errorCreateNetworkMessage, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
319                     ErrorCode.DataError.getValue(), e.getMessage(), e);
320         }
321         return;
322     }
323
324     /**
325      * This is the "Delete Network" web service implementation. It will delete a Network in the specified cloud and
326      * tenant.
327      *
328      * If the network is not found, it is treated as a success.
329      *
330      * This service supports two modes of Network creation/update/delete: - via Heat Templates - via Neutron API The
331      * network orchestration mode for each network type is declared in its catalog definition.
332      *
333      * For Heat-based orchestration, the networkId should be the stack ID. For Neutron-based orchestration, the
334      * networkId should be the Neutron network UUID.
335      *
336      * The method returns nothing on success. Rollback is not possible for delete commands, so any failure on delete
337      * will require manual fallout in the client.
338      */
339     @Override
340     public void deleteNetworkA(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
341             String networkId, String messageId, MsoRequest msoRequest, String notificationUrl) {
342
343         String serviceName = "DeleteNetworkA";
344         logger.debug("Async Delete Network {} in {}/{}", networkId, cloudSiteId, tenantId);
345
346         // Use the synchronous method to perform the actual Create
347
348
349         // Synchronous Web Service Outputs
350         Holder<Boolean> networkDeleted = new Holder<>();
351
352         try {
353             networkAdapter.deleteNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId,
354                     msoRequest, networkDeleted);
355         } catch (NetworkException e) {
356             logger.debug(NETWORK_EXCEPTION_MSG, e);
357             MsoExceptionCategory exCat = null;
358             String eMsg = null;
359             try {
360                 eMsg = e.getFaultInfo().getMessage();
361                 exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name());
362             } catch (Exception e1) {
363                 logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, ErrorCode.DataError.getValue(),
364                         e1);
365             }
366             // Build and send Asynchronous error response
367             try {
368                 NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
369                 notifyPort.deleteNetworkNotification(messageId, false, exCat, eMsg, null);
370             } catch (Exception e1) {
371                 logger.error("{} {} Error sending createNetwork notification {} ",
372                         MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, ErrorCode.DataError.getValue(), e1.getMessage(), e1);
373
374             }
375             return;
376         }
377         logger.debug("Async Delete NetworkId: {} tenantId:{}", networkId, tenantId);
378         // Build and send Asynchronous response
379         try {
380             NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
381             notifyPort.deleteNetworkNotification(messageId, true, null, null, networkDeleted.value);
382         } catch (Exception e) {
383             logger.error("{} {} Error sending deleteNetwork notification {} ", MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
384                     ErrorCode.DataError.getValue(), e.getMessage(), e);
385
386         }
387         return;
388     }
389
390     /**
391      * This web service endpoint will rollback a previous Create VNF operation. A rollback object is returned to the
392      * client in a successful creation response. The client can pass that object as-is back to the rollbackNetwork
393      * operation to undo the creation.
394      *
395      * The rollback includes removing the VNF and deleting the tenant if the tenant did not exist prior to the VNF
396      * creation.
397      */
398     @Override
399     public void rollbackNetworkA(NetworkRollback rollback, String messageId, String notificationUrl) {
400         // rollback may be null (e.g. if network already existed when Create was called)
401         if (rollback == null) {
402             logger.warn("{} {} Rollback is null", MessageEnum.RA_ROLLBACK_NULL, ErrorCode.SchemaError.getValue());
403             return;
404         }
405
406         logger.info("{} {}", MessageEnum.RA_ASYNC_ROLLBACK, rollback.getNetworkStackId());
407         // Use the synchronous method to perform the actual Create
408
409
410         try {
411             networkAdapter.rollbackNetwork(rollback);
412         } catch (NetworkException e) {
413             logger.debug("Got a NetworkException on rollbackNetwork: ", e);
414             // Build and send Asynchronous error response
415             MsoExceptionCategory exCat = null;
416             String eMsg = null;
417             try {
418                 eMsg = e.getFaultInfo().getMessage();
419                 exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name());
420             } catch (Exception e1) {
421                 logger.error("{} {} Exception in get fault info ", MessageEnum.RA_FAULT_INFO_EXC,
422                         ErrorCode.DataError.getValue(), e1);
423             }
424             // Build and send Asynchronous error response
425             try {
426                 NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
427                 notifyPort.rollbackNetworkNotification(rollback.getMsoRequest().getRequestId(), false, exCat, eMsg);
428             } catch (Exception e1) {
429                 logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
430                         ErrorCode.DataError.getValue(), e1.getMessage(), e1);
431
432             }
433             return;
434         }
435         logger.debug("Async Rollback NetworkId: {} tenantId:{}", rollback.getNetworkStackId(), rollback.getTenantId());
436         // Build and send Asynchronous response
437         try {
438             NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
439             notifyPort.rollbackNetworkNotification(rollback.getMsoRequest().getRequestId(), true, null, null);
440         } catch (Exception e) {
441             logger.error("{} {} Error sending rollbackNetwork notification {} ",
442                     MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, ErrorCode.DataError.getValue(), e.getMessage(), e);
443
444         }
445         return;
446     }
447
448     private org.onap.so.adapters.network.async.client.NetworkRollback copyNrb(Holder<NetworkRollback> hNrb) {
449         org.onap.so.adapters.network.async.client.NetworkRollback cnrb =
450                 new org.onap.so.adapters.network.async.client.NetworkRollback();
451
452         if (hNrb != null && hNrb.value != null) {
453             org.onap.so.adapters.network.async.client.MsoRequest cmr =
454                     new org.onap.so.adapters.network.async.client.MsoRequest();
455
456             cnrb.setCloudId(hNrb.value.getCloudId());
457             cmr.setRequestId(hNrb.value.getMsoRequest().getRequestId());
458             cmr.setServiceInstanceId(hNrb.value.getMsoRequest().getServiceInstanceId());
459             cnrb.setMsoRequest(cmr);
460             cnrb.setNetworkId(hNrb.value.getNetworkId());
461             cnrb.setNetworkStackId(hNrb.value.getNetworkStackId());
462             cnrb.setNeutronNetworkId(hNrb.value.getNeutronNetworkId());
463             cnrb.setTenantId(hNrb.value.getTenantId());
464             cnrb.setNetworkType(hNrb.value.getNetworkType());
465             cnrb.setNetworkCreated(hNrb.value.getNetworkCreated());
466             cnrb.setNetworkName(hNrb.value.getNetworkName());
467             cnrb.setPhysicalNetwork(hNrb.value.getPhysicalNetwork());
468             List<Integer> vlansc = cnrb.getVlans();
469             List<Integer> vlansh = hNrb.value.getVlans();
470             if (vlansh != null) {
471                 vlansc.addAll(vlansh);
472             }
473         }
474         return cnrb;
475     }
476
477     private NetworkAdapterNotify getNotifyEP(String notificationUrl) {
478
479         URL warWsdlLoc = null;
480         try {
481             warWsdlLoc = Thread.currentThread().getContextClassLoader().getResource("NetworkAdapterNotify.wsdl");
482         } catch (Exception e) {
483             logger.error("{} {} Exception - WSDL not found ", MessageEnum.RA_WSDL_NOT_FOUND,
484                     ErrorCode.DataError.getValue(), e);
485         }
486         if (warWsdlLoc == null) {
487             logger.error("{} {} WSDL not found", MessageEnum.RA_WSDL_NOT_FOUND, ErrorCode.DataError.getValue());
488         } else {
489             try {
490                 logger.debug("NetworkAdpaterNotify.wsdl location: {}", warWsdlLoc.toURI().toString());
491             } catch (Exception e) {
492                 logger.error("{} {} Exception - WSDL URL convention ", MessageEnum.RA_WSDL_URL_CONVENTION_EXC,
493                         ErrorCode.SchemaError.getValue(), e);
494             }
495         }
496
497         NetworkAdapterNotify_Service notifySvc = new NetworkAdapterNotify_Service(warWsdlLoc,
498                 new QName("http://org.onap.so/networkNotify", "networkAdapterNotify"));
499
500         NetworkAdapterNotify notifyPort = notifySvc.getMsoNetworkAdapterAsyncImplPort();
501
502         BindingProvider bp = (BindingProvider) notifyPort;
503
504         URL epUrl = null;
505         try {
506             epUrl = new URL(notificationUrl);
507         } catch (MalformedURLException e1) {
508             logger.error("{} {} Exception - init notification ", MessageEnum.RA_INIT_NOTIF_EXC,
509                     ErrorCode.DataError.getValue(), e1);
510         }
511
512         if (null != epUrl) {
513             logger.debug("Notification Endpoint URL: {}", epUrl.toExternalForm());
514             bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm());
515         } else {
516             logger.debug("Notification Endpoint URL is NULL: ");
517         }
518
519         // authentication
520         try {
521             Map<String, Object> reqCtx = bp.getRequestContext();
522             Map<String, List<String>> headers = new HashMap<>();
523
524             String userCredentials = this.getEncryptedProperty(BPEL_AUTH_PROP, "", ENCRYPTION_KEY_PROP);
525
526             String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes());
527             reqCtx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
528             headers.put("Authorization", Collections.singletonList(basicAuth));
529         } catch (Exception e) {
530             logger.error("{} {} Unable to set authorization in callback request {} ",
531                     MessageEnum.RA_SET_CALLBACK_AUTH_EXC, ErrorCode.DataError.getValue(), e.getMessage(), e);
532         }
533
534         return notifyPort;
535     }
536
537     public String getEncryptedProperty(String key, String defaultValue, String encryptionKey) {
538         try {
539             return CryptoUtils.decrypt(this.environment.getProperty(key), this.environment.getProperty(encryptionKey));
540         } catch (GeneralSecurityException e) {
541             logger.debug("Exception while decrypting property: {} ", this.environment.getProperty(key), e);
542         }
543         return defaultValue;
544
545     }
546
547     private CreateNetworkNotification.SubnetIdMap copyCreateSubnetIdMap(Holder<Map<String, String>> hMap) {
548
549         CreateNetworkNotification.SubnetIdMap subnetIdMap = new CreateNetworkNotification.SubnetIdMap();
550
551         if (hMap != null && hMap.value != null) {
552             Map<String, String> sMap = hMap.value;
553             CreateNetworkNotification.SubnetIdMap.Entry entry = new CreateNetworkNotification.SubnetIdMap.Entry();
554
555             for (Map.Entry<String, String> mapEntry : sMap.entrySet()) {
556                 String key = mapEntry.getKey();
557                 String value = mapEntry.getValue();
558                 entry.setKey(key);
559                 entry.setValue(value);
560                 subnetIdMap.getEntry().add(entry);
561             }
562         }
563         return subnetIdMap;
564     }
565
566     private UpdateNetworkNotification.SubnetIdMap copyUpdateSubnetIdMap(Holder<Map<String, String>> hMap) {
567
568         UpdateNetworkNotification.SubnetIdMap subnetIdMap = new UpdateNetworkNotification.SubnetIdMap();
569
570         if (hMap != null && hMap.value != null) {
571             Map<String, String> sMap = hMap.value;
572             UpdateNetworkNotification.SubnetIdMap.Entry entry = new UpdateNetworkNotification.SubnetIdMap.Entry();
573
574             for (Map.Entry<String, String> mapEntry : sMap.entrySet()) {
575                 String key = mapEntry.getKey();
576                 String value = mapEntry.getValue();
577                 entry.setKey(key);
578                 entry.setValue(value);
579                 subnetIdMap.getEntry().add(entry);
580             }
581         }
582         return subnetIdMap;
583     }
584
585     private QueryNetworkNotification.SubnetIdMap copyQuerySubnetIdMap(Holder<Map<String, String>> hMap) {
586
587         QueryNetworkNotification.SubnetIdMap subnetIdMap = new QueryNetworkNotification.SubnetIdMap();
588
589         if (hMap != null && hMap.value != null) {
590             Map<String, String> sMap = hMap.value;
591             QueryNetworkNotification.SubnetIdMap.Entry entry = new QueryNetworkNotification.SubnetIdMap.Entry();
592
593             for (Map.Entry<String, String> mapEntry : sMap.entrySet()) {
594                 String key = mapEntry.getKey();
595                 String value = mapEntry.getValue();
596                 entry.setKey(key);
597                 entry.setValue(value);
598                 subnetIdMap.getEntry().add(entry);
599             }
600         }
601         return subnetIdMap;
602     }
603 }