aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Brady <patrick.brady@att.com>2020-03-24 15:44:15 -0700
committerPatrick Brady <patrick.brady@att.com>2020-03-24 16:47:23 -0700
commit0141df20b1f533cd2acabdf7ea986aebab8d6868 (patch)
tree7df75e7fd455aeb0ccedeac6be801d4cab4d508d
parent179fea047479a44ef2fb0490c272f7f97127bbe9 (diff)
Authentication support for cdt
-Adding a password box to cdt -Adding a function to check login by making a request to appc -Moving username and authentication to session storage from localstorage so that it is not saved in the browser -Removing the hardcoded credentials from the cdt proxy since these are coming from the cdt login form now Change-Id: I8bd829a22d1b83829c1d53637dc1ad035d1030e9 Signed-off-by: Patrick Brady <patrick.brady@att.com> Issue-ID: APPC-1854
-rw-r--r--CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java36
-rw-r--r--CdtProxyService/src/main/resources/application.properties2
-rw-r--r--src/app/admin/admin.component.ts14
-rw-r--r--src/app/admin/view-edit/ansible-server.component.ts4
-rw-r--r--src/app/shared/components/navigation/navigation.component.spec.ts6
-rw-r--r--src/app/shared/components/navigation/navigation.component.ts12
-rw-r--r--src/app/shared/services/httpUtil/http-util.service.ts25
-rw-r--r--src/app/shared/services/utilityService/utility.service.ts12
-rw-r--r--src/app/test/test.component.ts10
-rw-r--r--src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts4
-rw-r--r--src/app/vnfs/LoginGuardService/Login-guard-service.ts6
-rw-r--r--src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts4
-rw-r--r--src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts8
-rw-r--r--src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts6
-rw-r--r--src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts4
-rw-r--r--src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts8
-rw-r--r--src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts6
-rw-r--r--src/app/vnfs/myvnfs/myvnfs.component.ts10
-rw-r--r--src/app/vnfs/userlogin-form/userlogin-form.component.html8
-rw-r--r--src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts6
-rw-r--r--src/app/vnfs/userlogin-form/userlogin-form.component.ts89
21 files changed, 187 insertions, 93 deletions
diff --git a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java
index 78a94f6..bdb12e5 100644
--- a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java
+++ b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -41,6 +41,7 @@ import org.springframework.web.client.RestTemplate;
import java.net.UnknownHostException;
import java.util.Base64;
+import java.util.List;
/**
* Created by Amaresh Kumar on 09/May/2018.
@@ -62,11 +63,6 @@ public class CdtController {
@Value("${restConf.backend.port}")
private String restConfPort;
- @Value("${restConf.username}")
- private String restConfUsername;
-
- @Value("${restConf.password}")
- private String restConfPassword;
@ApiOperation(value = "Return All Test Data for a given user", response = CdtController.class)
@ApiResponses(value = {
@@ -87,8 +83,8 @@ public class CdtController {
})
@RequestMapping(value = "/getDesigns", method = RequestMethod.POST)
@CrossOrigin(origins = "*", allowedHeaders = "*")
- public String getDesigns(@RequestBody String getDesignsRequest) throws UnknownHostException {
- HttpEntity<String> entity = getStringHttpEntity(getDesignsRequest);
+ public String getDesigns(@RequestBody String getDesignsRequest, @RequestHeader HttpHeaders requestHeader) throws UnknownHostException {
+ HttpEntity<String> entity = getStringHttpEntity(getDesignsRequest, requestHeader);
HttpClient httpClient = HttpClientBuilder.create().build();
ClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
restTemplate.setRequestFactory(factory);
@@ -103,8 +99,8 @@ public class CdtController {
})
@RequestMapping(value = "/testVnf", method = RequestMethod.POST)
@CrossOrigin(origins = "*", allowedHeaders = "*")
- public String testVnf(@RequestParam String urlAction, @RequestBody String testVnf) throws UnknownHostException {
- HttpEntity<String> entity = getStringHttpEntity(testVnf);
+ public String testVnf(@RequestParam String urlAction, @RequestBody String testVnf, @RequestHeader HttpHeaders requestHeader) throws UnknownHostException {
+ HttpEntity<String> entity = getStringHttpEntity(testVnf, requestHeader);
String testVnfResponse = restTemplate.postForObject(getUrl("testVnf")+urlAction, entity, String.class);
return testVnfResponse;
}
@@ -116,8 +112,8 @@ public class CdtController {
})
@RequestMapping(value = "/checkTestStatus", method = RequestMethod.POST)
@CrossOrigin(origins = "*", allowedHeaders = "*")
- public String checkTestStatus(@RequestBody String checkTestStatusRequest) throws UnknownHostException {
- HttpEntity<String> entity = getStringHttpEntity(checkTestStatusRequest);
+ public String checkTestStatus(@RequestBody String checkTestStatusRequest, @RequestHeader HttpHeaders requestHeader) throws UnknownHostException {
+ HttpEntity<String> entity = getStringHttpEntity(checkTestStatusRequest, requestHeader);
String checkTestStatusResponse = restTemplate.postForObject(getUrl("checkTestStatus"), entity, String.class);
return checkTestStatusResponse;
}
@@ -129,19 +125,23 @@ public class CdtController {
})
@RequestMapping(value = "/validateTemplate", method = RequestMethod.POST)
@CrossOrigin(origins = "*", allowedHeaders = "*")
- public String validateTemplate(@RequestBody String validateTemplateRequest) throws UnknownHostException {
- HttpEntity<String> entity = getStringHttpEntity(validateTemplateRequest);
+ public String validateTemplate(@RequestBody String validateTemplateRequest, @RequestHeader HttpHeaders requestHeader) throws UnknownHostException {
+ HttpEntity<String> entity = getStringHttpEntity(validateTemplateRequest, requestHeader);
String validateTemplateResponse = restTemplate.postForObject(getUrl("validateTemplate"), entity, String.class);
return validateTemplateResponse;
}
- private HttpEntity<String> getStringHttpEntity(@RequestBody String getDesignsRequest) {
+ private HttpEntity<String> getStringHttpEntity(@RequestBody String getDesignsRequest, @RequestHeader HttpHeaders requestHeader) {
+
HttpHeaders headers = new HttpHeaders();
+ if(requestHeader.containsKey("authorization")) {
+ List<String> headerAuthValue = requestHeader.get("authorization");
+ if(headerAuthValue != null && headerAuthValue.size() > 0) {
+ headers.set("authorization", headerAuthValue.get(0));
+ }
+ }
headers.setAccessControlAllowCredentials(true);
headers.setContentType(MediaType.APPLICATION_JSON);
- String planCredentials = restConfUsername + ":" + restConfPassword;
- String base64Credentails = Base64.getEncoder().encodeToString(planCredentials.getBytes());
- headers.set("Authorization", "Basic " + base64Credentails);
return new HttpEntity<String>(getDesignsRequest, headers);
}
diff --git a/CdtProxyService/src/main/resources/application.properties b/CdtProxyService/src/main/resources/application.properties
index d33188a..3b21458 100644
--- a/CdtProxyService/src/main/resources/application.properties
+++ b/CdtProxyService/src/main/resources/application.properties
@@ -13,8 +13,6 @@ Djavax.net.debug=ssl;
#=========RestConf Backend properties START==================
restConf.backend.hostname=localhost
restConf.backend.port=8181
-restConf.username=admin
-restConf.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
#=========RestConf Backend properties END==================
#====Allowed origins======================
diff --git a/src/app/admin/admin.component.ts b/src/app/admin/admin.component.ts
index 74fe86a..4bde5b5 100644
--- a/src/app/admin/admin.component.ts
+++ b/src/app/admin/admin.component.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -70,8 +70,8 @@ export class AdminComponent implements OnInit {
}
ngOnInit() {
- const apiToken = localStorage['apiToken'];
- this.currentUser = localStorage['userId'];
+ const apiToken = sessionStorage['apiToken'];
+ this.currentUser = sessionStorage['userId'];
if(this.paramShareService.ansibleServerData) {
this.ansibleServerData = this.paramShareService.ansibleServerData;
@@ -92,14 +92,14 @@ export class AdminComponent implements OnInit {
const input = {
"input":{
"design-request":{
- "request-id":localStorage['apiToken'],
+ "request-id":sessionStorage['apiToken'],
"action":"getArtifact",
"payload":"{\"vnf-type\":\"NULL\",\"vnfc-type\":\"NULL\",\"protocol\":\"\",\"incart\":\"N\",\"action\":\"NULL\",\"artifact-name\":\""+this.fileName+"\",\"artifact-type\":\"APPC-CONFIG\",\"userID\":\"admin\"}"
}
}
};
//const x = JSON.parse(data.input['design-request']['payload']);
- //x.userID = localStorage['userId'];
+ //x.userID = sessionStorage['userId'];
//data.input['design-request']['payload'] = JSON.stringify(x);
console.log("input to payload====", JSON.stringify(input));
@@ -215,7 +215,7 @@ export class AdminComponent implements OnInit {
let input = {
"input": {
"design-request": {
- "request-id": localStorage['apiToken'],
+ "request-id": sessionStorage['apiToken'],
"action": "uploadAdminArtifact",
"payload": "{\"userID\": \"admin\",\"vnf-type\" : \"NULL \",\"action\" : \"NULL\",\"artifact-name\" : \""+this.fileName+"\",\"artifact-type\" : \"APPC-CONFIG\",\"artifact-version\" : \"0.1\",\"artifact-contents\":\""+artifactContent+"\"}",
}
@@ -244,4 +244,4 @@ export class AdminComponent implements OnInit {
}
}
-} \ No newline at end of file
+}
diff --git a/src/app/admin/view-edit/ansible-server.component.ts b/src/app/admin/view-edit/ansible-server.component.ts
index b629b65..6691092 100644
--- a/src/app/admin/view-edit/ansible-server.component.ts
+++ b/src/app/admin/view-edit/ansible-server.component.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -78,7 +78,7 @@ export class AnsibleServerComponent implements OnInit {
}
ngOnInit() {
- this.currentUser = localStorage['userId'];
+ this.currentUser = sessionStorage['userId'];
this.item = JSON.parse(sessionStorage.getItem("ansibleserver"));
this.updateIndex = parseInt(sessionStorage.getItem("updateIndex"));
console.log("index===>"+this.updateIndex);
diff --git a/src/app/shared/components/navigation/navigation.component.spec.ts b/src/app/shared/components/navigation/navigation.component.spec.ts
index 2d4aafe..ead4b78 100644
--- a/src/app/shared/components/navigation/navigation.component.spec.ts
+++ b/src/app/shared/components/navigation/navigation.component.spec.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -91,7 +91,7 @@ describe('NavigationComponent', () => {
it('should go to /vnfs/list if url = vnfs and userId is not null or undefined', inject([Router],(router: Router) => {
let navigateSpy = spyOn(router, 'navigate');
- localStorage['userId'] = 'testingId';
+ sessionStorage['userId'] = 'testingId';
let testUrl = 'vnfs';
component.gotoDetail(testUrl);
@@ -99,7 +99,7 @@ describe('NavigationComponent', () => {
it('should go to /vnfs if url = vnfs and userId is null or undefined', inject([Router],(router: Router) => {
let navigateSpy = spyOn(router, 'navigate');
- localStorage['userId'] = '';
+ sessionStorage['userId'] = '';
let testUrl = 'vnfs';
component.gotoDetail(testUrl);
diff --git a/src/app/shared/components/navigation/navigation.component.ts b/src/app/shared/components/navigation/navigation.component.ts
index 7271bb1..424a002 100644
--- a/src/app/shared/components/navigation/navigation.component.ts
+++ b/src/app/shared/components/navigation/navigation.component.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
Copyright (C) 2018 IBM Intellectual Property. All rights reserved.
===================================================================
@@ -36,7 +36,7 @@ export class NavigationComponent implements OnInit {
//@ViewChild(GoldenConfigurationComponent) goldenConfig: GoldenConfigurationComponent;
@Input() id: string;
userLoggedIn = false;
- userId: string = localStorage['userId'];
+ userId: string = sessionStorage['userId'];
subscription: Subscription;
constructor(private router: Router) {
@@ -49,7 +49,7 @@ export class NavigationComponent implements OnInit {
if (value != null && value != '' && value != undefined && value != 'undefined') {
this.userId = value;
this.userLoggedIn = true;
- localStorage['userId'] = this.userId;
+ sessionStorage['userId'] = this.userId;
} else {
this.logout();
}
@@ -58,7 +58,7 @@ export class NavigationComponent implements OnInit {
}
ngOnInit() {
- this.userId = localStorage['userId'];
+ this.userId = sessionStorage['userId'];
if (this.userId != undefined && this.userId != '') {
this.userLoggedIn = true;
}
@@ -99,7 +99,7 @@ export class NavigationComponent implements OnInit {
gotoDetail(url) {
if (url == 'vnfs') {
- if (localStorage['userId'] != undefined && localStorage['userId'] != '' && localStorage['userId'] != null) {
+ if (sessionStorage['userId'] != undefined && sessionStorage['userId'] != '' && sessionStorage['userId'] != null) {
this.router.navigate(['/vnfs/list']);
} else {
this.router.navigate(url);
@@ -122,4 +122,4 @@ export class NavigationComponent implements OnInit {
}
-} \ No newline at end of file
+}
diff --git a/src/app/shared/services/httpUtil/http-util.service.ts b/src/app/shared/services/httpUtil/http-util.service.ts
index fc9c327..40c1518 100644
--- a/src/app/shared/services/httpUtil/http-util.service.ts
+++ b/src/app/shared/services/httpUtil/http-util.service.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -54,5 +54,28 @@ export class HttpUtilService {
.post(req.url, req.data, this.options)
.map((res: Response) => res.json())
}
+
+ postWithAuth(req) {
+ var authString = sessionStorage['auth'];
+ if(authString === undefined || authString === null || authString.length === 0){
+ this.options = new RequestOptions({
+ headers: new Headers({
+ 'Content-Type': 'application/json'
+ })
+ });
+ } else {
+ this.options = new RequestOptions({
+ headers: new Headers({
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Basic ' + authString
+ })
+ });
+ }
+
+ return this
+ .http
+ .post(req.url, req.data, this.options)
+ .map((res: Response) => res.json())
+ }
}
diff --git a/src/app/shared/services/utilityService/utility.service.ts b/src/app/shared/services/utilityService/utility.service.ts
index 6b29a2e..54ea76b 100644
--- a/src/app/shared/services/utilityService/utility.service.ts
+++ b/src/app/shared/services/utilityService/utility.service.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Copyright (C) 2018 IBM.
===================================================================
@@ -131,8 +131,8 @@ export class UtilityService {
public createPayLoadForSave(artifactType,vnfType,action,fileName, versionNo, artifactContent)
{
- let userId=localStorage['userId'];
- let apiToken=localStorage['apiToken']
+ let userId=sessionStorage['userId'];
+ let apiToken=sessionStorage['apiToken']
let newPayload:any;
switch(artifactType)
{
@@ -187,14 +187,14 @@ export class UtilityService {
let payload:any;
if(isReference) {
payload=JSON.parse(sessionStorage.getItem('updateParams'));
- payload['userID'] = localStorage['userId'];
+ payload['userID'] = sessionStorage['userId'];
payload = JSON.stringify(payload);
}
- else payload = '{"userID": "' + localStorage['userId'] + '","action": "' + action + '", "vnf-type" : "' + vnfType + '", "artifact-type":"APPC-CONFIG", "artifact-name":"' + fileName + '"}';
+ else payload = '{"userID": "' + sessionStorage['userId'] + '","action": "' + action + '", "vnf-type" : "' + vnfType + '", "artifact-type":"APPC-CONFIG", "artifact-name":"' + fileName + '"}';
let data = {
'input': {
'design-request': {
- 'request-id': localStorage['apiToken'],
+ 'request-id': sessionStorage['apiToken'],
'action': 'getArtifact',
'payload': payload
}
diff --git a/src/app/test/test.component.ts b/src/app/test/test.component.ts
index 347bde6..d1dd0c4 100644
--- a/src/app/test/test.component.ts
+++ b/src/app/test/test.component.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Copyright (C) 2018 IBM.
===================================================================
@@ -102,7 +102,7 @@ export class TestComponent implements OnInit {
public pollCounter = 0;
public enableCounterDiv: boolean = false;
public enableDownload: boolean = false;
- private userId = localStorage['userId'];
+ private userId = sessionStorage['userId'];
timeStampInt: number;
AppcTimeStampInt: number;
AppcTimeDiff: number;
@@ -395,7 +395,7 @@ export class TestComponent implements OnInit {
this.ngProgress.start();
this.apiRequest = JSON.stringify(this.constructRequest());
- this.httpUtil.post(
+ this.httpUtil.postWithAuth(
{
url: environment.testVnf + "?urlAction=" + this.getUrlEndPoint(this.action),
data: this.apiRequest
@@ -440,7 +440,7 @@ export class TestComponent implements OnInit {
}
};
console.log('getAppcTimestamp: sending httpUtil.post...');
- this.httpUtil.post(
+ this.httpUtil.postWithAuth(
{
url: environment.getDesigns, data: data
})
@@ -536,7 +536,7 @@ export class TestComponent implements OnInit {
'payload': '{"request-id":' + this.requestId + '}'
}
};
- this.httpUtil.post(
+ this.httpUtil.postWithAuth(
{
url: environment.checkTestStatus, data: data
diff --git a/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts b/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts
index 440993d..216a4df 100644
--- a/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts
+++ b/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts
@@ -51,7 +51,7 @@ describe('LogginGuard', () => {
});
it('be able to return true when referenceNameObjects is defined', inject([GCAuthGuardService, MappingEditorService], (service: GCAuthGuardService, mapService: MappingEditorService) => {
- localStorage['userId'] = 'abc@xyz.com';
+ sessionStorage['userId'] = 'abc@xyz.com';
mapService.referenceNameObjects = { data : 'data'};
let route : ActivatedRouteSnapshot;
let state: RouterStateSnapshot;
@@ -61,7 +61,7 @@ describe('LogginGuard', () => {
}));
it('stop routing if referenceNameObjects is not defined', inject([GCAuthGuardService, MappingEditorService, NgbModal], (service: GCAuthGuardService, mapService: MappingEditorService, ngbModal: NgbModal) => {
- localStorage['userId'] = 'abc@xyz.com';
+ sessionStorage['userId'] = 'abc@xyz.com';
mapService.referenceNameObjects = undefined;
let spy = spyOn(NgbModal.prototype, 'open').and.returnValue(Promise.resolve(true));
let route : ActivatedRouteSnapshot;
diff --git a/src/app/vnfs/LoginGuardService/Login-guard-service.ts b/src/app/vnfs/LoginGuardService/Login-guard-service.ts
index 1e7e752..1938030 100644
--- a/src/app/vnfs/LoginGuardService/Login-guard-service.ts
+++ b/src/app/vnfs/LoginGuardService/Login-guard-service.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
Copyright (C) 2018 IBM.
===================================================================
@@ -35,7 +35,7 @@ export class LoginGuardService implements CanActivate {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
- let userId = localStorage['userId'];
+ let userId = sessionStorage['userId'];
if (userId != null && userId != undefined && userId != '') {
return true;
} else {
@@ -44,4 +44,4 @@ export class LoginGuardService implements CanActivate {
}
}
-} \ No newline at end of file
+}
diff --git a/src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts b/src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts
index 1c57478..a2e26b8 100644
--- a/src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts
+++ b/src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts
@@ -51,14 +51,14 @@ describe('LogginGuard', () => {
});
it('be able to hit route when user is logged in', inject([LoginGuardService], (service: LoginGuardService) => {
- localStorage['userId'] = 'abc@xyz.com';
+ sessionStorage['userId'] = 'abc@xyz.com';
let route : ActivatedRouteSnapshot;
let state: RouterStateSnapshot;
expect(service.canActivate(route, state)).toBe(true);
}));
it('be able to navigate to login page when user is not logged in', inject([LoginGuardService], (service: LoginGuardService) => {
- localStorage['userId'] = '';
+ sessionStorage['userId'] = '';
let route : ActivatedRouteSnapshot;
let mockSnapshot:any = jasmine.createSpyObj<RouterStateSnapshot>("RouterStateSnapshot", ['toString']);
expect(service.canActivate(route, mockSnapshot)).toBe(false);
diff --git a/src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts b/src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts
index ae4aec4..add5b5e 100644
--- a/src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts
+++ b/src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
Copyright (C) 2018 IBM.
===================================================================
@@ -63,8 +63,8 @@ export class ParameterDefinitionService {
public myKeyFileName = null;
public myPdFileName = null;
private selectedActionReference: any;
- private apiToken = localStorage['apiToken'];
- private userId = localStorage['userId'];
+ private apiToken = sessionStorage['apiToken'];
+ private userId = sessionStorage['userId'];
public versionNoForApiCall=require('../../../../cdt.application.properties.json').versionNoForApiCall;
constructor(private mappingEditorService: MappingEditorService,
@@ -556,4 +556,4 @@ export class ParameterDefinitionService {
this.populatePD(fileModel);
return this.displayParamObjects;
}
-} \ No newline at end of file
+}
diff --git a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts
index 64f1159..7686839 100644
--- a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts
+++ b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
Copyright (C) 2018 IBM Intellectual Property. All rights reserved.
===================================================================
@@ -72,8 +72,8 @@ export class ParameterComponent implements OnInit {
public confirmation: boolean;
public showConfirmation: boolean;
public test: boolean;
- apiToken = localStorage['apiToken'];
- userId = localStorage['userId'];
+ apiToken = sessionStorage['apiToken'];
+ userId = sessionStorage['userId'];
public initialData: any;
public intialData: any;
public initialAction: any;
diff --git a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts
index a3ef4f7..ac89a2d 100644
--- a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts
+++ b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -939,7 +939,7 @@ export class ReferenceDataformComponent implements OnInit {
let payload = this.utilityService.createPayLoadForSave("reference_data", dataJson['scope']['vnf-type'], "AllAction", fileName, this.versionNoForApiCall, slashedPayload);
this.ngProgress.start();
- this.httpUtils.post({
+ this.httpUtils.postWithAuth({
url: environment.getDesigns,
data: payload
}).subscribe((resp) => {
diff --git a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts
index f18fe6c..ab1a7b3 100644
--- a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts
+++ b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Copyright (C) 2018 IBM Intellectual Property. All rights reserved.
===================================================================
@@ -77,8 +77,8 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy {
action: any = '';
artifactName: any = '';
enableMerge: boolean = false;
- apiToken = localStorage['apiToken'];
- userId = localStorage['userId'];
+ apiToken = sessionStorage['apiToken'];
+ userId = sessionStorage['userId'];
identifier: any;
public uploadTypes = [
@@ -435,4 +435,4 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy {
}
}
-} \ No newline at end of file
+}
diff --git a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
index cee9629..913e5e9 100644
--- a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
+++ b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -75,7 +75,7 @@ export class GoldenConfigurationComponent implements OnInit {
enableBrowse: boolean = true;
enableMerge: boolean = false;
uploadValidationSuccess: boolean = false;
- apiToken = localStorage['apiToken'];
+ apiToken = sessionStorage['apiToken'];
public appDataObject: any;
public downloadDataObject: any;
public checkNameEntered: boolean = true;
@@ -130,7 +130,7 @@ export class GoldenConfigurationComponent implements OnInit {
public fileType: any = '';
public actionType: any;
public myfileName: any;
- userId = localStorage['userId'];
+ userId = sessionStorage['userId'];
public artifactRequest: ArtifactRequest = new ArtifactRequest();
public showUploadStatus: boolean = false;
public uploadStatus: boolean = false;
diff --git a/src/app/vnfs/myvnfs/myvnfs.component.ts b/src/app/vnfs/myvnfs/myvnfs.component.ts
index 49f4f42..696e601 100644
--- a/src/app/vnfs/myvnfs/myvnfs.component.ts
+++ b/src/app/vnfs/myvnfs/myvnfs.component.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Copyright (C) 2018 IBM.
===================================================================
@@ -63,7 +63,7 @@ export class MyvnfsComponent implements OnInit, OnDestroy {
sessionStorage.setItem('updateParams', undefined);
this.mappingEditorService.latestAction = undefined;
- const apiToken = localStorage['apiToken'];
+ const apiToken = sessionStorage['apiToken'];
const data = {
'input': {
@@ -75,7 +75,7 @@ export class MyvnfsComponent implements OnInit, OnDestroy {
}
};
const x = JSON.parse(data.input['design-request']['payload']);
- x.userID = localStorage['userId'];
+ x.userID = sessionStorage['userId'];
data.input['design-request']['payload'] = JSON.stringify(x);
// console.log("input to payload====", JSON.stringify(data));
this.getArtifacts(data);
@@ -89,7 +89,7 @@ export class MyvnfsComponent implements OnInit, OnDestroy {
getArtifacts(data) {
let tempObj: any;
this.ngProgress.start();
- this.httpUtil.post({
+ this.httpUtil.postWithAuth({
url: environment.getDesigns,
data: data
})
@@ -233,4 +233,4 @@ export class MyvnfsComponent implements OnInit, OnDestroy {
}
-} \ No newline at end of file
+}
diff --git a/src/app/vnfs/userlogin-form/userlogin-form.component.html b/src/app/vnfs/userlogin-form/userlogin-form.component.html
index 3f18b72..069583e 100644
--- a/src/app/vnfs/userlogin-form/userlogin-form.component.html
+++ b/src/app/vnfs/userlogin-form/userlogin-form.component.html
@@ -1,7 +1,7 @@
<!--
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -32,6 +32,10 @@ limitations under the License.
[(ngModel)]="userId" name="userId" value="" #user="ngModel" (ngModelChange)="validateUserName()">
<span class="error-message">{{errorMessage}}</span>
</div>
+ <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
+ <input type="password" placeholder="Enter password" class="mdl-textfield__input" id="password" required
+ [(ngModel)]="password" name="password" value="" (ngModelChange)="validatePassword()" >
+ </div>
<div class="form-group text-right">
<button type="submit" [disabled]="invalid"
@@ -43,4 +47,4 @@ limitations under the License.
</div>
</div>
</div>
-</div> \ No newline at end of file
+</div>
diff --git a/src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts b/src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts
index 712d1bf..bf8431b 100644
--- a/src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts
+++ b/src/app/vnfs/userlogin-form/userlogin-form.component.spec.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
Modification Copyright (C) 2018 IBM
===================================================================
@@ -64,7 +64,7 @@ describe('userloginFormComponent', () => {
fixture = TestBed.createComponent(userloginFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
- // localStorage['userId'] = "testUser"
+ // sessionStorage['userId'] = "testUser"
component.userId = 'test Usr';
});
@@ -99,7 +99,7 @@ describe('userloginFormComponent', () => {
expect(url.length).toBe(5);
expect(url[0]).toEqual('/');
expect(url[1]).toEqual('h');
- expect(localStorage['userId']).toBe('test Usr');
+ expect(sessionStorage['userId']).toBe('test Usr');
}));
it('test validateUserName function', () => {
diff --git a/src/app/vnfs/userlogin-form/userlogin-form.component.ts b/src/app/vnfs/userlogin-form/userlogin-form.component.ts
index c62e9bb..7ed087e 100644
--- a/src/app/vnfs/userlogin-form/userlogin-form.component.ts
+++ b/src/app/vnfs/userlogin-form/userlogin-form.component.ts
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -23,19 +23,24 @@ import {Component, OnInit} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import {EmitterService} from '../../shared/services/emitter.service';
+import { environment } from '../../../environments/environment';
+import { HttpUtilService } from '../../shared/services/httpUtil/http-util.service';
import {Router} from '@angular/router';
+import { NgProgress } from 'ngx-progressbar';
import {UtilityService} from '../../shared/services/utilityService/utility.service';
+import { Http, Response, Headers, RequestOptions } from '@angular/http';
@Component({selector: 'app-mvnfs-form', templateUrl: './userlogin-form.component.html', styleUrls: ['./userlogin-form.component.css']})
export class userloginFormComponent implements OnInit {
userId: string = '';
+ password: string = '';
returnUrl:string
invalid = true;
errorMessage = '';
- constructor(private router: Router, private utiltiy: UtilityService, private route: ActivatedRoute
- ) {
+ constructor(private router: Router, private utiltiy: UtilityService, private route: ActivatedRoute,
+ private http: Http, private ngProgress: NgProgress) {
}
ngOnInit() {
@@ -44,12 +49,57 @@ export class userloginFormComponent implements OnInit {
getData() {
- localStorage['userId'] = this.userId;
- localStorage['apiToken'] = this.utiltiy.randomId();
- EmitterService
- .get('userLogin')
- .emit(this.userId);
- this.router.navigateByUrl(this.returnUrl);
+ this.ngProgress.start();
+ var getHeader = new Headers({ 'Content-Type': 'application/json' }); // ... Set content type to JSON
+ var authStr = btoa(this.userId + ':' + this.password);
+ const options = {
+ headers: new Headers({
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Basic ' + authStr
+ }),
+ observe: 'response'
+ };
+ const data = {
+ 'input': {
+ 'design-request': {
+ 'request-id': '1',
+ 'action': 'getDesigns',
+ 'payload': '{"userID": "","filter":"reference"}'
+ }
+ }
+ };
+ const x = JSON.parse(data.input['design-request']['payload']);
+ x.userID = this.userId;
+ data.input['design-request']['payload'] = JSON.stringify(x);
+ console.log("auth " + btoa(this.userId + ':' + this.password));
+ this.http.post(environment.getDesigns,data,options).subscribe(resp => {
+ console.log("status " + resp.status);
+ if(resp.status == 200){
+ console.log('logged in');
+ sessionStorage['userId'] = this.userId;
+ sessionStorage['apiToken'] = this.utiltiy.randomId();
+ sessionStorage['auth'] = authStr;
+ EmitterService
+ .get('userLogin')
+ .emit(this.userId);
+ this.router.navigateByUrl(this.returnUrl);
+ } else {
+ console.log("Invalid user or password");
+ this.invalid = true;
+ this.errorMessage = 'Invalid user or password';
+ }
+ }, error => {
+ console.log(error);
+ if(error.status == 401){
+ this.invalid = true;
+ this.errorMessage = 'Invalid user or password';
+ } else {
+ this.invalid = true;
+ this.errorMessage = 'Incorrect login or connection error.';
+ }
+ });
+ console.log("After");
+
}
validateUserName(){
@@ -57,7 +107,7 @@ export class userloginFormComponent implements OnInit {
this.errorMessage = '';
this.invalid = true;
}else if(this.userId.startsWith(' ') || this.userId.endsWith(' ')){
- this.errorMessage = 'Leading and trailing space is not allowed';
+ this.errorMessage = 'Leading and trailing space is not allowed in username';
this.invalid = true;
} else if(this.userId.includes(' ')){
this.errorMessage = 'More than one space is not allowed in username';
@@ -70,5 +120,24 @@ export class userloginFormComponent implements OnInit {
this.errorMessage = '';
}
}
+
+ validatePassword(){
+ if (!this.password.trim() || this.password.length < 1) {
+ this.errorMessage = '';
+ this.invalid = true;
+ }else if(this.password.startsWith(' ') || this.password.endsWith(' ')){
+ this.errorMessage = 'Leading and trailing space is not allowed in password';
+ this.invalid = true;
+ } else if(this.password.includes(' ')){
+ this.errorMessage = 'More than one space is not allowed in password';
+ this.invalid = true;
+ } else if(this.password.length > 50) {
+ this.errorMessage = 'Password should be of minimum one character and maximum 50 character';
+ this.invalid = true;
+ }else {
+ this.invalid = false;
+ this.errorMessage = '';
+ }
+ }
}