Sdc Listener Platform hardening changes 83/77783/2
authorBalaji, Ramya (rb111y) <rb111y@att.com>
Mon, 4 Feb 2019 12:57:11 +0000 (07:57 -0500)
committerPatrick Brady <patrick.brady@att.com>
Tue, 5 Feb 2019 17:26:12 +0000 (17:26 +0000)
Issue-ID: APPC-1382
Change-Id: Ib4928843a8f169d856aaa1afa49fcfa127ba4990
Signed-off-by: Balaji, Ramya (rb111y) <rb111y@att.com>
appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/ProviderOperations.java
appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcListener.java
appc-sdc-listener/appc-yang-generator/dependency-reduced-pom.xml

index f8fd146..4200601 100644 (file)
@@ -2,22 +2,22 @@
  * ============LICENSE_START=======================================================
  * ONAP : APPC
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Copyright (C) 2017 Amdocs
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- * 
+ *
  * ============LICENSE_END=========================================================
  */
 
@@ -69,6 +69,7 @@ public class ProviderOperations {
     private static final EELFLogger LOG = EELFManager.getInstance().getLogger(ProviderOperations.class);
 
     private static String basic_auth;
+    private static URL defaultUrl;
 
     public static ProviderResponse post(URL url, String json, Map<String, String> adtl_headers) throws APPCException {
         if (json == null) {
@@ -133,6 +134,18 @@ public class ProviderOperations {
         return basic_auth;
     }
 
+    /**
+     * Sets the default Provider URL to the provided URL. If the entry is null then sets to null.
+     *
+     * @param URL The URL
+     */
+    public static void setDefaultUrl(URL URL) {
+        if (URL != null) {
+            defaultUrl = URL;
+        } else {
+            defaultUrl = null;
+        }
+    }
     @SuppressWarnings("deprecation")
     private static HttpClient getHttpClient(URL url) throws APPCException {
         HttpClient client;
index d786247..c67535e 100644 (file)
@@ -2,16 +2,16 @@
  * ============LICENSE_START=======================================================
  * ONAP : APPC
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Copyright (C) 2017 Amdocs
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -55,6 +55,8 @@ public class SdcListener {
     private CountDownLatch latch;
 
     private Thread startThread = null;
+    private String ukey;
+    private String uval;
 
     @SuppressWarnings("unused")
     public void start() throws Exception {
@@ -65,7 +67,10 @@ public class SdcListener {
         Configuration configuration = ConfigurationFactory.getConfiguration();
         Properties props = configuration.getProperties();
         config = new SdcConfig(props);
-        logger.debug(String.format("[%d] created SDC config", timeStamp));
+        ukey = props.getProperty("appc.sdc.provider.user");
+        uval = props.getProperty("appc.sdc.provider.pass");
+        logger.debug(String.format("[%d] created SDC config provider URL [%s]", timeStamp, config.getStoreOpURI().toString()));
+
 
         client = DistributionClientFactory.createDistributionClient();
         logger.debug(String.format("[%d] created SDC client", timeStamp));
@@ -196,6 +201,8 @@ public class SdcListener {
                         config.getUser(), url, saltedPass[1]));
 
                 ProviderOperations providerOperations = new ProviderOperations();
+                ProviderOperations.setDefaultUrl(config.getStoreOpURI().toURL());
+                ProviderOperations.setAuthentication(ukey, uval);
                 ProviderResponse result = providerOperations.post(url, json, headers);
                 return result.getStatus() == 200;
             } catch (Exception e) {
index 2c61cdb..fd09e08 100644 (file)
@@ -3,7 +3,7 @@
   <parent>\r
     <artifactId>binding-parent</artifactId>\r
     <groupId>org.onap.appc.parent</groupId>\r
-    <version>1.5.1-SNAPSHOT</version>\r
+    <version>1.5.0-SNAPSHOT</version>\r
     <relativePath>pom.xml</relativePath>\r
   </parent>\r
   <modelVersion>4.0.0</modelVersion>\r