From fdee757af0388635adcebbfd28dfc48ac000fcf1 Mon Sep 17 00:00:00 2001 From: Sebastian-Ion TINCU <Sebastian-Ion.TINCU@ext.ec.europa.eu> Date: Wed, 10 Apr 2024 17:59:59 +0200 Subject: [PATCH] EDELIVERY-13046 SMP - Keystore - Non-keypair Entries Containing Only Certificates Present in the Keystore Are Not Displayed Distinguish between certificate-only and key-pair entries in a keystore. --- .../admin-keystore/admin-keystore.component.html | 12 +++++++++++- .../admin-keystore/admin-keystore.component.ts | 4 +--- .../edelivery/smp/services/ui/UIKeystoreService.java | 6 +++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/smp-angular/src/app/system-settings/admin-keystore/admin-keystore.component.html b/smp-angular/src/app/system-settings/admin-keystore/admin-keystore.component.html index f5fb37fd0..569c999d9 100644 --- a/smp-angular/src/app/system-settings/admin-keystore/admin-keystore.component.html +++ b/smp-angular/src/app/system-settings/admin-keystore/admin-keystore.component.html @@ -1,7 +1,7 @@ <div id="admin-keystore-panel"> <data-panel id="admin-keystore-data-panel" title="Keystore administration" - text="Keystore is contains keys for singing responses and Client keys for SML integrations ." + text="Keystore contains keys for signing responses and Client keys for SML integrations." [labelColumnContent]="searchKeyCertificatePanel"> <ng-template #noDataFound> <div class="empty-data-panel">No certificate selected.</div> @@ -43,6 +43,16 @@ [matTooltip]="row.certificateId">{{row.alias}}</td> </ng-container> + <ng-container matColumnDef="entry-type"> + <th mat-header-cell *matHeaderCellDef>Type</th> + <td mat-cell *matCellDef="let row" + [ngClass]="{'datatable-row-error': row.invalid}" + [matTooltip]="row.containingKey ? 'Key Pair': 'Certificate'"> + <span *ngIf="!!row.containingKey"><mat-icon>key</mat-icon></span> + <span *ngIf="!row.containingKey"><mat-icon>article</mat-icon></span> + </td> + </ng-container> + <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let odd = odd; let row; columns: displayedColumns;" (click)="certificateSelected(row)" diff --git a/smp-angular/src/app/system-settings/admin-keystore/admin-keystore.component.ts b/smp-angular/src/app/system-settings/admin-keystore/admin-keystore.component.ts index 2ea296b07..6bb19157a 100644 --- a/smp-angular/src/app/system-settings/admin-keystore/admin-keystore.component.ts +++ b/smp-angular/src/app/system-settings/admin-keystore/admin-keystore.component.ts @@ -18,7 +18,7 @@ import {CertificateRo} from "../../common/model/certificate-ro.model"; styleUrls: ['./admin-keystore.component.css'] }) export class AdminKeystoreComponent implements OnInit, OnDestroy, AfterViewInit, BeforeLeaveGuard { - displayedColumns: string[] = ['alias']; + displayedColumns: string[] = ['alias', 'entry-type']; dataSource: MatTableDataSource<CertificateRo> = new MatTableDataSource(); keystoreCertificates: CertificateRo[]; selected?: CertificateRo; @@ -100,10 +100,8 @@ export class AdminKeystoreComponent implements OnInit, OnDestroy, AfterViewInit, this.dataSource.data = this.keystoreCertificates; // show the last page this.paginator.lastPage(); - } - applyKeyAliasFilter(event: Event) { const filterValue = (event.target as HTMLInputElement).value; this.dataSource.filter = filterValue.trim().toLowerCase(); diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIKeystoreService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIKeystoreService.java index aa517b92a..5a5566a6c 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIKeystoreService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIKeystoreService.java @@ -175,8 +175,8 @@ public class UIKeystoreService extends BasicKeystoreService { private void loadKeyAndCert(KeyStore keyStore, String alias, String keySecurityToken, Map<String, Key> hmKeys, Map<String, X509Certificate> hmCertificates) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException { Key key = keyStore.getKey(alias, keySecurityToken.toCharArray()); Certificate certificate = keyStore.getCertificate(alias); - if (key == null || certificate == null || !(certificate instanceof X509Certificate)) { - LOG.warn("Wrong entry type found in keystore, only certificates with keypair are accepted, entry alias: [{}]. Entry is ignored", alias); + if (!(certificate instanceof X509Certificate)) { + LOG.warn("Wrong certificate type found in keystore, entry alias: [{}]. Entry is ignored", alias); return; } // add to cache @@ -196,7 +196,7 @@ public class UIKeystoreService extends BasicKeystoreService { CertificateRO certificateRO = convertToRo(cert); basicCertificateValidation(cert, certificateRO); certificateRO.setAlias(alias); - certificateRO.setContainingKey(keystoreKeys.containsKey(alias)); + certificateRO.setContainingKey(keystoreKeys.get(alias) != null); certificateROList.add(certificateRO); }); } -- GitLab