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