Code Change for cassandra PW Encryption 98/116398/4
authorSri Balaji Marripud <sri.balaji.marripud@att.com>
Tue, 15 Dec 2020 13:48:28 +0000 (08:48 -0500)
committerSri Balaji Marripud <sri.balaji.marripud@att.com>
Tue, 22 Dec 2020 20:13:27 +0000 (15:13 -0500)
Issue-ID: PORTAL-1045
Change-Id: If02599088f3d2509dddc53d60dd9ca76e945542d
Signed-off-by: Sri Balaji Marripud <sri.balaji.marripud@att.com>
ecomp-portal-BE-common/pom.xml
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/service/MusicService.java
portal-FE-os/pom.xml
portal-FE-os/src/app/pages/pages-routing.module.ts
portal-FE-os/src/app/pages/pages.module.ts

index 6789b67..68b4bb1 100644 (file)
                        <artifactId>gson</artifactId>
                        <version>2.5</version>
                </dependency>
+               <dependency>
+                       <groupId>com.google.guava</groupId>
+                       <artifactId>guava</artifactId>
+                       <version>19.0</version>
+               </dependency>
+
                <!-- Spring -->
                <dependency>
                        <groupId>org.springframework</groupId>
index 323a71f..119ad2d 100644 (file)
@@ -38,6 +38,7 @@
 
 package org.onap.portalapp.music.service;
 
+import java.io.InputStream;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -45,12 +46,14 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
 import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.eelf.logging.EELFLoggerDelegate;
 import org.onap.music.exceptions.MusicLockingException;
 import org.onap.music.exceptions.MusicQueryException;
 import org.onap.music.exceptions.MusicServiceException;
+import org.onap.music.main.CipherUtil;
 import org.onap.music.main.MusicCore;
 import org.onap.music.main.ResultType;
 import org.onap.music.main.ReturnType;
@@ -66,6 +69,7 @@ import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.session.Session;
 import org.springframework.web.client.RestTemplate;
+import org.onap.music.datastore.MusicDataStore;
 
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Row;
@@ -75,6 +79,46 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 public class MusicService {
        static RestTemplate template = new RestTemplate();
        private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicService.class);
+       
+       static {        
+       try {
+                       //MusicCore.getDSHandle();
+                       init();
+                       // Since mDstoreHandle is already initialized in init mthod, calling this method again will have no impact on mDstoreHandle.
+                       MusicCore.getDSHandle();
+               } catch (MusicServiceException e) {
+                       logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), e);
+               }
+    }
+    
+    public static void init() {
+       try {
+               Properties prop = new Properties();
+               // We load encryption key from key.properties on the classpath. This key is used for decrypting cassandra password
+            try(InputStream input = MusicUtil.class.getClassLoader().getResourceAsStream("key.properties")) {
+                prop.load(input);
+            } catch (Exception var11) {
+                logger.error(EELFLoggerDelegate.errorLogger, "Unable to find properties file.");
+                //throw new Exception();
+            }
+               try {
+                       // Load music.properties from classpath
+                org.onap.music.main.MusicUtil.loadProperties();
+                // decrypt encrypted password using the key we loaded before.
+                String decryptedPassword = CipherUtil.decryptPKC(org.onap.music.main.MusicUtil.getCassPwd(), prop.getProperty("cipher.enc.key"));
+                // set decrypted password 
+                org.onap.music.main.MusicUtil.setCassPwd(decryptedPassword);
+                // Here we are creating cassandra connections pool and sessions by calling MusicDataStore and passing the cassandrra hostname to that. 
+                MusicCore.mDstoreHandle = new MusicDataStore(org.onap.music.main.MusicUtil.getMyCassaHost());
+            } catch (Exception e) {
+               logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), e);
+            }
+               
+               } catch(Exception e) {
+                       logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), e);
+               }
+    }
+
 
        private static boolean isAtomicPut = MusicUtil.isAtomicPut();
        private static boolean isAtomicGet = MusicUtil.isAtomicGet();
index 7f6a02f..a306c15 100644 (file)
@@ -64,7 +64,7 @@
                                                                        <version>${epsdk.version}</version>
                                                                        <type>war</type>
                                                                        <overWrite>false</overWrite>
