From 0f6846175bb91b3e5c1fad2e62564534beb1a0e1 Mon Sep 17 00:00:00 2001 From: Sri Balaji Marripud Date: Tue, 15 Dec 2020 08:48:28 -0500 Subject: [PATCH] Code Change for cassandra PW Encryption Issue-ID: PORTAL-1045 Change-Id: If02599088f3d2509dddc53d60dd9ca76e945542d Signed-off-by: Sri Balaji Marripud --- ecomp-portal-BE-common/pom.xml | 6 +++ .../onap/portalapp/music/service/MusicService.java | 44 ++++++++++++++++++ portal-FE-os/pom.xml | 53 +++++++++++++++++++++- portal-FE-os/src/app/pages/pages-routing.module.ts | 2 +- portal-FE-os/src/app/pages/pages.module.ts | 10 ++-- 5 files changed, 108 insertions(+), 7 deletions(-) diff --git a/ecomp-portal-BE-common/pom.xml b/ecomp-portal-BE-common/pom.xml index 6789b67c..68b4bb18 100644 --- a/ecomp-portal-BE-common/pom.xml +++ b/ecomp-portal-BE-common/pom.xml @@ -145,6 +145,12 @@ gson 2.5 + + com.google.guava + guava + 19.0 + + org.springframework diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/service/MusicService.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/service/MusicService.java index 323a71fe..119ad2db 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/service/MusicService.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/service/MusicService.java @@ -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(); diff --git a/portal-FE-os/pom.xml b/portal-FE-os/pom.xml index 7f6a02ff..a306c15e 100644 --- a/portal-FE-os/pom.xml +++ b/portal-FE-os/pom.xml @@ -64,7 +64,7 @@ ${epsdk.version} war false - ngapp/src/app/pages/analytics/** + ngapp/src/app/pages/analytics/**, ngapp/src/app/report-run/**, ngapp/src/app/modals/error-modal/**, ngapp/src/app/shared/services/cache.service.ts ${basedir}/ @@ -99,6 +99,57 @@ + + copy-report-run + generate-sources + + copy-resources + + + ${basedir}/src/app/pages/ + + + + ${basedir}/ngapp/src/app/report-run + + + + + + + copy-error-modal + generate-sources + + copy-resources + + + ${basedir}/src/app/modals/ + + + + ${basedir}/ngapp/src/app/modals + + + + + + + copy-cache-service + generate-sources + + copy-resources + + + ${basedir}/src/app/shared/services/ + + + + ${basedir}/ngapp/src/app/shared/services + + + + + diff --git a/portal-FE-os/src/app/pages/pages-routing.module.ts b/portal-FE-os/src/app/pages/pages-routing.module.ts index ea1d8b5b..5e59cf30 100644 --- a/portal-FE-os/src/app/pages/pages-routing.module.ts +++ b/portal-FE-os/src/app/pages/pages-routing.module.ts @@ -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'; diff --git a/portal-FE-os/src/app/pages/pages.module.ts b/portal-FE-os/src/app/pages/pages.module.ts index a921257f..9d1a7597 100644 --- a/portal-FE-os/src/app/pages/pages.module.ts +++ b/portal-FE-os/src/app/pages/pages.module.ts @@ -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({ -- 2.16.6