diff --git a/mds-test-ui/README.md b/mds-test-ui/README.md index 6222a1d..3c846d4 100644 --- a/mds-test-ui/README.md +++ b/mds-test-ui/README.md @@ -1,29 +1,45 @@ -# MdsTestUi - -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.0.1. - -Change url to point to spring boot server in environments/environment.ts file. Currently it is set to base_url: 'http://localhost:8080/' - -## Development server - -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. - -## Code scaffolding - -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. - -## Build - -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. - -## Running unit tests - -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). - -## Running end-to-end tests - -Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). - -## Further help - -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). +# SBITestUi + +This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.0.1. + +Change url to point to spring boot server in environments/environment.ts file. Currently it is set to base_url: 'http://localhost:8081/' + +NodeJs is prerequisite + +## Local Set up one time + +Run `npm install` to download all the required configuration. `node_modules` will be created. + +## Development server + +Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. + +## Code scaffolding + +Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. + +## Build + +Since it is added inside java project and deployed together as one build, follow below step. + +In 'environment.prod.ts' make below changes and revert after build is done. +base_url: 'http://test.mosip.io/phase2/', + +In 'index.html' make below changes and revert after build is done. + + +Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. +Run `ng build --prod` +Files inside `dist/` should be trasfered to mosip device service + +## Running unit tests + +Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Running end-to-end tests + +Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). + +## Further help + +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/mds-test-ui/src/app/app.module.ts b/mds-test-ui/src/app/app.module.ts index 6201078..06bbb79 100644 --- a/mds-test-ui/src/app/app.module.ts +++ b/mds-test-ui/src/app/app.module.ts @@ -19,6 +19,7 @@ import { FooterComponent } from './components/footer/footer.component'; import { MatVideoModule } from 'mat-video'; import { ModalComponent } from './modal/modal.component'; import { DialogOverviewExampleDialog} from './auth/auth.component' +import { DialogOverviewCaptureDialog} from './capture/capture.component' @NgModule({ declarations: [ @@ -31,7 +32,8 @@ import { DialogOverviewExampleDialog} from './auth/auth.component' HeaderComponent, FooterComponent, ModalComponent, - DialogOverviewExampleDialog + DialogOverviewExampleDialog, + DialogOverviewCaptureDialog ], imports: [ BrowserModule, diff --git a/mds-test-ui/src/app/auth/auth.compnent.html b/mds-test-ui/src/app/auth/auth.compnent.html index be10600..e81ff8b 100644 --- a/mds-test-ui/src/app/auth/auth.compnent.html +++ b/mds-test-ui/src/app/auth/auth.compnent.html @@ -7,7 +7,7 @@

Authentication

Enter UIN -

* Default UIN is 6027349120, Provide your UIN to authenticate

+

* Default UIN is {{data.uin}}, Provide your UIN to authenticate

