From a928241dbb60ae575daba9a620cf97279ee0e866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Wed, 25 Aug 2021 16:29:15 +0100 Subject: [PATCH 1/4] IBM Web notification config add --- src/app/home/home.page.ts | 6 ++++-- src/app/services/webnotifications.service.ts | 6 ++++-- src/index.html | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index 070babc46..946a63ea8 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -7,6 +7,7 @@ import { EventsService } from '../services/events.service'; import { Event } from '../models/event.model'; import { ProcessesService } from '../services/processes.service'; import { NotificationsService } from '../services/notifications.service'; +import { WebNotificationsService } from '../services/webnotifications.service'; import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular'; import { Router, ActivatedRoute } from '@angular/router'; import { ToDayEventStorage } from '../store/to-day-event-storage.service'; @@ -73,7 +74,7 @@ export class HomePage implements OnInit { private notificatinsservice: NotificationsService, private platform: Platform, private activeroute: ActivatedRoute, - // private network: NetworkService, + private webnotification: WebNotificationsService, public p: PermissionService, public documentCounterService: DocumentCounterService) { @@ -105,7 +106,8 @@ export class HomePage implements OnInit { this.network.checkNetworkDisconnection; */ console.log('Active route ', this.router.url) if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - console.log('Notifications not supported') + this.webnotification.webconnection(); + this.webnotification.onReceviNotificationWeb(); } else { this.mobilefirstConnect(); this.notificatinsservice.getAndpostToken2(); diff --git a/src/app/services/webnotifications.service.ts b/src/app/services/webnotifications.service.ts index c528bc51c..ec446a1e8 100644 --- a/src/app/services/webnotifications.service.ts +++ b/src/app/services/webnotifications.service.ts @@ -32,10 +32,10 @@ export class WebNotificationsService { webconnection() { - MFPPush.initialize({ + /* MFPPush.initialize({ appId: "com.gpr.gabinetedigital", mfpContextRoot: "/mfp", - }); + }); */ MFPPush.registerDevice() .then((res) => { @@ -72,7 +72,9 @@ async onReceviNotificationWeb() { if(message.actionName){ //this.notificatinsRoutes(data); + console.log("Web notification") } else { + console.log("Web notification") //this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data); } diff --git a/src/index.html b/src/index.html index f1e90bcc6..553bfaa3f 100644 --- a/src/index.html +++ b/src/index.html @@ -7,11 +7,11 @@ - - + + - + From 246b6266003498e4c58be915bb03480e20bb8bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Wed, 25 Aug 2021 16:37:45 +0100 Subject: [PATCH 2/4] Callback add at home page edit --- src/app/home/home.page.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index 7ee901507..1b58abf19 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -5,12 +5,8 @@ import { Component, OnInit, NgZone } from '@angular/core'; import { Event } from '../models/event.model'; import { NotificationsService } from '../services/notifications.service'; -<<<<<<< HEAD import { WebNotificationsService } from '../services/webnotifications.service'; import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular'; -======= -import { AlertController, Platform } from '@ionic/angular'; ->>>>>>> 07435162e12e42437c43ac894bad4be11c64e70e import { Router, ActivatedRoute } from '@angular/router'; import { ToDayEventStorage } from '../store/to-day-event-storage.service'; import { DocumentCounterService } from 'src/app/OtherService/document-counter.service' From c80d8fb5884b478969572d68bd29a4218d5000a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Thu, 26 Aug 2021 16:32:59 +0100 Subject: [PATCH 3/4] User password encrypted --- src/app/services/aesencrypt.service.spec.ts | 16 ++++++ src/app/services/aesencrypt.service.ts | 56 +++++++++++++++++++++ src/app/services/auth.service.ts | 4 +- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 src/app/services/aesencrypt.service.spec.ts create mode 100644 src/app/services/aesencrypt.service.ts diff --git a/src/app/services/aesencrypt.service.spec.ts b/src/app/services/aesencrypt.service.spec.ts new file mode 100644 index 000000000..081c16cb1 --- /dev/null +++ b/src/app/services/aesencrypt.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { AESEncrypt } from './aesencrypt.service'; + +describe('AuthService', () => { + let service: AESEncrypt; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(AESEncrypt); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/aesencrypt.service.ts b/src/app/services/aesencrypt.service.ts new file mode 100644 index 000000000..551281a03 --- /dev/null +++ b/src/app/services/aesencrypt.service.ts @@ -0,0 +1,56 @@ +import { Injectable } from '@angular/core'; +import CryptoJS from 'crypto-js'; + +@Injectable({ + providedIn: 'root' +}) +export class AESEncrypt { + + ivArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + constructor() { } + + encrypt(encryptData, pass) { + var text = "Pro-it te espera!!!!"; + //Creating the Vector Key + var iv = CryptoJS.enc.Hex.parse(this.toHexString(this.ivArray)); + //Encoding the Password in from UTF8 to byte array + var Pass = CryptoJS.enc.Utf8.parse(pass); + //Encoding the Salt in from UTF8 to byte array + var Salt = CryptoJS.enc.Utf8.parse("gabinetedigital"); + //Creating the key in PBKDF2 format to be used during the decryption + var key128Bits1000Iterations = CryptoJS.PBKDF2(Pass.toString(CryptoJS.enc.Utf8), Salt, { keySize: 128 / 32, iterations: 1000 }); + + //Decrypting the string contained in cipherParams using the PBKDF2 key + var decrypted = CryptoJS.AES.encrypt(encryptData, key128Bits1000Iterations, { mode: CryptoJS.mode.CBC, iv: iv, padding: CryptoJS.pad.Pkcs7 }); + console.log('AES encrypt',decrypted.toString()); + } + + decrypt(deceyptData,pass) { + + //Creating the Vector Key + var iv = CryptoJS.enc.Hex.parse(this.toHexString(this.ivArray)); + //Encoding the Password in from UTF8 to byte array + var Pass = CryptoJS.enc.Utf8.parse(pass); + //Encoding the Salt in from UTF8 to byte array + var Salt = CryptoJS.enc.Utf8.parse("gabinetedigital"); + //Creating the key in PBKDF2 format to be used during the decryption + var key128Bits1000Iterations = CryptoJS.PBKDF2(Pass.toString(CryptoJS.enc.Utf8), Salt, { keySize: 128 / 32, iterations: 1000 }); + //Enclosing the test to be decrypted in a CipherParams object as supported by the CryptoJS libarary + var cipherParams = CryptoJS.lib.CipherParams.create({ + ciphertext: CryptoJS.enc.Base64.parse(deceyptData) + }) + + //Decrypting the string contained in cipherParams using the PBKDF2 key + var decrypted = CryptoJS.AES.decrypt(cipherParams, key128Bits1000Iterations, { mode: CryptoJS.mode.CBC, iv: iv, padding: CryptoJS.pad.Pkcs7 }); + console.log('AES decrypt',decrypted.toString(CryptoJS.enc.Utf8)); + } + + toHexString(byteArray) { + return Array.from(byteArray, (value: any) => { + return ('0' + (value & 0xFF).toString(16)).slice(-2); + }).join('') + } + +} + + diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 711943234..c2689d9e5 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -12,6 +12,7 @@ import { LocalstoreService } from '../store/localstore.service'; import { ToastService } from './toast.service'; import { UserStore } from 'src/app/store/user.service' import { SHA1, SHA256, AES, enc } from 'crypto-js' +import { AESEncrypt } from '../services/aesencrypt.service'; @Injectable({ providedIn: 'root' @@ -33,6 +34,7 @@ export class AuthService { public alertController: AlertController, private localstoreService: LocalstoreService, private toastService: ToastService, + private aesencrypt: AESEncrypt, ) { this.headers = new HttpHeaders(); @@ -51,7 +53,7 @@ export class AuthService { async login(user: UserForm): Promise { // user.BasicAuthKey = 'Basic ' + btoa(user.username + '@' + user.domainName + ':' + user.password); user.BasicAuthKey = 'Basic ' + btoa(user.username + ':' + user.password); //conversão em base64 das credenciais inseridas - console.log('Basic ' + btoa(user.username + ':' + SHA1(user.password).toString())); //conversão em base64 das credenciais inseridas + console.log('Basic ' + btoa(user.username + ':' + this.aesencrypt.encrypt(user.password,user.username ))); //conversão em base64 das credenciais inseridas this.headers = this.headers.set('Authorization',user.BasicAuthKey); From 181da6b1e0944d402e25f1526577b96ab61d6cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Fri, 27 Aug 2021 10:13:35 +0100 Subject: [PATCH 4/4] Bug fixed encrypting the password --- src/app/services/aesencrypt.service.ts | 4 ++++ src/app/services/auth.service.ts | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/services/aesencrypt.service.ts b/src/app/services/aesencrypt.service.ts index 551281a03..2a9f33289 100644 --- a/src/app/services/aesencrypt.service.ts +++ b/src/app/services/aesencrypt.service.ts @@ -23,6 +23,8 @@ export class AESEncrypt { //Decrypting the string contained in cipherParams using the PBKDF2 key var decrypted = CryptoJS.AES.encrypt(encryptData, key128Bits1000Iterations, { mode: CryptoJS.mode.CBC, iv: iv, padding: CryptoJS.pad.Pkcs7 }); console.log('AES encrypt',decrypted.toString()); + + return decrypted.toString(); } decrypt(deceyptData,pass) { @@ -43,6 +45,8 @@ export class AESEncrypt { //Decrypting the string contained in cipherParams using the PBKDF2 key var decrypted = CryptoJS.AES.decrypt(cipherParams, key128Bits1000Iterations, { mode: CryptoJS.mode.CBC, iv: iv, padding: CryptoJS.pad.Pkcs7 }); console.log('AES decrypt',decrypted.toString(CryptoJS.enc.Utf8)); + + return decrypted.toString(CryptoJS.enc.Utf8); } toHexString(byteArray) { diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index c2689d9e5..ca8a8c86e 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -52,8 +52,10 @@ export class AuthService { async login(user: UserForm): Promise { // user.BasicAuthKey = 'Basic ' + btoa(user.username + '@' + user.domainName + ':' + user.password); - user.BasicAuthKey = 'Basic ' + btoa(user.username + ':' + user.password); //conversão em base64 das credenciais inseridas + user.BasicAuthKey = 'Basic ' + btoa(user.username + ':' + this.aesencrypt.encrypt(user.password,user.username )); + //conversão em base64 das credenciais inseridas console.log('Basic ' + btoa(user.username + ':' + this.aesencrypt.encrypt(user.password,user.username ))); //conversão em base64 das credenciais inseridas + console.log("Encript ",this.aesencrypt.encrypt(user.password,user.username )) this.headers = this.headers.set('Authorization',user.BasicAuthKey);