summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSri Balaji Marripud <sri.balaji.marripud@att.com>2020-12-15 08:48:28 -0500
committerSri Balaji Marripud <sri.balaji.marripud@att.com>2020-12-22 15:13:27 -0500
commit0f6846175bb91b3e5c1fad2e62564534beb1a0e1 (patch)
tree17554081ffc4c8ad7208c5d8f2965cf2a8e46d44
parenta49678cb3d2c7ef2b3e5fecc7f52b85df46e8268 (diff)
Code Change for cassandra PW Encryption
Issue-ID: PORTAL-1045 Change-Id: If02599088f3d2509dddc53d60dd9ca76e945542d Signed-off-by: Sri Balaji Marripud <sri.balaji.marripud@att.com>
-rw-r--r--ecomp-portal-BE-common/pom.xml6
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/service/MusicService.java44
-rw-r--r--portal-FE-os/pom.xml53
-rw-r--r--portal-FE-os/src/app/pages/pages-routing.module.ts2
-rw-r--r--portal-FE-os/src/app/pages/pages.module.ts10
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 @@
<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>
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 @@
<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>
@@ -99,6 +99,57 @@
</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>
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({