-                                                                       <includes>ngapp/src/app/pages/analytics/**</includes>
+                                                                       <includes>ngapp/src/app/pages/analytics/**, ngapp/src/app/report-run/**, ngapp/src/app/modals/error-modal/**, ngapp/src/app/shared/services/cache.service.ts</includes>
                                                                        <outputDirectory>${basedir}/</outputDirectory>
                                                                </artifactItem>
                                                        </artifactItems>
                                                </configuration>
                                        </execution>
 
+                                       <execution>
+                                               <id>copy-report-run</id>
+                                               <phase>generate-sources</phase>
+                                               <goals>
+                                                       <goal>copy-resources</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <outputDirectory>${basedir}/src/app/pages/</outputDirectory>
+                                                       
+                                                       <resources>
+                                                               <resource>
+                                                                       <directory>${basedir}/ngapp/src/app/report-run</directory>
+                                                               </resource>
+                                                       </resources>
+                                               </configuration>
+                                       </execution>
+
+                                       <execution>
+                                               <id>copy-error-modal</id>
+                                               <phase>generate-sources</phase>
+                                               <goals>
+                                                       <goal>copy-resources</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <outputDirectory>${basedir}/src/app/modals/</outputDirectory>
+                                                       
+                                                       <resources>
+                                                               <resource>
+                                                                       <directory>${basedir}/ngapp/src/app/modals</directory>
+                                                               </resource>
+                                                       </resources>
+                                               </configuration>
+                                       </execution>
+
+                                       <execution>
+                                               <id>copy-cache-service</id>
+                                               <phase>generate-sources</phase>
+                                               <goals>
+                                                       <goal>copy-resources</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <outputDirectory>${basedir}/src/app/shared/services/</outputDirectory>
+                                                       
+                                                       <resources>
+                                                               <resource>
+                                                                       <directory>${basedir}/ngapp/src/app/shared/services</directory>
+                                                               </resource>
+                                                       </resources>
+                                               </configuration>
+                                       </execution>
+
                                </executions>
                        </plugin>
 
index ea1d8b5..5e59cf3 100644 (file)
@@ -57,7 +57,7 @@ import { RoleFunctionsComponent } from './role/role-functions/role-functions.com
 import { NotificationHistoryComponent } from './notification-history/notification-history.component';
 import { GetAccessComponent } from './get-access/get-access.component';
 import { HeaderTabsWrapperComponent } from './analytics/Report_List/header-tabs-wrapper-component/header-tabs-wrapper.component';
-import { RunReportFormFieldsComponent } from './analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component';
+import { RunReportFormFieldsComponent } from './run/run-report-form-fields/run-report-form-fields.component';
 import { DisplayAreaComponent } from './analytics/Report_List/display-area/display-area.component';
 import { ReportComponent } from './analytics/Report_List/Report/report.component';
 
index a921257..9d1a759 100644 (file)
@@ -100,7 +100,7 @@ import { InformationTooltipComponent } from './information-tooltip/information-t
 import { UserDetailsFormComponent } from './users/user-details-form/user-details-form.component';
 import { MatTooltipModule } from '@angular/material';
 import { HeaderTabsWrapperComponent } from './analytics/Report_List/header-tabs-wrapper-component/header-tabs-wrapper.component';
-import { RunReportFormFieldsComponent } from './analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component';
+import { RunReportFormFieldsComponent } from './run/run-report-form-fields/run-report-form-fields.component';
 import { DisplayAreaComponent } from './analytics/Report_List/display-area/display-area.component';
 import { HeaderTabsComponent } from './analytics/Report_List/header-tabs-component/header-tabs.component';
 import { MatTableModule, MatPaginatorModule, MatSortModule, MatTabsModule, MatButtonToggleModule, MatExpansionModule, MatFormFieldModule, MatGridListModule, MatCardModule, MatMenuModule, MatButtonModule } from '@angular/material';
@@ -111,7 +111,7 @@ import { FormFieldsComponent } from './analytics/Report_List/Report/form-fields/
 import { ChartWizardComponent } from './analytics/Report_List/Report/chart-wizard/chart-wizard.component';
 import { SecurityComponent } from './analytics/Report_List/Report/security/security.component';
 import { LogComponent } from './analytics/Report_List/Report/log/log.component';
-import { RunComponent } from './analytics/Report_List/Report/run/run.component';
+import { RunComponent } from './run/run.component';
 import { DefinitionSaveDialogComponent } from './analytics/Report_List/Report/definition/definition-save-dialog/definition-save-dialog.component';
 import { SQLSaveChangesDialogComponent } from './analytics/Report_List/Report/sql/sql-save-changes-dialog/sql-save-changes-dialog.component';
 import { SQLValidateChangesDialogComponent } from './analytics/Report_List/Report/sql/sql-validate-changes-dialog/sql-validate-changes-dialog.component';
@@ -120,14 +120,14 @@ import { SQLValidateErrorDialogComponent } from './analytics/Report_List/Report/
 import { ReportComponent } from './analytics/Report_List/Report/report.component';
 import { DashboardReportGridComponent } from './analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component';
 import { DataChartComponent } from './analytics/Report_List/Report/definition/dashboard-report-grid/data-chart/data-chart.component';
-import { RunDashboardReportComponent } from './analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component';
+import { RunDashboardReportComponent } from './run/run-report/run-dashboard-report/run-dashboard-report.component';
 import { EditDrillDownLinkComponent } from './analytics/Report_List/Report/columns/columns-edit-component/edit-drill-down-link/edit-drill-down-link.component';
 import { FormFieldsAddEditComponent } from './analytics/Report_List/Report/form-fields/form-fields-add-edit/form-fields-add-edit.component';
-import { RunReportResultSetComponent } from './analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component';
+import { RunReportResultSetComponent } from './run/run-report-result-set/run-report-result-set.component';
 import { ColumnListComponent } from './analytics/Report_List/Report/columns/column-list/column-list.component';
 import { ColumnsEditComponent } from './analytics/Report_List/Report/columns/columns-edit-component/columns-edit.component';
 import { ReportListComponent } from './analytics/Report_List/report-list.component';
-import { RunReportComponent } from './analytics/Report_List/Report/run/run-report/run-report.component';
+import { RunReportComponent } from './run/run-report/run-report.component';
 
 
 @NgModule({