diff --git a/mds-test-ui/src/app/auth/auth.component.ts b/mds-test-ui/src/app/auth/auth.component.ts index c88601b..43c2855 100644 --- a/mds-test-ui/src/app/auth/auth.component.ts +++ b/mds-test-ui/src/app/auth/auth.component.ts @@ -18,17 +18,16 @@ export interface DialogData { authloading = false; data1 :DialogData; - uin=5698342963; + uin=6795809148; testReportObject: any; constructor( private dataService: DataService, private dialog: MatDialog, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: DialogData) { - console.log(data); this.data1=data; -this.data1.uin="6027349120"; +this.data1.uin="6795809148"; } onNoClick(): void { diff --git a/mds-test-ui/src/app/capture/capture.compnent.html b/mds-test-ui/src/app/capture/capture.compnent.html new file mode 100644 index 0000000..ffefd3c --- /dev/null +++ b/mds-test-ui/src/app/capture/capture.compnent.html @@ -0,0 +1,31 @@ + +

Request Options

+ +
+ + + Enter Time Out(in ms) + + + + Enter Previous Hash + + + + Enter Request Score + + + + +
+
+ + + + + +
+ diff --git a/mds-test-ui/src/app/capture/capture.component.css b/mds-test-ui/src/app/capture/capture.component.css new file mode 100644 index 0000000..ae62dc8 --- /dev/null +++ b/mds-test-ui/src/app/capture/capture.component.css @@ -0,0 +1,62 @@ +.example-form { + min-width: 150px; + max-width: 500px; + width: 100%; + margin: 18px; +} + +.example-full-width { + width: 100%; +} + + +.mat-form-field { + font-size: 14px; + width: 100%; +} + + +:host ::ng-deep .mat-tab-body-wrapper { + min-height: 150px; + +} + +:host ::ng-deep .mat-tab-body.mat-tab-body-active { + min-height: 150px; + +} + +.Passed{color: green;} +.Failed{color: red;} + +.centereddiv { + text-align: center; + color: #2c3e50; + margin-top: 60px; +} + +#video { + border: 5px solid transparent; + background-color: #000000; +} + + +@keyframes spinner { + to {transform: rotate(360deg);} +} + +.spinner:before { + content: ''; + box-sizing: border-box; + position: absolute; + top: 50%; + left: 50%; + width: 20px; + height: 20px; + margin-top: -10px; + margin-left: -10px; + border-radius: 50%; + border: 2px solid #ffffff; + border-top-color: #000000; + animation: spinner .8s linear infinite; +} diff --git a/mds-test-ui/src/app/capture/capture.component.ts b/mds-test-ui/src/app/capture/capture.component.ts new file mode 100644 index 0000000..f8a4ea0 --- /dev/null +++ b/mds-test-ui/src/app/capture/capture.component.ts @@ -0,0 +1,269 @@ +import { Component, Inject } from '@angular/core'; +import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { MdsService } from '../services/mds/mds.service'; + +import { ModalComponent } from '../modal/modal.component'; +import { DataService } from '../services/data/data.service'; +export interface DialogData { + timeOut: string; + requestScore: string, + previousHash: string, + testReportObject1: any; + testId: string; + request:any; +} + +@Component({ + selector: 'app-module', + templateUrl: 'capture.compnent.html', + styleUrls: ['./capture.component.css'] +}) +export class DialogOverviewCaptureDialog { + + validationResult: any; + keyRotatOrderIdList = [3011, 3012, 3013]; + keyRotatOrderIdListRcapture = [3014]; + successErrorCodeOfAuth = "IDA-BIA-001"; + succesAuth = "authStatus=true"; + failErrorCodeOfAuth = "IDA-MPA-002"; + validCertButton = false; + expiredCertButton = false; + afterKeyRotationButton = false; + loading = false; + authloading = false; + readyButton = false; + busyButton = false; + notReadyButton = false; + notRegisteredButton = false; + statusButton = false; + + data1: DialogData; + timeOut = 0; + testReportObject: any; + constructor( + private mdsService: MdsService, + private dataService: DataService, + private dialog: MatDialog, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: DialogData) { + this.data1 = data; + this.data1.requestScore = '40'; + this.data1.timeOut = '10000' + } + + onNoClick(): void { + this.dialogRef.close(); + } + + + openDialog(title: string, message: string): void { + this.authloading = false + this.dialog.open(ModalComponent, { + width: '80%', + data: { 'title': title, 'message': message } + }); + } + +//testReportObject.testReport[key].requestData,testReportObject.testReport[key].runId, key,null + +getMDSResponse(){ + this.authloading=true; + let myObj = JSON.parse(this.data1.request); + myObj.body=JSON.parse(myObj.body); + let bio1=myObj.body.bio[0]; + bio1.requestedScore = this.data.requestScore; + bio1.previousHash=this.data.previousHash; + myObj.body.bio[0]=bio1; + + myObj.body.timeout=this.data.timeOut; + myObj.body.bio[0].requestedScore=this.data.requestScore; + myObj.body.bio[0].previousHash=this.data.previousHash; + console.log(this.data1.testReportObject1); + this.mdsService.request(myObj).subscribe( + response => { + this.validateMDSResponse(this.data1.testReportObject1.runId, this.data1.testId, + myObj, response, status); + }, + error => { + this.validateMDSResponse(this.data1.testReportObject1.runId, + this.data1.testId, myObj, error, status); + } + ); +} + +validateMDSResponse(runId, testId, request, response, status) { + this.dataService.validateResponse(runId, testId, request, response).subscribe( + result => { + this.testReportObject = result; + if (testId == "Device Status") { + let testObjectValidationResult = this.testReportObject.testReport[testId].validationResults[0].validationTestResultDtos[0]; + testObjectValidationResult.validations[1].expected = status; + if (testObjectValidationResult.validations[1].found != status) { + this.testReportObject.testReport[testId].validationResults[0].status = "Failed"; + testObjectValidationResult.validations[1].status = "FAILED"; + testObjectValidationResult.validations[1].message = 'Device info response device status is invalid'; + } + + let testKeyObjectValidationResult = this.testReportObject.testReportKey[3][testId].validationResults[0].validationTestResultDtos[0]; + testKeyObjectValidationResult.validations[1].expected = status; + if (testKeyObjectValidationResult.validations[1].found != status) { + this.testReportObject.testReportKey[3][testId].validationResults[0].status = 'Failed'; + testKeyObjectValidationResult.validations[1].status = "FAILED"; + testKeyObjectValidationResult.validations[1].message = 'Device info response device status is invalid'; + } + } + + if (testId.includes("Key Rotation")) { + for (let i = 0; i < this.keyRotatOrderIdList.length; i++) { + if (this.testReportObject.testReportKey[this.keyRotatOrderIdList[i]] != null) { + // let testKeyObjectValidationResult=this.testReportObject.testReportKey[this.keyRotatOrderIdList[i]][testId].validationResults[0].validationTestResultDtos[0]; + this.validationResult = this.testReportObject.testReportKey[this.keyRotatOrderIdList[i]][testId].validationResults[0].validationTestResultDtos[0].validations[0]; + var reqData = JSON.parse(this.testReportObject.testReportKey[this.keyRotatOrderIdList[i]][testId].requestData) + if (reqData.verb == 'CAPTURE') { + + let authResponse = this.validationResult.found; + if (status == "validCertButton" || status == "afterKeyRotationButton") { + if (!(authResponse.includes(this.successErrorCodeOfAuth) || + authResponse.includes(this.succesAuth))) { + this.validationResult.message = "Unexpected result returned"; + this.validationResult.status = "FAILED"; + this.testReportObject.testReportKey[this.keyRotatOrderIdList[i]][testId].validationResults[0].status = "Failed"; + } + } else if (status == "expiredCertButton") { + if (!(authResponse.includes(this.failErrorCodeOfAuth))) { + this.validationResult.message = "Unexpected result returned"; + this.validationResult.status = "FAILED"; + this.testReportObject.testReportKey[this.keyRotatOrderIdList[i]][testId].validationResults[0].status = "Failed"; + } + } + this.testReportObject.testReportKey[this.keyRotatOrderIdList[i]][testId].validationResults[0].validationTestResultDtos[0].validations[0] = this.validationResult; + } + + } + // let testKeyObjectValidationResult=this.testReportObject.testReportKey[this.keyRotatOrderIdList[i]][testId].validationResults[0].validationTestResultDtos[0]; + this.validationResult = this.testReportObject.testReport[testId].validationResults[0].validationTestResultDtos[0].validations[0]; + var reqData = JSON.parse(this.testReportObject.testReport[testId].requestData); + if (reqData.verb == 'CAPTURE') { + + let authResponse = this.validationResult.found; + + if (status == "validCertButton" || status == "afterKeyRotationButton") { + if (!(authResponse.includes(this.successErrorCodeOfAuth) || + authResponse.includes(this.succesAuth))) { + this.validationResult.message = "Unexpected result returned"; + this.validationResult.status = "FAILED"; + this.testReportObject.testReport[testId].validationResults[0].status = "Failed"; + } + } else if (status == "expiredCertButton") { + if (!(authResponse.includes(this.failErrorCodeOfAuth))) { + this.validationResult.message = "Unexpected result returned"; + this.validationResult.status = "FAILED"; + this.testReportObject.testReport[testId].validationResults[0].status = "Failed"; + } + } + + this.testReportObject.testReport[testId].validationResults[0].validationTestResultDtos[0].validations[0] = this.validationResult; + } + + } + for (let i = 0; i < this.keyRotatOrderIdListRcapture.length; i++) { + if (this.testReportObject.testReportKey[this.keyRotatOrderIdListRcapture[i]] != null) { + // let testKeyObjectValidationResult=this.testReportObject.testReportKey[this.keyRotatOrderIdList[i]][testId].validationResults[0].validationTestResultDtos[0]; + this.validationResult = this.testReportObject.testReportKey[this.keyRotatOrderIdListRcapture[i]][testId].validationResults[0].validationTestResultDtos[0].validations[0]; + var reqData = JSON.parse(this.testReportObject.testReportKey[this.keyRotatOrderIdListRcapture[i]][testId].requestData) + + if (reqData.verb == 'RCAPTURE') { + if (status == "expiredCertButton") { + if (this.validationResult.status == "FAILED") { + this.validationResult.status = "SUCCESS"; + this.testReportObject.testReportKey[this.keyRotatOrderIdListRcapture[i]][testId].validationResults[0].status = "Passed"; + + } else if (this.validationResult.status == "SUCCESS") { + this.validationResult.status = "FAILED"; + this.testReportObject.testReportKey[this.keyRotatOrderIdListRcapture[i]][testId].validationResults[0].status = "Failed"; + + } + } + this.testReportObject.testReportKey[this.keyRotatOrderIdListRcapture[i]][testId].validationResults[0].validationTestResultDtos[0].validations[0] = this.validationResult; + this.validationResult = this.testReportObject.testReport[testId].validationResults[0].validationTestResultDtos[0].validations[0]; + var reqData = JSON.parse(this.testReportObject.testReport[testId].requestData); + if (reqData.verb == 'RCAPTURE') { + if (status == "expiredCertButton") { + if (this.validationResult.status == "FAILED") { + this.validationResult.status = "SUCCESS"; + this.testReportObject.testReport[testId].validationResults[0].status = "Passed"; + + } else if (this.validationResult.status == "SUCCESS") { + this.validationResult.status = "FAILED"; + this.testReportObject.testReport[testId].validationResults[0].status = "Failed"; + + } + } + this.testReportObject.testReport[testId].validationResults[0].validationTestResultDtos[0].validations[0] = this.validationResult; + + } + } + } + } + } + this.dialogRef.close(); + this.authloading = false; + this.loading = false; + this.statusButton = false; + this.readyButton = false; + this.busyButton = false; + this.notReadyButton = false; + this.notRegisteredButton = false; + this.statusButton = false; + this.validCertButton = false; + this.expiredCertButton = false; + this.afterKeyRotationButton = false; + }, + error => { + this.openDialog("Alert", error); + this.loading = false; + this.statusButton = false; + this.readyButton = false; + this.busyButton = false; + this.notReadyButton = false; + this.notRegisteredButton = false; + this.statusButton = false; + this.validCertButton = false; + this.expiredCertButton = false; + this.afterKeyRotationButton = false; + } + ); + } + + startAuthTest(timeOut: any) { + this.authloading = true; + + this.timeOut = timeOut; + this.dataService.authTestCallByUin(this.data1.testReportObject1.testReport[this.data1.testId].runId, this.data1.testId, timeOut).subscribe( + result => { + //window.alert(JSON.stringify(result)) + console.log("Auth Response", JSON.stringify(result)) + this.authloading = false; + }, + // error => console.log("Auth Error Response", error) + error => this.openDialog("Auth Response", JSON.stringify(error.error.text)) + + ); + + } + + getButtonName() { + let method = JSON.parse(this.data1.request).verb; + switch (method.toUpperCase()) { + case "MOSIPDISC": + return "Discover Devices"; + case "MOSIPDINFO": + return "Get Device Info"; + case "CAPTURE": + return "Initiate Capture"; + case "RCAPTURE": + return "Initiate RCapture"; + } + return "Initiate Request"; + } +} \ No newline at end of file diff --git a/mds-test-ui/src/app/components/run/run.component.css b/mds-test-ui/src/app/components/run/run.component.css index ae62dc8..40e6d21 100644 --- a/mds-test-ui/src/app/components/run/run.component.css +++ b/mds-test-ui/src/app/components/run/run.component.css @@ -35,6 +35,13 @@ margin-top: 60px; } +.leftdiv { + text-align: left; + color: #2c3e50; + margin-top: 60px; + margin-left: 20%; +} + #video { border: 5px solid transparent; background-color: #000000; diff --git a/mds-test-ui/src/app/components/run/run.component.html b/mds-test-ui/src/app/components/run/run.component.html index 44d38bb..7c4ffee 100644 --- a/mds-test-ui/src/app/components/run/run.component.html +++ b/mds-test-ui/src/app/components/run/run.component.html @@ -15,11 +15,12 @@ Device - {{'Purpose[' + obj.purpose + '] - BiometricDeviceType[' + obj.digitalIdDecoded.type + '] - DeviceSubType[' + obj.digitalIdDecoded.deviceSubType + ']' + ' - DeviceId[' + obj.deviceId+ ']'}} + {{'Purpose[' + obj.purpose + '] - BiometricDeviceType[' + + obj.digitalIdDecoded.type + '] - DeviceSubType[' + obj.digitalIdDecoded.deviceSubType + ']' + ' - DeviceId[' + + obj.deviceId+ ']'}} -
@@ -28,71 +29,78 @@
- -
- - - - {{key}} - - - {{testReportObject.testReport[key].currentState}} - - - - - -

- Summary : {{testReportObject.testReport[key].summary}} -

-
-

ExecutedOn : {{testReportObject.testReport[key].executedOn | date: 'full'}}

-
- - - -
- + + + + +

+ Summary : {{testReportObject.testReport[key].summary}} +

+
+

ExecutedOn : {{testReportObject.testReport[key].executedOn | date: 'full'}}

+
+ + +
+
+ 1) Check with Valid certificate.
+ 2) Wait for certificate to expire.Then test with expired certificate.
+ 3) Key Rotate and then test after key rotation.
+
+
+
+ - - + - - + - Start Streaming to Display -
+ Start Streaming to Display +
-
+
- - + + - - + - - - - -
diff --git a/mds-test-ui/src/app/components/run/run.component.ts b/mds-test-ui/src/app/components/run/run.component.ts index 0245695..7cbdde5 100644 --- a/mds-test-ui/src/app/components/run/run.component.ts +++ b/mds-test-ui/src/app/components/run/run.component.ts @@ -10,7 +10,9 @@ import { DomSanitizer } from '@angular/platform-browser'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { ModalComponent } from '../../modal/modal.component'; -import { DialogOverviewExampleDialog } from '../../auth/auth.component' +import { DialogOverviewExampleDialog } from '../../auth/auth.component'; +import { DialogOverviewCaptureDialog } from '../../capture/capture.component' + declare const start_streaming: any; declare const stop_streaming: any; @@ -25,10 +27,12 @@ export class RunComponent implements OnInit { uin: string; testId: string; testReportObject1: any; + timeOut:any; + requestScore:any; + previousHash:any; + keyRotatOrderIdList = [3011, 3012, 3013]; - keyRotatOrderIdList = [11, 12, 13]; - - keyRotatOrderIdListRcapture = [14]; + keyRotatOrderIdListRcapture = [3014]; successErrorCodeOfAuth = "IDA-BIA-001"; succesAuth = "authStatus=true"; failErrorCodeOfAuth = "IDA-MPA-002"; @@ -138,8 +142,7 @@ export class RunComponent implements OnInit { getMDSResponse(request, runId, testId, status) { - this.loading = true; - this.statusButton = true; + this.statusButton = true; if (status == 'Ready') { this.readyButton = true; } else if (status == 'Not Ready') { @@ -158,6 +161,17 @@ export class RunComponent implements OnInit { let mdmResponse = this.testReportObject.testReport[testId].responseData; + let method = JSON.parse(request).verb; + + if((method === "CAPTURE" || method==="RCAPTURE") && status == null) + this.openCaptureDataDialog(this.testReportObject,testId,request); + else + this.otherInitate(testId, request, runId, status); + } + + private otherInitate(testId: any, request: any, runId: any, status: any) { + this.loading = true; + if (this.mdmInitiated === true) { console.log("MDM request is currently going on ....."); } @@ -495,6 +509,26 @@ export class RunComponent implements OnInit { }); } + + + openCaptureDataDialog(testReportObject1: any, key: any,request:any): void { + this.testReportObject1 = testReportObject1; + this.testId = key; + const dialogRef = this.dialog.open(DialogOverviewCaptureDialog, { + width: '300px', + data: { timeOut: this.timeOut, + requestScore:this.requestScore, + previousHash:this.previousHash, + testReportObject1:this.testReportObject1, + testId: this.testId , + request:request} + }); + dialogRef.afterClosed().subscribe(result => { + console.log('The dialog was closed'); + this.uin = result; + }); + } + download(runId, testId) { this.loading = true; diff --git a/mds-test-ui/src/environments/environment.prod.ts b/mds-test-ui/src/environments/environment.prod.ts index 2baf8d7..62350b7 100644 --- a/mds-test-ui/src/environments/environment.prod.ts +++ b/mds-test-ui/src/environments/environment.prod.ts @@ -1,5 +1,5 @@ export const environment = { production: true, - base_url: 'http://test.mosip.io/phase2', - mds_url: 'http://test.mosip.io:' + base_url: 'https://test.mosip.io/phase2', + mds_url: 'https://test.mosip.io:' }; diff --git a/mosip-device-service/README.md b/mosip-device-service/README.md new file mode 100644 index 0000000..4d1ae3d --- /dev/null +++ b/mosip-device-service/README.md @@ -0,0 +1,34 @@ +# SBI Testing Kit + +This module contains SBI Testing Kit. Which will validate response from MOSIP Device service implementation as per defined [SPEC](https://docs.mosip.io/platform/biometrics/mosip-device-service-specification) + +Device specification can be found in /data/config/masterdata.json + +Test case details can be found in /data/config/test-definitions.json +Any new Test cases needed should be updated in above file in json format. + +MISP license,partner Id and partner API key should be updated in application.properties for Auth validations + +Java 11 is a prerequisite + +### Supported SPEC versions + +0.9.5 + +### Defaults + +server.port=8081 + +### Build and run + +If any updates in the UI place the build files in the /src/main/resources/static/ + +Execute the below command to build module + +> mvn clean install + +Deployable jar file will be created inside target folder. 'test-definitions.json' should be updated in the server + +otherwise, we could simply run Main class + +> io.mosip.mds.MosipDeviceSpecificationApplication \ No newline at end of file diff --git a/mosip-device-service/data/config/test-definitions.json b/mosip-device-service/data/config/test-definitions.json index 6fbebab..3840727 100644 --- a/mosip-device-service/data/config/test-definitions.json +++ b/mosip-device-service/data/config/test-definitions.json @@ -892,7 +892,7 @@ , { "testId": "Registration capture -Key Rotation - Left Slab", - "testOrderId":14, + "testOrderId":3014, "method": "rcapture", "testDescription": "Key Rotation Registration capture Request for Slap scanner", "requestGenerator": null, @@ -921,7 +921,7 @@ }, { "testId": "Auth capture -Key Rotation - Single Iris - Left Iris", - "testOrderId":12, + "testOrderId":3012, "method": "capture", "testDescription": "Valid Auth capture Key Rotation Request for Left iris", "requestGenerator": null, @@ -949,7 +949,7 @@ ] }, { "testId": "Auth capture -Key Rotation - LeftIndex Finger", - "testOrderId":11, + "testOrderId":3011, "method": "capture", "testDescription": "Key Rotation Auth capture Request for LeftIndex Finger", "requestGenerator": null, @@ -977,8 +977,8 @@ ] }, { - "testId": "Auth capture - Face", - "testOrderId":13, + "testId": "Auth capture -Key Rotation - Face", + "testOrderId":3013, "method": "capture", "testDescription": "Valid Auth capture Request only for Face", "requestGenerator": null, diff --git a/mosip-device-service/src/main/java/io/mosip/mds/dto/RegistrationCaptureRequest.java b/mosip-device-service/src/main/java/io/mosip/mds/dto/RegistrationCaptureRequest.java index 9caf617..b1c75f1 100644 --- a/mosip-device-service/src/main/java/io/mosip/mds/dto/RegistrationCaptureRequest.java +++ b/mosip-device-service/src/main/java/io/mosip/mds/dto/RegistrationCaptureRequest.java @@ -19,7 +19,7 @@ public static class RegistrationCaptureBioRequest public String env; //target environment public String purpose; public String specVersion; //expected MDS spec version - public int timeout; //timeout for registration capture + public String timeout; //timeout for registration capture public String captureTime; //time of capture request in ISO format including timezone public String transactionId; //registration Id for the current capture public RegistrationCaptureBioRequest[] bio; diff --git a/mosip-device-service/src/main/java/io/mosip/mds/dto/RegistrationCaptureRequest_0_9_2.java b/mosip-device-service/src/main/java/io/mosip/mds/dto/RegistrationCaptureRequest_0_9_2.java index 97ac91d..19d53ec 100644 --- a/mosip-device-service/src/main/java/io/mosip/mds/dto/RegistrationCaptureRequest_0_9_2.java +++ b/mosip-device-service/src/main/java/io/mosip/mds/dto/RegistrationCaptureRequest_0_9_2.java @@ -17,7 +17,7 @@ public class RegistrationCaptureBioRequest_0_9_2 public String env; //target environment public String specVersion; //expected MDS spec version - public Integer timeout; //timeout for registration capture + public String timeout; //timeout for registration capture public String captureTime; //time of capture request in ISO format including timezone public String registrationId; //registration Id for the current capture public RegistrationCaptureBioRequest_0_9_2[] bio; diff --git a/mosip-device-service/src/main/java/io/mosip/mds/service/MDS_0_9_2_RequestBuilder.java b/mosip-device-service/src/main/java/io/mosip/mds/service/MDS_0_9_2_RequestBuilder.java index 5212007..f6aecc5 100644 --- a/mosip-device-service/src/main/java/io/mosip/mds/service/MDS_0_9_2_RequestBuilder.java +++ b/mosip-device-service/src/main/java/io/mosip/mds/service/MDS_0_9_2_RequestBuilder.java @@ -130,7 +130,7 @@ private String registrationCapture(TestDefinition test, DeviceDto device) throws requestBody.env = "test"; //requestBody.purpose = "AUTHENTICATION"; requestBody.specVersion = "0.9.2"; - requestBody.timeout = 30; + requestBody.timeout = "30"; requestBody.registrationId = "" + System.currentTimeMillis(); RegistrationCaptureRequest_0_9_2.RegistrationCaptureBioRequest_0_9_2 bio = requestBody.new RegistrationCaptureBioRequest_0_9_2(); bio.count = 1; diff --git a/mosip-device-service/src/main/java/io/mosip/mds/service/MDS_0_9_5_RequestBuilder.java b/mosip-device-service/src/main/java/io/mosip/mds/service/MDS_0_9_5_RequestBuilder.java index 7fe3135..b4512a0 100644 --- a/mosip-device-service/src/main/java/io/mosip/mds/service/MDS_0_9_5_RequestBuilder.java +++ b/mosip-device-service/src/main/java/io/mosip/mds/service/MDS_0_9_5_RequestBuilder.java @@ -192,7 +192,7 @@ private String getRegistrationCaptureRequest(TestManagerDto targetProfile, TestD requestBody.env = "Developer"; requestBody.purpose = "Registration"; requestBody.specVersion = "0.9.5"; - requestBody.timeout = 10000; + requestBody.timeout = "10000"; requestBody.transactionId = "" + System.currentTimeMillis(); requestBody.bio = new RegistrationCaptureRequest.RegistrationCaptureBioRequest[1]; diff --git a/mosip-device-service/src/main/java/io/mosip/mds/util/BioAuthRequestUtil.java b/mosip-device-service/src/main/java/io/mosip/mds/util/BioAuthRequestUtil.java index 83b4ec1..2a5cabe 100644 --- a/mosip-device-service/src/main/java/io/mosip/mds/util/BioAuthRequestUtil.java +++ b/mosip-device-service/src/main/java/io/mosip/mds/util/BioAuthRequestUtil.java @@ -79,27 +79,9 @@ @Component public class BioAuthRequestUtil { - @Autowired - private ObjectMapper objMapper; - private static final Logger logger = LoggerFactory.getLogger(BioAuthRequestUtil.class); private static String AUTH_REQ_TEMPLATE = "{ \"id\": \"string\",\"metadata\": {},\"request\": { \"appId\": \"%s\", \"clientId\": \"%s\", \"secretKey\": \"%s\" }, \"requesttime\": \"%s\", \"version\": \"string\"}"; - private static String SIGN_REQ_TEMPLATE = "{\r\n" + - " \"id\": \"string\",\r\n" + - " \"metadata\": {},\r\n" + - " \"request\": {\r\n" + - " \"applicationId\": \"IDA\",\r\n" + - " \"dataToSign\": \"%s\",\r\n" + - " \"includeCertHash\": true,\r\n" + - " \"includeCertificate\": true,\r\n" + - " \"includePayload\": false,\r\n" + - " \"referenceId\": \"SIGN\"\r\n" + - " },\r\n" + - " \"requesttime\": \"%s\",\r\n" + - " \"version\": \"string\"\r\n" + - "}"; - private static final String VERSION = "1.0"; private static final String UIN = "UIN"; private static final String TRANSACTION_ID = "1234567890"; @@ -250,30 +232,6 @@ public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttp return restTemplate; } - private String doAuthRequest(String authToken, Map authRequestMap) throws Exception { - try { - String reqBodyJson = mapper.writeValueAsString(authRequestMap); - OkHttpClient client = new OkHttpClient(); - MediaType mediaType = MediaType.parse("application/json; charset=utf-8"); - RequestBody body = RequestBody.create(mediaType, reqBodyJson); - Request request = new Request.Builder() - //curl -X POST "https://dev.mosip.net/v1/keymanager/sign" -H "accept: */*" -H "Content-Type: application/json" -d "{ \"id\": \"string\", \"metadata\": {}, \"request\": { \"data\": \"string\" }, \"requesttime\": \"2018-12-10T06:12:52.994Z\", \"version\": \"string\"}" - .header("signature", sign(CryptoUtil.encodeBase64(reqBodyJson.getBytes("UTF-8")) - )) - .header( "Authorization" , authToken) - .url(String.format(env.getProperty("ida.auth.url"), env.getProperty("auth.request.misplicense.key"), - env.getProperty("auth.request.partnerid"), env.getProperty("auth.request.partnerapi.key"))) - .post(body) - .build(); - Response idaResponse = client.newCall(request).execute(); - return idaResponse.body().string(); - - } catch (IOException | JSONException e) { - logger.error("Failed to fetch cert from IDA auth server", e); - } - return "Failed to get auth response !"; - } - private EncryptionResponseDto kernelEncrypt(EncryptionRequestDto encryptionRequestDto, X509Certificate certificate) throws Exception { EncryptionResponseDto encryptionResponseDto = new EncryptionResponseDto(); @@ -295,22 +253,6 @@ private EncryptionResponseDto kernelEncrypt(EncryptionRequestDto encryptionReque return encryptionResponseDto; } - private EncryptionResponseDto kernelEncrypt1(EncryptionRequestDto encryptionRequestDto, X509Certificate x509Cert) throws Exception { - String identityBlock = objMapper.writeValueAsString(encryptionRequestDto.getIdentityRequest()); - SecretKey secretKey = cryptoUtil.genSecKey(); - EncryptionResponseDto encryptionResponseDto = new EncryptionResponseDto(); - byte[] encryptedIdentityBlock = cryptoUtil.symmetricEncrypt(identityBlock.getBytes(StandardCharsets.UTF_8), - secretKey); - encryptionResponseDto.setEncryptedIdentity(Base64.encodeBase64URLSafeString(encryptedIdentityBlock)); - PublicKey publicKey = x509Cert.getPublicKey(); - byte[] encryptedSessionKeyByte = cryptoUtil.asymmetricEncrypt((secretKey.getEncoded()), publicKey); - encryptionResponseDto.setEncryptedSessionKey(Base64.encodeBase64URLSafeString(encryptedSessionKeyByte)); - byte[] byteArr = cryptoUtil.symmetricEncrypt(digestAsPlainText(HMACUtils2.generateHash(identityBlock.getBytes(StandardCharsets.UTF_8))).getBytes(), - secretKey); - encryptionResponseDto.setRequestHMAC(Base64.encodeBase64URLSafeString(byteArr)); - return encryptionResponseDto; - } - public static String digestAsPlainText(byte[] data) { return DatatypeConverter.printHexBinary(data).toUpperCase(); } @@ -323,28 +265,6 @@ private X509Certificate getCertificateFull(String authToken, String role) throws return x509Certificate; } - //Depriciated - private String getJWTSignedData(String data, String authToken) throws IOException, JSONException { - OkHttpClient client = new OkHttpClient(); - String requestBody = String.format(SIGN_REQ_TEMPLATE, - data, DateUtils.getUTCCurrentDateTime()); - - MediaType mediaType = MediaType.parse("application/json; charset=utf-8"); - RequestBody body = RequestBody.create(mediaType, requestBody); - Request request = new Request.Builder() - .header("cookie", "Authorization="+authToken) - .url(env.getProperty("internal.auth.jwtSign.url")) - .post(body) - .build(); - Response response = client.newCall(request).execute(); - if(response.isSuccessful()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - jsonObject = jsonObject.getJSONObject("response"); - return jsonObject.getString("jwtSignedData"); - } - return ""; - } - public String getAuthToken() throws IOException { OkHttpClient client = new OkHttpClient(); String requestBody = String.format(AUTH_REQ_TEMPLATE, diff --git a/mosip-device-service/src/main/java/io/mosip/mds/validator/ValidValueRCaptureResponseValidator.java b/mosip-device-service/src/main/java/io/mosip/mds/validator/ValidValueRCaptureResponseValidator.java index dca3978..4683797 100644 --- a/mosip-device-service/src/main/java/io/mosip/mds/validator/ValidValueRCaptureResponseValidator.java +++ b/mosip-device-service/src/main/java/io/mosip/mds/validator/ValidValueRCaptureResponseValidator.java @@ -325,16 +325,16 @@ else if(biometrics[bioIndex].dataDecoded.bioType.equals(CommonConstant.FACE)) { validations.add(validation); bioIndex++; } - if(biometrics[bioIndex].dataDecoded.bioType.equals(CommonConstant.IRIS)) { - - validation = commonValidator.setFieldExpected("dataDecoded.bioSubType",subType,biometrics[bioIndex].dataDecoded.bioSubType); - if(!biometrics[bioIndex].dataDecoded.bioSubType.equals(subType) - && !bioSubTypeIrisList.contains(biometrics[bioIndex].dataDecoded.bioSubType)) { - commonValidator.setFoundMessageStatus(validation,biometrics[bioIndex].dataDecoded.bioSubType,"invalid biometrics SubType returned",CommonConstant.FAILED); - } - validations.add(validation); - bioIndex++; - } +// if(biometrics[bioIndex].dataDecoded.bioType.equals(CommonConstant.IRIS)) { +// +// validation = commonValidator.setFieldExpected("dataDecoded.bioSubType",subType,biometrics[bioIndex].dataDecoded.bioSubType); +// if(!biometrics[bioIndex].dataDecoded.bioSubType.equals(subType) +// && !bioSubTypeIrisList.contains(biometrics[bioIndex].dataDecoded.bioSubType)) { +// commonValidator.setFoundMessageStatus(validation,biometrics[bioIndex].dataDecoded.bioSubType,"invalid biometrics SubType returned",CommonConstant.FAILED); +// } +// validations.add(validation); +// bioIndex++; +// } } }