diff --git a/pom.xml b/pom.xml index 858ffb4c07eb5d62aae2f30d8441ee89e80aed0d..8b7453388d59eb3d4d33452972368ffdb6941546 100644 --- a/pom.xml +++ b/pom.xml @@ -257,6 +257,12 @@ <artifactId>h2</artifactId> <version>${h2.version}</version> </dependency> + <dependency> + <groupId>org.apache.santuario</groupId> + <artifactId>xmlsec</artifactId> + <version>2.3.3</version> + </dependency> + <!-- dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> diff --git a/smp-angular/src/app/common/enums/visibility.enum.ts b/smp-angular/src/app/common/enums/visibility.enum.ts index 446815b94ba2eeef4bb7a3f28112d0b9ef872f58..9445cfe301f5c08c8dea7a47374d76c422d6b506 100644 --- a/smp-angular/src/app/common/enums/visibility.enum.ts +++ b/smp-angular/src/app/common/enums/visibility.enum.ts @@ -4,11 +4,7 @@ export enum VisibilityEnum { */ Public= 'PUBLIC', /** - * Access to the resource is within the domain/group. Users must be authenticated and must be members of the domain/group/resource in order to read it. - */ - Internal= 'INTERNAL', - /** - * Access to the resource is possible only to the resource members + * Access to the resource, group or domain */ Private= 'PRIVATE' } diff --git a/smp-angular/src/app/common/model/domain-ro.model.ts b/smp-angular/src/app/common/model/domain-ro.model.ts index 8b2193d866c8a4fae6b1b6b254b2e98ad5acf834..2182ef215294b12fe94f8ecd12f25eebaa18fbb9 100644 --- a/smp-angular/src/app/common/model/domain-ro.model.ts +++ b/smp-angular/src/app/common/model/domain-ro.model.ts @@ -7,7 +7,6 @@ export interface DomainRo extends SearchTableEntity { smlSubdomain?: string; smlSmpId?: string; smlParticipantIdentifierRegExp?: string; - smlClientCertHeader?: string; smlClientKeyAlias?: string; signatureKeyAlias?: string; smlRegistered?: boolean; diff --git a/smp-angular/src/app/common/panels/membership-panel/membership-panel.component.html b/smp-angular/src/app/common/panels/membership-panel/membership-panel.component.html index 400ced3982c529c1bb97a0fbd710ab65fb0a3eec..56e37c8a1a17bdd7394a6094208c78d8ad72aabd 100644 --- a/smp-angular/src/app/common/panels/membership-panel/membership-panel.component.html +++ b/smp-angular/src/app/common/panels/membership-panel/membership-panel.component.html @@ -81,10 +81,11 @@ </table> </div> - <mat-paginator class="mat-elevation-z2" [length]="resultsLength" + <mat-paginator class="mat-elevation-z2" [length]="resultsLength" #memberPaginator (page)="onPageChanged($event)" - [pageSize]="5" - [pageSizeOptions]="[5, 10, 25]" + [hidePageSize]="true" + [pageSize]="pageSize" + [showFirstLastButtons]="true" [disabled]="entityNotSelected" aria-label="Select pages"></mat-paginator> </div> diff --git a/smp-angular/src/app/common/panels/membership-panel/membership-panel.component.ts b/smp-angular/src/app/common/panels/membership-panel/membership-panel.component.ts index c2daaace112089aacd544bb4bcd6fce821b957c2..458ea3c1166ff5a4c4c26b895ac2e12732290006 100644 --- a/smp-angular/src/app/common/panels/membership-panel/membership-panel.component.ts +++ b/smp-angular/src/app/common/panels/membership-panel/membership-panel.component.ts @@ -26,6 +26,7 @@ import {ResourceRo} from "../../model/resource-ro.model"; }) export class MembershipPanelComponent implements BeforeLeaveGuard { + pageSize: number = 10; @Input() membershipType: MemberTypeEnum = MemberTypeEnum.DOMAIN; private _domain: DomainRo; @@ -39,7 +40,7 @@ export class MembershipPanelComponent implements BeforeLeaveGuard { filter: any = {}; resultsLength = 0; isLoadingResults = false; - @ViewChild(MatPaginator) paginator: MatPaginator; + @ViewChild('memberPaginator') paginator: MatPaginator; constructor(private domainService: AdminDomainService, private membershipService: MembershipService, @@ -71,13 +72,10 @@ export class MembershipPanelComponent implements BeforeLeaveGuard { @Input() set domain(value: DomainRo) { this._domain = value; - if (!!value) { - if (this.membershipType == MemberTypeEnum.DOMAIN) { + if (this.membershipType === MemberTypeEnum.DOMAIN) { this.loadMembershipData(); } - } else { - this.isLoadingResults = false; } } @@ -89,26 +87,22 @@ export class MembershipPanelComponent implements BeforeLeaveGuard { this._group = value; if (!!value) { - if (this.membershipType == MemberTypeEnum.GROUP) { + if (this.membershipType === MemberTypeEnum.GROUP) { this.loadMembershipData(); } - } else { - this.isLoadingResults = false; } } + get resource(): ResourceRo { return this._resource; } @Input() set resource(value: ResourceRo) { this._resource = value; - if (!!value) { if (this.membershipType == MemberTypeEnum.RESOURCE) { this.loadMembershipData(); } - } else { - this.isLoadingResults = false; } } @@ -155,7 +149,7 @@ export class MembershipPanelComponent implements BeforeLeaveGuard { } public refresh() { - if (this.paginator) { + if (!!this.paginator) { this.paginator.firstPage(); } this.loadMembershipData(); @@ -223,14 +217,15 @@ export class MembershipPanelComponent implements BeforeLeaveGuard { } protected getMembershipListService(): Observable<SearchTableResult> { + let page = this.paginator ? this.paginator.pageIndex : 0; + let pageSize = this.paginator ? this.paginator.pageSize : this.pageSize; switch (this.membershipType) { case MemberTypeEnum.DOMAIN: - - return !this._domain?null:this.membershipService.getDomainMembersObservable(this._domain.domainId, this.filter, this.paginator.pageIndex, this.paginator.pageSize); + return !this._domain ? null : this.membershipService.getDomainMembersObservable(this._domain.domainId, this.filter, page, pageSize); case MemberTypeEnum.GROUP: - return !this._group?null: this.membershipService.getGroupMembersObservable(this._group.groupId, this._domain.domainId, this.filter, this.paginator.pageIndex, this.paginator.pageSize); + return !this._group ? null : this.membershipService.getGroupMembersObservable(this._group.groupId, this._domain.domainId, this.filter, page, pageSize); case MemberTypeEnum.RESOURCE: - return !this._resource?null: this.membershipService.getResourceMembersObservable(this._resource, this._group, this._domain, this.filter, this.paginator.pageIndex, this.paginator.pageSize); + return !this._resource ? null : this.membershipService.getResourceMembersObservable(this._resource, this._group, this._domain, this.filter, page, pageSize); } } diff --git a/smp-angular/src/app/common/search-table/_search-table.component-theme.scss b/smp-angular/src/app/common/search-table/_search-table.component-theme.scss index 243ba2b6a756f1be881a214986688ca70dfc2243..64f3c933385221280f4f93b3152e5f3e5946364a 100644 --- a/smp-angular/src/app/common/search-table/_search-table.component-theme.scss +++ b/smp-angular/src/app/common/search-table/_search-table.component-theme.scss @@ -2,12 +2,19 @@ @mixin set-component-colors($theme) { .ngx-datatable .datatable-row-odd { - background-color: rgba(155, 155, 155, .1); } .ngx-datatable .datatable-header-cell { background-color: smp.get-theme-color($theme, primary, 800, 0.1) !important; } + + .ngx-datatable .datatable-row-selected { + background-color: red; + } + + .ngx-datatable .datatable-body-row:hover,.ngx-datatable .datatable-row-odd:hover { + background-color: smp.get-theme-color($theme, primary, 300) !important; + } } diff --git a/smp-angular/src/app/common/search-table/search-table.component.ts b/smp-angular/src/app/common/search-table/search-table.component.ts index b1d76afab9c262579ddc33983f652b1a6337b606..9c3d40ee403376c354f56810cec1e830e5ec0c02 100644 --- a/smp-angular/src/app/common/search-table/search-table.component.ts +++ b/smp-angular/src/app/common/search-table/search-table.component.ts @@ -17,7 +17,6 @@ import {ConfirmationDialogComponent} from "../dialogs/confirmation-dialog/confir import {SearchTableValidationResult} from "./search-table-validation-result.model"; import {ExtendedHttpClient} from "../../http/extended-http-client"; import {Router} from "@angular/router"; -import {authenticationGuard} from "../../guards/authentication.guard"; import ObjectUtils from "../utils/object-utils"; @Component({ @@ -138,6 +137,7 @@ export class SearchTableComponent implements OnInit { getRowClass(row) { return { + 'datatable-row-selected': (this.selected && this.selected.length >= 0 && this.rows.indexOf(row) === this.rowNumber), 'table-row-new': (row.status === EntityStatus.NEW), 'table-row-updated': (row.status === EntityStatus.UPDATED), 'deleted': (row.status === EntityStatus.REMOVED) @@ -253,9 +253,7 @@ export class SearchTableComponent implements OnInit { formRef.afterClosed().subscribe(result => { if (result) { this.rows = [...this.rows, {...formRef.componentInstance.getCurrent()}]; - //this.rows = this.rows.concat(formRef.componentInstance.current); this.count++; - // this.searchable.refresh(); } else { this.unselectRows(); } @@ -291,14 +289,10 @@ export class SearchTableComponent implements OnInit { try { this.dialog.open(SaveDialogComponent).afterClosed().subscribe(result => { if (result) { - // this.unselectRows(); const modifiedRowEntities = this.rows.filter(el => el.status !== EntityStatus.PERSISTED); - // this.isBusy = true; this.showSpinner = true; this.http.put(this.managementUrl, modifiedRowEntities).toPromise().then(res => { this.showSpinner = false; - // this.isBusy = false; - // this.getUsers(); this.alertService.success('The operation \'update\' completed successfully.', false); this.forceRefresh = true; this.onRefresh(); diff --git a/smp-angular/src/app/edit/edit-domain/domain-group-panel/group-dialog/group-dialog.component.ts b/smp-angular/src/app/edit/edit-domain/domain-group-panel/group-dialog/group-dialog.component.ts index fc30e583eae256197ea616cce1ec45424ceaf00a..90f6cfd072d97c585e6f113da4fd609972eaa851 100644 --- a/smp-angular/src/app/edit/edit-domain/domain-group-panel/group-dialog/group-dialog.component.ts +++ b/smp-angular/src/app/edit/edit-domain/domain-group-panel/group-dialog/group-dialog.component.ts @@ -15,7 +15,7 @@ import {EditDomainService} from "../../edit-domain.service"; export class GroupDialogComponent { readonly groupVisibilityOptions = Object.keys(VisibilityEnum) - .filter(el => el !== "Private").map(el => { + .map(el => { return {key: el, value: VisibilityEnum[el]} }); formTitle = "Group dialog"; diff --git a/smp-angular/src/app/edit/edit-group/group-resource-panel/resource-dialog/resource-dialog.component.ts b/smp-angular/src/app/edit/edit-group/group-resource-panel/resource-dialog/resource-dialog.component.ts index 1fc34f7c61523d43532495c683bea753be74c51f..f9c22cba5643b4df551f1ff37c9acfcc7eb0de41 100644 --- a/smp-angular/src/app/edit/edit-group/group-resource-panel/resource-dialog/resource-dialog.component.ts +++ b/smp-angular/src/app/edit/edit-group/group-resource-panel/resource-dialog/resource-dialog.component.ts @@ -17,7 +17,7 @@ import {EditGroupService} from "../../edit-group.service"; export class ResourceDialogComponent { readonly groupVisibilityOptions = Object.keys(VisibilityEnum) - .filter(el => el !== "Private").map(el => { + .map(el => { return {key: el, value: VisibilityEnum[el]} }); formTitle = "Resource dialog"; diff --git a/smp-angular/src/app/edit/edit-resources/resource-details-panel/resource-details-panel.component.ts b/smp-angular/src/app/edit/edit-resources/resource-details-panel/resource-details-panel.component.ts index f372d20860f859a6a212ba640ca7b3d41a3f4b19..c95ad7234b5f2e4264c70fff548f549a9f64706c 100644 --- a/smp-angular/src/app/edit/edit-resources/resource-details-panel/resource-details-panel.component.ts +++ b/smp-angular/src/app/edit/edit-resources/resource-details-panel/resource-details-panel.component.ts @@ -20,7 +20,7 @@ import {NavigationNode, NavigationService} from "../../../window/sidenav/navigat export class ResourceDetailsPanelComponent implements BeforeLeaveGuard { readonly groupVisibilityOptions = Object.keys(VisibilityEnum) - .filter(el => el !== "Private").map(el => { + .map(el => { return {key: el, value: VisibilityEnum[el]} }); diff --git a/smp-angular/src/app/system-settings/admin-domain/admin-domain.component.html b/smp-angular/src/app/system-settings/admin-domain/admin-domain.component.html index da072fe61d133c3b3c165ead00255584557b427d..153a1a5026ab5e8c478a74fdbfc037a65ff16902 100644 --- a/smp-angular/src/app/system-settings/admin-domain/admin-domain.component.html +++ b/smp-angular/src/app/system-settings/admin-domain/admin-domain.component.html @@ -4,10 +4,14 @@ text="System Domain administration panel is a tool for creating and removing domains from DomiSMP" [labelColumnContent]="searchDomainPanel"> - - <mat-tab-group #domainTabs style="height: 100%" > - <mat-tab > - <ng-template mat-tab-label><smp-label icon="domain" label="Domain data"></smp-label></ng-template> + <ng-template #noDataFound> + <div class="empty-data-panel">No domain selected.</div> + </ng-template> + <mat-tab-group #domainTabs style="height: 100%" *ngIf="selected;else noDataFound"> + <mat-tab> + <ng-template mat-tab-label> + <smp-label icon="domain" label="Domain data"></smp-label> + </ng-template> <domain-panel #domainPanelComponent [domain]="selected" [keystoreCertificates]="keystoreCertificates" @@ -17,28 +21,34 @@ ></domain-panel> </mat-tab> <mat-tab> - <ng-template mat-tab-label><smp-label icon="extension" label="Resource Types"></smp-label></ng-template> - <domain-resource-type-panel #domainResourceTypePanelComponent - [domain]="selected" - [domiSMPResourceDefinitions]="domiSMPResourceDefinitions" - (onSaveResourceTypesEvent)="onSaveResourceTypesEvent($event)" + <ng-template mat-tab-label> + <smp-label icon="extension" label="Resource Types"></smp-label> + </ng-template> + <domain-resource-type-panel #domainResourceTypePanelComponent + [domain]="selected" + [domiSMPResourceDefinitions]="domiSMPResourceDefinitions" + (onSaveResourceTypesEvent)="onSaveResourceTypesEvent($event)" ></domain-resource-type-panel> </mat-tab> - <mat-tab> - <ng-template mat-tab-label><smp-label icon="dns" label="SML integration"></smp-label></ng-template> - <domain-sml-integration-panel #domainSmlIntegrationPanelComponent - [keystoreCertificates]="keystoreCertificates" - [domain]="selected" - (onSaveSmlIntegrationDataEvent)="onSaveSmlIntegrationDataEvent($event)" - ></domain-sml-integration-panel> - </mat-tab> - <mat-tab label="Members"> - <ng-template mat-tab-label><smp-label icon="groups" label="Members"></smp-label></ng-template> + <mat-tab label="Members" > + <ng-template mat-tab-label> + <smp-label icon="groups" label="Members"></smp-label> + </ng-template> <domain-member-panel #domainMemberPanelComponent [membershipType]="membershipType" [domain]="selected" ></domain-member-panel> </mat-tab> + <mat-tab> + <ng-template mat-tab-label> + <smp-label icon="dns" label="SML integration"></smp-label> + </ng-template> + <domain-sml-integration-panel #domainSmlIntegrationPanelComponent + [keystoreCertificates]="keystoreCertificates" + [domain]="selected" + (onSaveSmlIntegrationDataEvent)="onSaveSmlIntegrationDataEvent($event)" + ></domain-sml-integration-panel> + </mat-tab> </mat-tab-group> </data-panel> </div> @@ -49,12 +59,12 @@ <input matInput (keyup)="applyDomainFilter($event)" placeholder="Domain code" #inputDomainFilter> </mat-form-field> - <mat-toolbar class ="mat-elevation-z2"> - <mat-toolbar-row class="smp-toolbar-row"> + <mat-toolbar class="mat-elevation-z2"> + <mat-toolbar-row class="smp-toolbar-row"> <button mat-raised-button mat-flat-button color="primary" (click)="onCreateDomainClicked()" - >Create domain + >Create domain </button> <button mat-raised-button @@ -75,7 +85,7 @@ <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-row *matRowDef="let odd = odd; let row; columns: displayedColumns;" (click)="domainSelected(row)" - [ngClass]="{'datatable-row-selected': row==selected,'datatable-row-odd': odd}" + [ngClass]="{'datatable-row-selected': row===selected,'datatable-row-odd': odd}" ></tr> @@ -89,7 +99,7 @@ </tr> </table> - <mat-paginator class="mat-elevation-z2" id="extension-paginator" + <mat-paginator class="mat-elevation-z2" id="domain-paginator" [hidePageSize]="true" [showFirstLastButtons]="true" [pageSize]="5" aria-label="Select page"></mat-paginator> diff --git a/smp-angular/src/app/system-settings/admin-domain/admin-domain.component.ts b/smp-angular/src/app/system-settings/admin-domain/admin-domain.component.ts index e81c0411379c73ee60379ca0666999a498715a0e..ca7330e57f7ae1bef439d22d2b34b08178d3abb6 100644 --- a/smp-angular/src/app/system-settings/admin-domain/admin-domain.component.ts +++ b/smp-angular/src/app/system-settings/admin-domain/admin-domain.component.ts @@ -28,7 +28,7 @@ import {MemberTypeEnum} from "../../common/enums/member-type.enum"; styleUrls: ['./admin-domain.component.css'] }) export class AdminDomainComponent implements OnInit, AfterViewInit, BeforeLeaveGuard { - membershipType:MemberTypeEnum = MemberTypeEnum.DOMAIN; + readonly membershipType:MemberTypeEnum = MemberTypeEnum.DOMAIN; displayedColumns: string[] = ['domainCode']; dataSource: MatTableDataSource<DomainRo> = new MatTableDataSource(); selected?: DomainRo; @@ -37,7 +37,7 @@ export class AdminDomainComponent implements OnInit, AfterViewInit, BeforeLeaveG domiSMPResourceDefinitions: ResourceDefinitionRo[] = []; currenTabIndex: number = 0; - handleTabClick; + handleTabClick = null; @ViewChild(MatPaginator) paginator: MatPaginator; @@ -104,6 +104,9 @@ export class AdminDomainComponent implements OnInit, AfterViewInit, BeforeLeaveG } registerTabClick(): void { + if (!this.domainTabs) { + return; + } // Get the handler reference this.handleTabClick = this.domainTabs._handleClick; @@ -189,8 +192,11 @@ export class AdminDomainComponent implements OnInit, AfterViewInit, BeforeLeaveG } onCreateDomainClicked() { - this.domainTabs.selectedIndex = 0; this.selected = this.newDomain(); + if ( !this.handleTabClick) { + this.registerTabClick(); + } + this.domainTabs.selectedIndex = 0; this.domainPanelComponent.setFocus(); } @@ -202,7 +208,6 @@ export class AdminDomainComponent implements OnInit, AfterViewInit, BeforeLeaveG smlSubdomain: '', smlSmpId: '', smlParticipantIdentifierRegExp: '', - smlClientCertHeader: '', smlClientKeyAlias: '', signatureKeyAlias: '', status: EntityStatus.NEW, @@ -250,7 +255,12 @@ export class AdminDomainComponent implements OnInit, AfterViewInit, BeforeLeaveG } public domainSelected(domainSelected: DomainRo) { - if (this.selected === domainSelected) { + if (domainSelected && !this.handleTabClick) { + this.registerTabClick(); + } + + + if (this.selected == domainSelected) { return; } if (this.isCurrentTabDirty()) { @@ -263,6 +273,8 @@ export class AdminDomainComponent implements OnInit, AfterViewInit, BeforeLeaveG } }); } else { + console.log("domain selected") + this.selected = domainSelected; } } @@ -306,7 +318,7 @@ export class AdminDomainComponent implements OnInit, AfterViewInit, BeforeLeaveG } get canNotDelete():boolean{ - return !this.selected || this.domainSmlIntegrationPanelComponent.isDomainRegistered || this.isNewDomain() + return !this.selected || this.domainSmlIntegrationPanelComponent?.isDomainRegistered || this.isNewDomain() } get editMode(): boolean { diff --git a/smp-angular/src/app/system-settings/admin-domain/domain-panel/domain-panel.component.ts b/smp-angular/src/app/system-settings/admin-domain/domain-panel/domain-panel.component.ts index 9f162913111fc9bda6c0eb03761173284e14a1ec..9dd2246e23eb9b41d18926b87e963b9f1af09208 100644 --- a/smp-angular/src/app/system-settings/admin-domain/domain-panel/domain-panel.component.ts +++ b/smp-angular/src/app/system-settings/admin-domain/domain-panel/domain-panel.component.ts @@ -21,7 +21,7 @@ export class DomainPanelComponent implements BeforeLeaveGuard { readonly warningTimeout: number = 50000; readonly domainCodePattern = '^[a-zA-Z0-9]{1,63}$'; readonly domainVisibilityOptions = Object.keys(VisibilityEnum) - .filter(el => el !== "Private").map(el => { + .map(el => { return {key: el, value: VisibilityEnum[el]} }); diff --git a/smp-angular/src/app/system-settings/admin-domain/domain-sml-panel/domain-sml-integration-panel.component.html b/smp-angular/src/app/system-settings/admin-domain/domain-sml-panel/domain-sml-integration-panel.component.html index 6d91319ba1dfa01e7f0b629e97b499b0f284b84f..8d3d5f4bc3cbddb3595dc39b44923d589ffa5dd2 100644 --- a/smp-angular/src/app/system-settings/admin-domain/domain-sml-panel/domain-sml-integration-panel.component.html +++ b/smp-angular/src/app/system-settings/admin-domain/domain-sml-panel/domain-sml-integration-panel.component.html @@ -72,7 +72,7 @@ <mat-label>SML Client Certificate Alias</mat-label> <mat-select placeholder="SML ClientCert Alias" - formControlName="smlClientKeyCertificate" + formControlName="smlClientKeyAlias" id="smlClientKeyAlias_id"> <mat-option [value]="''">Choose certificate for signing soap response</mat-option> <mat-option *ngFor="let cert of keystoreCertificates" [value]="cert.alias"> diff --git a/smp-angular/src/app/system-settings/admin-domain/domain-sml-panel/domain-sml-integration-panel.component.ts b/smp-angular/src/app/system-settings/admin-domain/domain-sml-panel/domain-sml-integration-panel.component.ts index 6bfa7a7099ccc3fba03d23e89dc78f5f269ef2c8..e88054430f2840fac33c13a186e680d4833e3cd3 100644 --- a/smp-angular/src/app/system-settings/admin-domain/domain-sml-panel/domain-sml-integration-panel.component.ts +++ b/smp-angular/src/app/system-settings/admin-domain/domain-sml-panel/domain-sml-integration-panel.component.ts @@ -81,7 +81,6 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard { disabled: this.isDomainRegistered }, [Validators.pattern(this.smpIdDomainPattern), this.notInList(this.lookups.cachedDomainList.map(a => a.smlSmpId), this._domain?.smlSmpId)]), - 'smlClientCertHeader': new FormControl({value: '', readonly: true}), 'smlClientKeyAlias': new FormControl({value: '', readonly: true}), 'smlClientCertAuth': new FormControl({value: '', readonly: true}), 'smlClientKeyCertificate': new FormControl({value: '', readonly: true}), @@ -96,7 +95,6 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard { newDomain.smlSubdomain = this.domainForm.get('smlSubdomain').value; newDomain.smlSmpId = this.domainForm.get('smlSmpId').value; newDomain.smlClientKeyAlias = this.domainForm.get('smlClientKeyAlias').value; - newDomain.smlClientCertHeader = this.domainForm.get('smlClientCertHeader').value; newDomain.smlClientCertAuth = this.domainForm.get('smlClientCertAuth').value; return newDomain; } @@ -107,15 +105,16 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard { this.domainForm.controls['smlSubdomain'].setValue(this._domain.smlSubdomain); this.domainForm.controls['smlSmpId'].setValue(this._domain.smlSmpId); this.domainForm.controls['smlClientKeyAlias'].setValue(this._domain.smlClientKeyAlias); - this.domainForm.controls['smlClientCertHeader'].setValue(this._domain.smlClientCertHeader); this.domainForm.controls['smlRegistered'].setValue(this._domain.smlRegistered); this.domainForm.controls['smlClientCertAuth'].setValue(this._domain.smlClientCertAuth); this.domainForm.enable(); + if (this.isDomainRegistered) { + this.domainForm.controls['smlSmpId'].disable() + } } else { this.domainForm.controls['smlSubdomain'].setValue(""); this.domainForm.controls['smlSmpId'].setValue(""); this.domainForm.controls['smlClientKeyAlias'].setValue(""); - this.domainForm.controls['smlClientCertHeader'].setValue(""); this.domainForm.controls['smlRegistered'].setValue(""); this.domainForm.controls['smlClientCertAuth'].setValue(""); this.domainForm.disable(); @@ -156,14 +155,12 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard { return false; } - if (!this._domain.smlClientCertHeader && this._domain.smlClientCertAuth) { - return false; - } - if (!this._domain.smlClientKeyAlias && !this._domain.smlClientCertAuth) { + if (!this._domain.smlClientKeyAlias ) { + console.log("enableSMLRegister 4") return false; } - - // entity must be first persisted in order to be enabled to registering to SML + console.log("enableSMLRegister 5") + // entity must be first persisted in order to be enabled to register to SML return !this._domain.smlRegistered; } @@ -172,9 +169,6 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard { return false; } - if (this._domain.smlClientCertHeader && this._domain.smlClientCertAuth) { - return false; - } if (!this._domain.smlClientKeyAlias && !this._domain.smlClientCertAuth) { return false; } @@ -183,7 +177,7 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard { return this.isDomainRegistered; } - get isDomainRegistered() { + get isDomainRegistered():boolean { return this._domain?.smlRegistered; } @@ -196,7 +190,7 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard { this.dialog.open(ConfirmationDialogComponent, { data: { title: "Unregister domain to SML", - description: "Action will unregister domain: " + this._domain + " and all its resources from SML. Do you wish to continue?" + description: "Action will unregister domain: [" + this._domain?.domainCode + "] and all its resources from SML. Do you wish to continue?" } }).afterClosed().subscribe(result => { if (result) { @@ -213,7 +207,7 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard { this.dialog.open(ConfirmationDialogComponent, { data: { title: "Register domain to SML", - description: "Action will register domain: " + this._domain + " and all its service groups to SML. Do you wish to continue?" + description: "Action will register domain: [" + this._domain?.domainCode + "] and all its service groups to SML. Do you wish to continue?" } }).afterClosed().subscribe(result => { if (result) { @@ -229,9 +223,10 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard { // this.searchTable.showSpinner = false; if (res) { if (res.success) { - this.alertService.success("Domain " + domain.domainCode + " registered to sml!"); + this.alertService.success("Domain [" + domain.domainCode + "] registered to sml!"); this.lookups.refreshDomainLookupForLoggedUser(); domain.smlRegistered = true; + this.domain = domain; } else { this.alertService.exception('Error occurred while registering domain:' + domain.domainCode, res.errorMessage); } @@ -252,9 +247,10 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard { // this.searchTable.showSpinner = false; if (res) { if (res.success) { - this.alertService.success("Domain " + domain.domainCode + " unregistered from sml!"); + this.alertService.success("Domain [" + domain.domainCode + "] unregistered from sml!"); this.lookups.refreshDomainLookupForLoggedUser(); domain.smlRegistered = false; + this.domain = domain; } else { this.alertService.exception('Error occurred while unregistering domain:' + domain.domainCode, res.errorMessage); } diff --git a/smp-angular/src/app/system-settings/admin-extension/extension.component.html b/smp-angular/src/app/system-settings/admin-extension/extension.component.html index 18eb0dc4c588ad2554160fb4b4f1a6d2dd38f0aa..d55cc075ee45a7756afdd278f64d5e45f2a8eedc 100644 --- a/smp-angular/src/app/system-settings/admin-extension/extension.component.html +++ b/smp-angular/src/app/system-settings/admin-extension/extension.component.html @@ -4,7 +4,10 @@ text="Registered DomiSMP extensions. <br /> DomiSMP supports document types via custom designed extension. The extensions implements tools for validating and generating the resources and subresources. <br /> Extensions can also implement custom logic for the payload scaning eg. virus detections. " [labelColumnContent]="searchExtensionPanel"> - <extension-panel [extension]="selected"></extension-panel> + <ng-template #noDataFound> + <div class="empty-data-panel">No extension selected.</div> + </ng-template> + <extension-panel [extension]="selected" *ngIf="selected;else noDataFound "></extension-panel> </data-panel> </div> 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 9ddb1187429d2d3704fb01185c557eae3a208ab7..359bdbcd77c56bb43a4c36d7ec8a528d5ec6bace 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 @@ -3,8 +3,10 @@ title="Keystore administration" text="Keystore is contains keys for singing responses and Client keys for SML integrations ." [labelColumnContent]="searchKeyCertificatePanel"> - - <certificate-panel [certificate]="selected"></certificate-panel> + <ng-template #noDataFound> + <div class="empty-data-panel">No certificate selected.</div> + </ng-template> + <certificate-panel [certificate]="selected" *ngIf="selected;else noDataFound"></certificate-panel> </data-panel> </div> diff --git a/smp-angular/src/app/system-settings/admin-truststore/admin-truststore.component.html b/smp-angular/src/app/system-settings/admin-truststore/admin-truststore.component.html index 348eda464a0533c817769a68ac16aee9db302fa6..d5b1cd91280587dacef5c32e7a2945821b7c21e2 100644 --- a/smp-angular/src/app/system-settings/admin-truststore/admin-truststore.component.html +++ b/smp-angular/src/app/system-settings/admin-truststore/admin-truststore.component.html @@ -3,8 +3,10 @@ title="Truststore administration" text="Truststore is contains certificate trust anchors. <br /> Certificates used for authentication must have trust anchors in the truststore." [labelColumnContent]="searchCertificatePanel"> - - <certificate-panel [certificate]="selected"></certificate-panel> + <ng-template #noDataFound> + <div class="empty-data-panel">No certificate selected.</div> + </ng-template> + <certificate-panel [certificate]="selected" *ngIf="selected; else noDataFound"></certificate-panel> </data-panel> </div> diff --git a/smp-angular/src/app/system-settings/admin-users/admin-user.component.html b/smp-angular/src/app/system-settings/admin-users/admin-user.component.html index ea2c1b30715c302a98892c8a08e82c8dc7dfe5ea..60b434d8950dda2eef2e0597a025302c18021960 100644 --- a/smp-angular/src/app/system-settings/admin-users/admin-user.component.html +++ b/smp-angular/src/app/system-settings/admin-users/admin-user.component.html @@ -3,7 +3,10 @@ title="System User administration" text="System User administration panel is a tool for creating and removing users from DomiSMP" [labelColumnContent]="searchUserPanel"> - <user-profile-panel + <ng-template #noDataFound> + <div class="empty-data-panel">No user selected.</div> + </ng-template> + <user-profile-panel *ngIf="managedUserData;else noDataFound" [showDataPanelTitles] =false [managedUserData]="managedUserData" (onSaveUserEvent)="onSaveUserEvent($event)" @@ -67,8 +70,8 @@ <mat-paginator class="mat-elevation-z2" id="extension-paginator" [length]="resultsLength" (page)="onPageChanged($event)" - [pageSize]="5" - [pageSizeOptions]="[5, 10, 25]" + [hidePageSize]="true" + [pageSize]="10" [showFirstLastButtons]="true" aria-label="Select page"></mat-paginator> </ng-template> diff --git a/smp-angular/src/app/system-settings/domain/domain-controller.ts b/smp-angular/src/app/system-settings/domain/domain-controller.ts index adc45188d723aa7416c8d8468efdbb035d402843..7f333c67e9f43d205ed88d377f27f06ded9f2b4d 100644 --- a/smp-angular/src/app/system-settings/domain/domain-controller.ts +++ b/smp-angular/src/app/system-settings/domain/domain-controller.ts @@ -39,7 +39,6 @@ export class DomainController implements SearchTableController { smlSubdomain: '', smlSmpId: '', smlParticipantIdentifierRegExp: '', - smlClientCertHeader: '', smlClientKeyAlias: '', signatureKeyAlias: '', status: EntityStatus.NEW, diff --git a/smp-angular/src/app/system-settings/domain/domain-details-dialog/domain-details-dialog.component.ts b/smp-angular/src/app/system-settings/domain/domain-details-dialog/domain-details-dialog.component.ts index 917a7e38af62e81dbaccf40277fd5cb36f7e2c9e..8af1638bde7855604aefe4a2b144d162871f150e 100644 --- a/smp-angular/src/app/system-settings/domain/domain-details-dialog/domain-details-dialog.component.ts +++ b/smp-angular/src/app/system-settings/domain/domain-details-dialog/domain-details-dialog.component.ts @@ -81,7 +81,6 @@ export class DomainDetailsDialogComponent { this.notInList(this.lookups.cachedDomainList.map(a => a.smlSubdomain), this.current.smlSubdomain)]), 'smlSmpId': new UntypedFormControl({value: ''}, [Validators.pattern(this.smpIdDomainPattern), this.notInList(this.lookups.cachedDomainList.map(a => a.smlSmpId), this.current.smlSmpId)]), - 'smlClientCertHeader': new UntypedFormControl({value: ''}, null), 'smlClientKeyAlias': new UntypedFormControl({value: ''}, null), 'smlClientKeyCertificate': new UntypedFormControl({value: this.selectedSMLCert}, null), 'signatureKeyAlias': new UntypedFormControl({value: ''}, null), @@ -95,7 +94,6 @@ export class DomainDetailsDialogComponent { this.domainForm.controls['smlSmpId'].setValue(this.current.smlSmpId); this.domainForm.controls['smlClientKeyAlias'].setValue(this.current.smlClientKeyAlias); - this.domainForm.controls['smlClientCertHeader'].setValue(this.current.smlClientCertHeader); this.domainForm.controls['signatureKeyAlias'].setValue(this.current.signatureKeyAlias); this.domainForm.controls['smlRegistered'].setValue(this.current.smlRegistered); @@ -164,13 +162,10 @@ export class DomainDetailsDialogComponent { this.current.smlSubdomain = this.domainForm.value['smlSubdomain']; } this.current.smlSmpId = this.domainForm.value['smlSmpId']; - this.current.smlClientCertHeader = this.domainForm.value['smlClientCertHeader']; if (this.domainForm.value['smlClientKeyCertificate']) { this.current.smlClientKeyAlias = this.domainForm.value['smlClientKeyCertificate'].alias; - this.current.smlClientCertHeader = this.domainForm.value['smlClientKeyCertificate'].clientCertHeader; } else { this.current.smlClientKeyAlias = ''; - this.current.smlClientCertHeader = ''; } this.current.signatureKeyAlias = this.domainForm.value['signatureKeyAlias']; this.current.smlClientCertAuth = this.domainForm.value['smlClientCertAuth']; diff --git a/smp-angular/src/app/system-settings/domain/domain.component.ts b/smp-angular/src/app/system-settings/domain/domain.component.ts index e52fe0804a0bf0c13718f5cdfca262931b78482e..e1dba178a5cb9d61b545eedee8f96eaf34571119 100644 --- a/smp-angular/src/app/system-settings/domain/domain.component.ts +++ b/smp-angular/src/app/system-settings/domain/domain.component.ts @@ -168,7 +168,7 @@ export class DomainComponent implements OnInit, AfterViewInit, AfterViewChecked msg = "The domain should have a defined signature CertAlias." } if (this.lookups.cachedApplicationConfig.smlIntegrationOn) { - if (!domain.smlSmpId || !domain.smlClientCertHeader) { + if (!domain.smlSmpId || !domain.smlClientKeyAlias) { msg = (!msg ? "" : msg + " ") + "For SML integration the SMP SMP ID and SML client certificate must be defined!" } } @@ -194,9 +194,6 @@ export class DomainComponent implements OnInit, AfterViewInit, AfterViewChecked } let domainRo = (this.searchTable.selected[0] as DomainRo); - if (!domainRo.smlClientCertHeader && domainRo.smlClientCertAuth) { - return false; - } if (!domainRo.smlClientKeyAlias && !domainRo.smlClientCertAuth) { return false; } @@ -214,9 +211,6 @@ export class DomainComponent implements OnInit, AfterViewInit, AfterViewChecked } let domainRo = (this.searchTable.selected[0] as DomainRo); - if (!domainRo.smlClientCertHeader && domainRo.smlClientCertAuth) { - return false; - } if (!domainRo.smlClientKeyAlias && !domainRo.smlClientCertAuth) { return false; } diff --git a/smp-angular/src/styles.css b/smp-angular/src/styles.css index 9ca7647088300bb3e67ebef4905dd5aa7a1a523d..460b942348bfa6cfee7de2187384836649b8370e 100644 --- a/smp-angular/src/styles.css +++ b/smp-angular/src/styles.css @@ -205,7 +205,12 @@ a:hover { box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 1px 2px 0 rgba(0, 0, 0, 0.24); } +.empty-data-panel { + margin-bottom: 10px; + padding: 10px; + box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 1px 2px 0 rgba(0, 0, 0, 0.24); +} .smp-toolbar-row { display: flex; diff --git a/smp-docker/compose/tomcat-mysql-smp-sml/properties/db-scripts/sml-mysql5innodb-data.sql b/smp-docker/compose/tomcat-mysql-smp-sml/properties/db-scripts/sml-mysql5innodb-data.sql index 2392d6d40cca7b2743f24ea9dbd9d9e271f91910..7b6b00682297623b2a335cd6bc57d7f281a90768 100644 --- a/smp-docker/compose/tomcat-mysql-smp-sml/properties/db-scripts/sml-mysql5innodb-data.sql +++ b/smp-docker/compose/tomcat-mysql-smp-sml/properties/db-scripts/sml-mysql5innodb-data.sql @@ -23,7 +23,7 @@ insert into bdmsl_configuration(property, value, description, created_on, last_u ('configurationDir','/opt/smlconf/','The absolute path to the folder containing all the configuration files (keystore and sig0 key)', NOW(), NOW()), ('certificateChangeCronExpression','0 0 2 ? * *','Cron expression for the changeCertificate job. Example: 0 0 2 ? * * (everyday at 2:00 am)', NOW(), NOW()), ('authorization.smp.certSubjectRegex','^.*(CN=SMP_|OU=PEPPOL TEST SMP).*$','User with ROOT-CA is granted SMP_ROLE only if its certificates Subject matches configured regexp', NOW(), NOW()), -('smp.automation.authentication.external.tls.clientCert.enabled','true','Enables reverse proxy authentication.', NOW(), NOW()), +('authentication.bluecoat.enabled','true','Enables reverse proxy authentication.', NOW(), NOW()), ('adminPassword','$2a$10$9RzbkquhBYRkHUoKMTNZhOPJmevTbUKWf549MEiCWUd.1LdblMhBi','BCrypt Hashed password to access admin services', NOW(), NOW()), ('mail.smtp.host','smtp.localhost','BCrypt Hashed password to access admin services', NOW(), NOW()), ('mail.smtp.port','25','BCrypt Hashed password to access admin services', NOW(), NOW()), diff --git a/smp-docker/images/build-docker-images.sh b/smp-docker/images/build-docker-images.sh index b90fce6b2b41a07a432b6e4f486e019ff7c8f762..7893de78151867b422cab249f9199db56aa0d1ec 100755 --- a/smp-docker/images/build-docker-images.sh +++ b/smp-docker/images/build-docker-images.sh @@ -165,6 +165,9 @@ validateAndPrepareArtefacts() { exit 1 else # copy artefact to docker build folder + cp -r shared-artefacts ./weblogic-12.2-smp/artefacts/ + cp -r shared-artefacts ./weblogic-14.1-smp/artefacts/ + cp -r shared-artefacts ./tomcat-mysql-smp-sml/artefacts/ # for weblogic cp "${SMP_ARTEFACTS}/smp.war" ./weblogic-12.2-smp/artefacts/smp.war cp "${SMP_ARTEFACTS}/smp.war" ./weblogic-14.1-smp/artefacts/smp.war @@ -196,9 +199,9 @@ validateAndPrepareArtefacts() { # build docker images # ----------------------------------------------------------------------------- buildImages() { - buildOracleDatabaseImage - buildWebLogicOracleImages12 - buildWebLogicOracleImages14 + #buildOracleDatabaseImage + #buildWebLogicOracleImages12 + #buildWebLogicOracleImages14 buildTomcatMysqlImages buildUtils } diff --git a/smp-docker/images/shared-artefacts/README.md b/smp-docker/images/shared-artefacts/README.md new file mode 100644 index 0000000000000000000000000000000000000000..eb736c87265d9dea6f48aa298de6b5f5b531f949 --- /dev/null +++ b/smp-docker/images/shared-artefacts/README.md @@ -0,0 +1,11 @@ +The SMP keystore and SML truststore are needed for SMP/SML integration. + - [sml-truststore.p12](sml-truststore.p12) + - [smp-keystore-docker.p12](smp-keystore-docker.p12) + +The smp certificates + - CN=smp_domain_01,OU=edelivery,O=digit,C=eu + - CN=smp_domain_02,OU=edelivery,O=digit,C=eu +are registered in SML as trusted certificates for domains + - domain-01.test.edelivery.local + - domain-02.test.edelivery.local +For detailed DomiSML configuration see the SML init script:[sml-mysql5innodb-data.sql](sml-mysql5innodb-data.sql) diff --git a/smp-docker/images/shared-artefacts/sml-mysql5innodb-data.sql b/smp-docker/images/shared-artefacts/sml-mysql5innodb-data.sql new file mode 100644 index 0000000000000000000000000000000000000000..886595706018257a30380428c0461636d1c8590b --- /dev/null +++ b/smp-docker/images/shared-artefacts/sml-mysql5innodb-data.sql @@ -0,0 +1,41 @@ +insert into bdmsl_configuration(property, value, description, created_on, last_updated_on) values +('useProxy','false','true if a proxy is required to connect to the internet. Possible values: true/false', NOW(), NOW()), +('unsecureLoginAllowed','false','true if the use of HTTPS is not required. If the value is set to true, then the user unsecure-http-client is automatically created. Possible values: true/false', NOW(), NOW()), +('signResponse','false','true if the responses must be signed. Possible values: true/false', NOW(), NOW()), +('paginationListRequest','100','Number of participants per page for the list operation of ManageParticipantIdentifier service. This property is used for pagination purposes.', NOW(), NOW()), +('keystorePassword','vXA7JjCy0iDQmX1UEN1Qwg==','Base64 encrypted password for Keystore.', NOW(), NOW()), +('keystoreFileName','keystore.jks','The JKS keystore file. Should be just the filename if the file is in the classpath or in the configurationDir', NOW(), NOW()), +('keystoreAlias','sendercn','The signing certificate alias in the keystore.', NOW(), NOW()), +('truststorePassword','vXA7JjCy0iDQmX1UEN1Qwg==','Base64 encrypted password for Keystore.', NOW(), NOW()), +('truststoreFileName','sml-truststore-docker-demo.p12','The JKS keystore file. Should be just the filename if the file is in the classpath or in the configurationDir', NOW(), NOW()), +('httpProxyUser','user','The proxy user', NOW(), NOW()), +('httpProxyPort','80','The http proxy port', NOW(), NOW()), +('httpProxyPassword','setencPasswd','Base64 encrypted password for Proxy.', NOW(), NOW()), +('httpProxyHost','127.0.0.1','The http proxy host', NOW(), NOW()), +('encriptionPrivateKey','encriptionPrivateKey.private','Name of the 256 bit AES secret key to encrypt or decrypt passwords.', NOW(), NOW()), +('dnsClient.server','127.0.0.1','The DNS server', NOW(), NOW()), +('dnsClient.publisherPrefix','publisher','This is the prefix for the publishers (SMP). This is to be concatenated with the associated DNS domain in the table bdmsl_certificate_domain', NOW(), NOW()), +('dnsClient.enabled','true','true if registration of DNS records is required. Must be true in production. Possible values: true/false', NOW(), NOW()), +('dnsClient.show.entries','true','if true than service ListDNS transfer and show the DNS entries. (Not recommended for large zones) Possible VALUES: true/false', NOW(), NOW()), +('dnsClient.SIG0PublicKeyName','sig0.test.edelivery.local.','The public key name of the SIG0 key', NOW(), NOW()), +('dnsClient.SIG0KeyFileName','SIG0.private','The actual SIG0 key file. Should be just the filename if the file is in the classpath or in the configurationDir', NOW(), NOW()), +('dnsClient.SIG0Enabled','false','true if the SIG0 signing is enabled. Required fr DNSSEC. Possible values: true/false', NOW(), NOW()), +('dataInconsistencyAnalyzer.senderEmail','automated-notifications@nomail.ec.europa.eu','Sender email address for reporting Data Inconsistency Analyzer.', NOW(), NOW()), +('dataInconsistencyAnalyzer.recipientEmail','email@domain.com','Email address to receive Data Inconsistency Checker results', NOW(), NOW()), +('dataInconsistencyAnalyzer.cronJobExpression','0 0 3 ? * *','Cron expression for dataInconsistencyChecker job. Example: 0 0 3 ? * * (everyday at 3:00 am)', NOW(), NOW()), +('configurationDir','/opt/smlconf/','The absolute path to the folder containing all the configuration files (keystore and sig0 key)', NOW(), NOW()), +('certificateChangeCronExpression','0 0 2 ? * *','Cron expression for the changeCertificate job. Example: 0 0 2 ? * * (everyday at 2:00 am)', NOW(), NOW()), +('authorization.smp.certSubjectRegex','^.*(CN=smp_|CN=SMP_|OU=PEPPOL TEST SMP).*$','User with ROOT-CA is granted SMP_ROLE only if its certificates Subject matches configured regexp', NOW(), NOW()), +('authentication.bluecoat.enabled','true','Enables reverse proxy authentication. with CLient-Cert header', NOW(), NOW()), +('authentication.sslclientcert.enabled','true','Enables reverse proxy authentication with SSLCLientCert header.', NOW(), NOW()), +('sml.property.refresh.cronJobExpression','5 */1 * * * *','Properies update', NOW(), NOW()); + + +insert into bdmsl_subdomain(subdomain_id, subdomain_name,dns_zone, description, participant_id_regexp, dns_record_types, smp_url_schemas, created_on, last_updated_on) values +(1, 'domain-01.test.edelivery.local','test.edelivery.local','Domain for no trestriction ','^.*$','all','all', NOW(), NOW()), +(2, 'domain-02.test.edelivery.local', 'test.edelivery.local','Domain for with party id restriction', '^((((0002|0007|0009|0037|0060|0088|0096|0097|0106|0135|0142|9901|9902|9904|9905|9906|9907|9908|9909|9910|9912|9913|9914|9915|9916|9917|9918|9919|9920|9921|9922|9923|9924|9925|9926|9927|9928|9929|9930|9931|9932|9933|9934|9935|9936|9937|9938|9939|9940|9941|9942|9943|9944|9945|9946|9947|9948|9949|9950|9951|9952|9953|9954|9955|9956|9957|0184):).*)|(\\*))$','all','all', NOW(), NOW()); + + +INSERT INTO bdmsl_certificate_domain(truststore_alias, certificate, crl_url, is_root_ca, fk_subdomain_id, created_on, last_updated_on, is_admin) VALUES +('CN=smp_domain_01', 'CN=smp_domain_01,O=digit,C=eu','',0, 1, NOW(), NOW(),1), +('CN=smp_domain_02','CN=smp_domain_02,O=digit,C=eu','',0, 2, NOW(), NOW(),1); diff --git a/smp-docker/images/shared-artefacts/sml-truststore-docker-demo.p12 b/smp-docker/images/shared-artefacts/sml-truststore-docker-demo.p12 new file mode 100644 index 0000000000000000000000000000000000000000..82789e63c8915a4740b6b9fc65578e4187621231 Binary files /dev/null and b/smp-docker/images/shared-artefacts/sml-truststore-docker-demo.p12 differ diff --git a/smp-docker/images/shared-artefacts/smp-keystore-docker-demo.p12 b/smp-docker/images/shared-artefacts/smp-keystore-docker-demo.p12 new file mode 100644 index 0000000000000000000000000000000000000000..b98490ab6f55a61121fd59f5911cbb32556aadd2 Binary files /dev/null and b/smp-docker/images/shared-artefacts/smp-keystore-docker-demo.p12 differ diff --git a/smp-docker/images/tomcat-mysql-smp-sml/entrypoint.sh b/smp-docker/images/tomcat-mysql-smp-sml/entrypoint.sh index 3a197d7af553a4fce02689841d93468cb1cd92ac..b64cd3de65e45b7602243a238657f3243653b895 100755 --- a/smp-docker/images/tomcat-mysql-smp-sml/entrypoint.sh +++ b/smp-docker/images/tomcat-mysql-smp-sml/entrypoint.sh @@ -18,9 +18,8 @@ TOMCAT_DIR=${DATA_DIR}/tomcat TOMCAT_HOME=${SMP_HOME}/apache-tomcat-$TOMCAT_VERSION/ BIND_DATA_DIR=${DATA_DIR}/bind - if [ ! -d ${DATA_DIR} ]; then - mkdir -p ${DATA_DIR} + mkdir -p ${DATA_DIR} fi init_tomcat() { @@ -36,20 +35,18 @@ init_tomcat() { JAVA_OPTS="$JAVA_OPTS -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true -Djdk.http.auth.tunneling.disabledSchemes=" # add truststore for eulogin if [ -e /tmp/keystores/smp-eulogin-mock.p12 ]; then - echo "add eulogin trustStore: /tmp/keystores/smp-eulogin-mock.p12" - JAVA_OPTS="$JAVA_OPTS -Djavax.net.ssl.trustStore=/tmp/keystores/smp-eulogin-mock.p12 -Djavax.net.ssl.trustStoreType=PKCS12 -Djavax.net.ssl.trustStorePassword=test123" + echo "add eulogin trustStore: /tmp/keystores/smp-eulogin-mock.p12" + JAVA_OPTS="$JAVA_OPTS -Djavax.net.ssl.trustStore=/tmp/keystores/smp-eulogin-mock.p12 -Djavax.net.ssl.trustStoreType=PKCS12 -Djavax.net.ssl.trustStorePassword=test123" fi - # add external extensions + # add external extensions for extensionLibFile in /tmp/artefacts/*.jar; do # Check if the glob gets expanded to existing files. - [ -e "$extensionLibFile" ] && mv $extensionLibFile $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/smp-libs || echo "Extensions do not exist" + [ -e "$extensionLibFile" ] && mv $extensionLibFile $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/smp-libs || echo "Extensions do not exist" done - echo "[INFO] init tomcat JAVA_OPTS: $JAVA_OPTS" - export JAVA_OPTS - + export JAVA_OPTS echo "[INFO] init tomcat folders: $tfile" if [ ! -d ${TOMCAT_DIR} ]; then @@ -58,21 +55,21 @@ init_tomcat() { # move tomcat log folder to data folder if [ ! -d ${TOMCAT_DIR}/logs ]; then - if [ ! -d ${TOMCAT_HOME}/logs ]; then + if [ ! -d ${TOMCAT_HOME}/logs ]; then mkdir -p ${TOMCAT_DIR}/logs - else + else mv ${TOMCAT_HOME}/logs ${TOMCAT_DIR}/ - rm -rf ${TOMCAT_HOME}/logs + rm -rf ${TOMCAT_HOME}/logs fi fi - rm -rf ${TOMCAT_HOME}/logs + rm -rf ${TOMCAT_HOME}/logs ln -sf ${TOMCAT_DIR}/logs ${TOMCAT_HOME}/logs # move tomcat conf folder to data folder if [ ! -d ${TOMCAT_DIR}/conf ]; then - mv ${TOMCAT_HOME}/conf ${TOMCAT_DIR}/ + mv ${TOMCAT_HOME}/conf ${TOMCAT_DIR}/ fi - rm -rf ${TOMCAT_HOME}/conf + rm -rf ${TOMCAT_HOME}/conf ln -sf ${TOMCAT_DIR}/conf ${TOMCAT_HOME}/conf # move smp conf folder to data folder @@ -81,29 +78,13 @@ init_tomcat() { fi rm -rf ${TOMCAT_HOME}/classes ln -sf ${TOMCAT_DIR}/classes ${TOMCAT_HOME}/ + # set smp data/security folder + mkdir ${DATA_DIR}/smp/ - # sleep a little to avoid mv issues - sleep 5s -} - -init_smp_properties() { - echo "[INFO] init smp properties:" - - { echo "# SMP init parameters" - echo "smp.libraries.folder=$SMP_HOME/apache-tomcat-$TOMCAT_VERSION/smp-libs" - echo "bdmsl.integration.logical.address=${SMP_LOGICAL_ADDRESS:-http://localhost:8080/smp/}" - echo "smp.automation.authentication.external.tls.clientCert.enabled=true" - echo "bdmsl.integration.enabled=true" - echo "bdmsl.integration.physical.address=0.0.0.0" - echo "bdmsl.participant.multidomain.enabled=false" - echo "bdmsl.integration.url=http://localhost:8080/edelivery-sml/" - echo "bdmsl.integration.logical.address=${SMP_LOGICAL_ADDRESS:-http://localhost:8080/smp/}" - } >> "$SMP_HOME/apache-tomcat-$TOMCAT_VERSION/classes/smp.config.properties" - - addOrReplaceProperties "$SMP_HOME/apache-tomcat-$TOMCAT_VERSION/classes/smp.config.properties" "$SMP_INIT_PROPERTIES" "$SMP_INIT_PROPERTY_DELIMITER" + # sleep a little to avoid mv issues + sleep 5s } - init_mysql() { echo "[INFO] init database:" if [ ! -d "/run/mysqld" ]; then @@ -116,7 +97,7 @@ init_mysql() { sleep 3s mv /var/lib/mysql ${DATA_DIR} fi - + rm -rf /var/lib/mysql ln -sf ${MYSQL_DATA_DIR} /var/lib/mysql chmod -R 0777 ${MYSQL_DATA_DIR} @@ -124,36 +105,34 @@ init_mysql() { echo '[INFO] start MySQL' sleep 5s service mysql start - + echo "[INFO] ----------------------------------------" echo "[INFO] create SMP database: ${SMP_DB_SCHEMA}" if [ -d ${MYSQL_DATA_DIR}/${SMP_DB_SCHEMA} ]; then echo "[INFO] MySQL ${SMP_DB_SCHEMA} already present, skipping creation" - else + else echo "[INFO] MySQL ${SMP_DB_SCHEMA} not found, creating initial DBs" echo 'Create smp database' mysql -h localhost -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD';drop schema if exists $SMP_DB_SCHEMA;DROP USER IF EXISTS $SMP_DB_USER; create schema $SMP_DB_SCHEMA;alter database $SMP_DB_SCHEMA charset=utf8; create user $SMP_DB_USER identified by '$SMP_DB_USER_PASSWORD';grant all on $SMP_DB_SCHEMA.* to $SMP_DB_USER;" - if [ -f "/tmp/custom-data/mysql5innodb.sql" ] - then - echo "Use custom database script! " - mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SMP_DB_SCHEMA < "tmp/custom-data/mysql5innodb.ddl" + if [ -f "/tmp/custom-data/mysql5innodb.sql" ]; then + echo "Use custom database script! " + mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SMP_DB_SCHEMA <"tmp/custom-data/mysql5innodb.ddl" else - echo "Use default database ddl script!" - mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SMP_DB_SCHEMA < "/tmp/smp-setup/database-scripts/mysql5innodb.ddl" + echo "Use default database ddl script!" + mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SMP_DB_SCHEMA <"/tmp/smp-setup/database-scripts/mysql5innodb.ddl" fi - if [ -f "/tmp/custom-data/mysql5innodb-data.sql" ] - then - echo "Use custom init script! " - mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SMP_DB_SCHEMA < "/tmp/custom-data/mysql5innodb-data.sql" - else - echo "Use default init script!" - mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SMP_DB_SCHEMA < "/tmp/smp-setup/database-scripts/mysql5innodb-data.sql" + if [ -f "/tmp/custom-data/mysql5innodb-data.sql" ]; then + echo "Use custom init script! " + mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SMP_DB_SCHEMA <"/tmp/custom-data/mysql5innodb-data.sql" + else + echo "Use default init script!" + mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SMP_DB_SCHEMA < "/tmp/smp-setup/database-scripts/mysql5innodb-data.sql" fi fi - + echo "[INFO] ----------------------------------------" echo "[INFO] create SML database: ${SML_DB_SCHEMA}" if [ -d ${MYSQL_DATA_DIR}/${SML_DB_SCHEMA} ]; then echo "[INFO] MySQL $SML_DB_SCHEMA already present, skipping creation" @@ -161,31 +140,26 @@ init_mysql() { echo "[INFO] MySQL ${SML_DB_SCHEMA} not found, creating initial DBs" echo 'Create sml database' - mysql -h localhost -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD';drop schema if exists $SML_DB_SCHEMA;DROP USER IF EXISTS $SML_DB_USER; create schema $SML_DB_SCHEMA;alter database $SML_DB_SCHEMA charset=utf8; create user $SML_DB_USER identified by '$SML_DB_USER_PASSWORD';grant all on $SML_DB_SCHEMA.* to $SML_DB_USER;" + mysql -h localhost -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD';drop schema if exists $SML_DB_SCHEMA;DROP USER IF EXISTS $SML_DB_USER; create schema $SML_DB_SCHEMA;alter database $SML_DB_SCHEMA charset=utf8; create user $SML_DB_USER identified by '$SML_DB_USER_PASSWORD';grant all on $SML_DB_SCHEMA.* to $SML_DB_USER;" - if [ -f "/tmp/custom-data/sml-mysql5innodb.sql" ] - then - echo "Use custom database script! " - mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SML_DB_SCHEMA < "/tmp/custom-data/sml-mysql5innodb.ddl" + if [ -f "/tmp/custom-data/sml-mysql5innodb.sql" ]; then + echo "Use custom database script! " + mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SML_DB_SCHEMA <"/tmp/custom-data/sml-mysql5innodb.ddl" else - echo "Use default database ddl script!" - mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SML_DB_SCHEMA < "/tmp/sml-setup/database-scripts/mysql5innodb.ddl" + echo "Use default database ddl script!" + mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SML_DB_SCHEMA <"/tmp/sml-setup/database-scripts/mysql5innodb.ddl" fi - if [ -f "/tmp/custom-data/sml-mysql5innodb-data.sql" ] - then - echo "Use custom init script! " - mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SML_DB_SCHEMA < "/tmp/custom-data/sml-mysql5innodb-data.sql" - else - echo "Use default init script!" - mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SML_DB_SCHEMA < "/tmp/sml-setup/database-scripts/mysql5innodb-data.sql" + if [ -f "/tmp/custom-data/sml-mysql5innodb-data.sql" ]; then + echo "Use custom init script! " + mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SML_DB_SCHEMA <"/tmp/custom-data/sml-mysql5innodb-data.sql" + else + echo "Use default init script!" + mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SML_DB_SCHEMA <"/tmp/artefacts/shared-artefacts/sml-mysql5innodb-data.sql" + #mysql -h localhost -u root --password=$MYSQL_ROOT_PASSWORD $SML_DB_SCHEMA <"/tmp/sml-setup/database-scripts/mysql5innodb-data.sql" fi fi - - sleep 5s - # start mysql - } addOrReplaceProperties() { @@ -193,7 +167,7 @@ addOrReplaceProperties() { PROP_FILE=$1 INIT_PROPERTIES=$2 INIT_PROPERTY_DELIMITER=$3 - + # replace domibus properties if [ -n "$INIT_PROPERTIES" ]; then echo "Parse init properties: $INIT_PROPERTIES" @@ -211,8 +185,8 @@ addOrReplaceProperties() { for property in "${array[@]}"; do read -r key value <<<"$property" # escape regex chars and remove trailing and leading spaces.. - keyRE="$(printf '%s' "${key// }" | sed 's/[[\*^$()+?{|]/\\&/g')" - propertyRE="$(printf '%s' "${property// }" | sed 's/[[\*^$()+?{|/]/\\&/g')" + keyRE="$(printf '%s' "${key// /}" | sed 's/[[\*^$()+?{|]/\\&/g')" + propertyRE="$(printf '%s' "${property// /}" | sed 's/[[\*^$()+?{|/]/\\&/g')" echo "replace or add property: [$keyRE] with value [$propertyRE]" # replace key line and commented #key line with new property @@ -224,7 +198,6 @@ addOrReplaceProperties() { fi } - init_bind() { # move configuration if it does not exist @@ -238,33 +211,60 @@ init_bind() { chmod -R 0775 ${BIND_DATA_DIR} chown -R ${BIND_USER}:${BIND_USER} ${BIND_DATA_DIR} - # init data - if [ -f "/tmp/custom-data/db.test.edelivery.local" ] - then - echo "Use custom zone file! " - rm -rf /etc/bind/db.test.edelivery.local - cp /tmp/custom-data/db.test.edelivery.local /etc/bind/ - fi + # init data + if [ -f "/tmp/custom-data/db.test.edelivery.local" ]; then + echo "Use custom zone file! " + rm -rf /etc/bind/db.test.edelivery.local + cp /tmp/custom-data/db.test.edelivery.local /etc/bind/ + fi +} + +init_sml() { + #copy the sml truststore with SMP trusted certificates + cp /tmp/artefacts/shared-artefacts/sml-truststore.p12 /opt/smlconf/sml-truststore-docker-demo.p12 +} + +init_smp() { + # copy smp keystore with sml authorized sml certificates + cp /tmp/artefacts/shared-artefacts/smp-keystore-docker-demo.p12 "${DATA_DIR}/smp/smp-keystore-docker-demo.p12" +} +init_smp_properties() { + echo "[INFO] init smp properties:" + { + echo "# SMP init parameters" + echo "smp.security.folder=${DATA_DIR}/smp/" + echo "smp.libraries.folder=$SMP_HOME/apache-tomcat-$TOMCAT_VERSION/smp-libs" + echo "bdmsl.integration.logical.address=${SMP_LOGICAL_ADDRESS:-http://localhost:8080/smp/}" + echo "smp.automation.authentication.external.tls.clientCert.enabled=true" + echo "bdmsl.integration.enabled=true" + echo "bdmsl.integration.physical.address=0.0.0.0" + echo "bdmsl.participant.multidomain.enabled=false" + echo "bdmsl.integration.url=http://localhost:8080/edelivery-sml/" + echo "bdmsl.integration.logical.address=${SMP_LOGICAL_ADDRESS:-http://localhost:8080/smp/}" + echo "smp.keystore.filename=smp-keystore-docker-demo.p12" + echo "smp.keystore.type=PKCS12" + echo "smp.truststore.filename=smp-truststore-docker-demo.p12" + echo "smp.truststore.type=PKCS12" + echo "smp.keystore.password={DEC}{test123}" + echo "smp.truststore.password={DEC}{test123}" + } >>"$SMP_HOME/apache-tomcat-$TOMCAT_VERSION/classes/smp.config.properties" + + addOrReplaceProperties "$SMP_HOME/apache-tomcat-$TOMCAT_VERSION/classes/smp.config.properties" "$SMP_INIT_PROPERTIES" "$SMP_INIT_PROPERTY_DELIMITER" } init_smp_properties init_bind init_mysql init_tomcat - +init_sml +init_smp echo "Starting named..." -$(which named) -u ${BIND_USER} &> $BIND_DATA_DIR/bind-console.out & - - +$(which named) -u ${BIND_USER} &>$BIND_DATA_DIR/bind-console.out & echo '[INFO] start running SMP' chmod u+x $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/bin/*.sh cd $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/ # run from this folder in order to be smp log in logs folder exec ./bin/catalina.sh jpda run - - - - diff --git a/smp-server-library/pom.xml b/smp-server-library/pom.xml index 68b085503678402a6c7505435dbc34a54e3e3dd4..f4286b48378939da348f17b15759082d8a54ba81 100644 --- a/smp-server-library/pom.xml +++ b/smp-server-library/pom.xml @@ -151,22 +151,10 @@ <artifactId>httpclient</artifactId> <version>4.5.14</version> </dependency> - <!-- dependency> - <groupId>com.sun.xml.bind</groupId> - <artifactId>jaxb-impl</artifactId> - </dependency> <dependency> - <groupId>com.sun.xml.bind</groupId> - <artifactId>jaxb-core</artifactId> - </dependency --> - <!-- dependency> - <groupId>org.bouncycastle</groupId> - <artifactId>bcprov-jdk15on</artifactId> + <groupId>org.apache.santuario</groupId> + <artifactId>xmlsec</artifactId> </dependency> - <dependency> - <groupId>org.bouncycastle</groupId> - <artifactId>bcpkix-jdk15on</artifactId> - </dependency --> <!-- Tests --> <dependency> diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/X509CertificateToCertificateROConverter.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/X509CertificateToCertificateROConverter.java index d36e07bbd1dbde5b80825432d7e75703cac0a369..2e53bb8638cb4711b476d36b29d6664bfa8c1b1e 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/X509CertificateToCertificateROConverter.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/X509CertificateToCertificateROConverter.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Component; import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; +import java.security.Key; import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; @@ -66,7 +67,7 @@ public class X509CertificateToCertificateROConverter implements Converter<X509Ce cro.setCertificateId(certId); cro.setSubject(subject); cro.setIssuer(issuer); - cro.setPublicKeyType(cert.getPublicKey().getAlgorithm()); + cro.setPublicKeyType(getKeyAlgorithm(cert.getPublicKey())); cro.setCrlUrl(url); if (certPolicyIdentifiers!=null && !certPolicyIdentifiers.isEmpty()) { cro.getCertificatePolicies().addAll(certPolicyIdentifiers); @@ -115,4 +116,13 @@ public class X509CertificateToCertificateROConverter implements Converter<X509Ce } return ""; } + public String getKeyAlgorithm(Key key) { + if (StringUtils.equals(key.getAlgorithm(), "1.3.101.112")) { + return "Ed25519"; + } + if (StringUtils.equals(key.getAlgorithm(), "1.3.101.113")) { + return "Ed448"; + } + return key.getAlgorithm(); + } } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/QueryNames.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/QueryNames.java index 09fb0f0b05ff8bf241a3bcc886a6cd2a9c8501db..bae9ceb410ef07f07f125d88fc815b4241b4916a 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/QueryNames.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/QueryNames.java @@ -70,7 +70,7 @@ public class QueryNames { public static final String QUERY_RESOURCE_MEMBER_BY_USER_DOMAIN_RESOURCE_COUNT = "DBResourceMember.getByUserAndDomainResourceCount"; public static final String QUERY_RESOURCE_MEMBER_BY_USER_DOMAIN_RESOURCE_ROLE_COUNT = "DBResourceMember.getByUserAndDomainRoleResourceCount"; public static final String QUERY_RESOURCE_MEMBER_BY_USER_GROUP_RESOURCES_ROLE_COUNT = "DBResourceMember.getByUserAndGroupsResourcesAndRoleCount"; - + public static final String QUERY_RESOURCE_MEMBER_BY_USER_GROUP_RESOURCES_COUNT = "DBResourceMember.getByUserAndGroupsResourcesCount"; public static final String QUERY_RESOURCE_MEMBERS_COUNT = "DBResourceMember.getByResourceCount"; public static final String QUERY_RESOURCE_MEMBERS_FILTER_COUNT = "DBResourceMember.getByResourceFilterCount"; public static final String QUERY_RESOURCE_MEMBERS = "DBResourceMember.getByResource"; diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ResourceDao.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ResourceDao.java index 5fd057ead06832d5abc02bcb6b4d8a4b6ac1d12a..eca074ce5e3ba2549368e60ef2b62352ebfc9c18 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ResourceDao.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ResourceDao.java @@ -18,6 +18,7 @@ import eu.europa.ec.edelivery.smp.data.model.DBDomainResourceDef; import eu.europa.ec.edelivery.smp.data.model.doc.DBResource; import eu.europa.ec.edelivery.smp.data.model.doc.DBResourceFilter; import eu.europa.ec.edelivery.smp.data.model.ext.DBResourceDef; +import eu.europa.ec.edelivery.smp.data.model.user.DBUser; import eu.europa.ec.edelivery.smp.exceptions.ErrorCode; import eu.europa.ec.edelivery.smp.logging.SMPLogger; import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory; @@ -82,9 +83,6 @@ public class ResourceDao extends BaseDao<DBResource> { query.setParameter(PARAM_USER_ID, resourceFilter.getUserId()); query.setParameter(PARAM_MEMBERSHIP_ROLES, resourceFilter.getMembershipRoleTypes()); query.setParameter(PARAM_RESOURCE_FILTER, resourceFilter.getIdentifierFilter()); - - LOG.info("RESOURCE+FILTER: [{}]", resourceFilter.getIdentifierFilter()); - return query.getSingleResult(); } @@ -108,6 +106,31 @@ public class ResourceDao extends BaseDao<DBResource> { return query.getResultList(); } + public List<DBResource> getPublicResourcesSearch(int iPage, int iPageSize, DBUser user, String schema, String identifier) { + TypedQuery<DBResource> query = memEManager.createNamedQuery("DBResource.getPublicSearch", DBResource.class); + if (iPageSize > -1 && iPage > -1) { + query.setFirstResult(iPage * iPageSize); + } + if (iPageSize > 0) { + query.setMaxResults(iPageSize); + } + query.setParameter(PARAM_USER_ID, user != null ? user.getId() : null); + query.setParameter(PARAM_RESOURCE_SCHEME, StringUtils.isBlank(schema)? null: StringUtils.wrapIfMissing(schema,"%")); + query.setParameter(PARAM_RESOURCE_IDENTIFIER, StringUtils.isBlank(identifier)? null: StringUtils.wrapIfMissing(identifier,"%")); + + return query.getResultList(); + } + + public Long getPublicResourcesSearchCount(DBUser user, String schema, String identifier) { + TypedQuery<Long> query = memEManager.createNamedQuery("DBResource.getPublicSearchCount", Long.class); + + query.setParameter(PARAM_USER_ID, user != null ? user.getId() : null); + query.setParameter(PARAM_RESOURCE_SCHEME, StringUtils.isBlank(schema)? null: StringUtils.wrapIfMissing(schema,"%")); + query.setParameter(PARAM_RESOURCE_IDENTIFIER, StringUtils.isBlank(identifier)? null: StringUtils.wrapIfMissing(identifier,"%")); + + return query.getSingleResult(); + } + /** * Method returns ServiceGroup by participant identifier. If there is no service group it returns empty Option. diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ResourceMemberDao.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ResourceMemberDao.java index 76c9267fbe648f88fd6fdd861f405160f355eba6..2c4d4d5c9a3028924faf35bd7188083630c6d6a2 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ResourceMemberDao.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ResourceMemberDao.java @@ -17,7 +17,6 @@ import eu.europa.ec.edelivery.smp.data.enums.MembershipRoleType; import eu.europa.ec.edelivery.smp.data.model.DBDomain; import eu.europa.ec.edelivery.smp.data.model.DBGroup; import eu.europa.ec.edelivery.smp.data.model.doc.DBResource; -import eu.europa.ec.edelivery.smp.data.model.user.DBGroupMember; import eu.europa.ec.edelivery.smp.data.model.user.DBResourceMember; import eu.europa.ec.edelivery.smp.data.model.user.DBUser; import eu.europa.ec.edelivery.smp.logging.SMPLogger; @@ -101,12 +100,21 @@ public class ResourceMemberDao extends BaseDao<DBResourceMember> { LOG.debug("User [{}], group [{}], Role [{}]", userId, groupId, roleType); TypedQuery<Long> query = memEManager.createNamedQuery(QUERY_RESOURCE_MEMBER_BY_USER_GROUP_RESOURCES_ROLE_COUNT, Long.class); - query.setParameter(PARAM_USER_ID,userId); + query.setParameter(PARAM_USER_ID, userId); query.setParameter(PARAM_GROUP_ID, groupId); query.setParameter(PARAM_MEMBERSHIP_ROLE, roleType); return query.getSingleResult() > 0; } + public boolean isUserAnyGroupResourceMember(DBUser user, DBGroup group) { + LOG.debug("User [{}], group [{}]", user, group); + TypedQuery<Long> query = memEManager.createNamedQuery(QUERY_RESOURCE_MEMBER_BY_USER_GROUP_RESOURCES_COUNT, + Long.class); + query.setParameter(PARAM_USER_ID, user.getId()); + query.setParameter(PARAM_GROUP_ID, group.getId()); + return query.getSingleResult() > 0; + } + public List<DBResourceMember> getResourceMembers(Long resourceId, int iPage, int iPageSize, String filter) { boolean hasFilter = StringUtils.isNotBlank(filter); @@ -121,7 +129,7 @@ public class ResourceMemberDao extends BaseDao<DBResourceMember> { } query.setParameter(PARAM_RESOURCE_ID, resourceId); if (hasFilter) { - query.setParameter(PARAM_USER_FILTER, StringUtils.wrapIfMissing(StringUtils.trim(filter),"%" )); + query.setParameter(PARAM_USER_FILTER, StringUtils.wrapIfMissing(StringUtils.trim(filter), "%")); } return query.getResultList(); } @@ -131,7 +139,7 @@ public class ResourceMemberDao extends BaseDao<DBResourceMember> { TypedQuery<Long> query = memEManager.createNamedQuery(hasFilter ? QUERY_RESOURCE_MEMBERS_FILTER_COUNT : QUERY_RESOURCE_MEMBERS_COUNT, Long.class); query.setParameter(PARAM_RESOURCE_ID, groupId); if (hasFilter) { - query.setParameter(PARAM_USER_FILTER, StringUtils.wrapIfMissing(StringUtils.trim(filter),"%" )); + query.setParameter(PARAM_USER_FILTER, StringUtils.wrapIfMissing(StringUtils.trim(filter), "%")); } return query.getSingleResult(); } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/enums/SMLAuthenticationType.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/enums/SMLAuthenticationType.java new file mode 100644 index 0000000000000000000000000000000000000000..d5fcbb0262371619a79c36d3919165dc77895882 --- /dev/null +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/enums/SMLAuthenticationType.java @@ -0,0 +1,16 @@ +package eu.europa.ec.edelivery.smp.data.enums; + +/** + * Specifies + * + * Specifies sml authentication type as SML Client-Cert header, SSLCLientCert header and mTLS . + * + * @author Joze Rihtarsic + * @since 5.0 + */ +public enum SMLAuthenticationType { + + HTTP_HEADER_STRING, + HTTP_HEADER_CERTIFICATE, + TLS_CLIENT_CERTIFICATE +} diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/enums/VisibilityType.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/enums/VisibilityType.java index 1f5a263dc6582ec547882f36c5f01653984d0b30..5a402425f71d371130a88a4811c0600dcb29a918 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/enums/VisibilityType.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/enums/VisibilityType.java @@ -19,7 +19,7 @@ public enum VisibilityType { */ INTERNAL, /** - * Access to the resource is possible only to the resource members + * Access to the domain, group or resource is possible only if you are only direct or un-direct member of the domain, group or resource */ PRIVATE } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBDomain.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBDomain.java index 43ea855ca694339b32eeb2869b4199545009c4dc..da2edc0685fbc411f897d775df66aefcec7f8b5f 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBDomain.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/DBDomain.java @@ -92,9 +92,6 @@ public class DBDomain extends BaseEntity { @Column(name = "SML_SMP_ID", length = CommonColumnsLengths.MAX_SML_SMP_ID_LENGTH) @ColumnDescription(comment = "SMP ID used for SML integration") String smlSmpId; - @Column(name = "SML_CLIENT_CERT_HEADER", length = CommonColumnsLengths.MAX_FREE_TEXT_LENGTH) - @ColumnDescription(comment = "Client-Cert header used behind RP - ClientCertHeader for SML integration") - String smlClientCertHeader; @Column(name = "SML_CLIENT_KEY_ALIAS", length = CommonColumnsLengths.MAX_CERT_ALIAS_LENGTH) @ColumnDescription(comment = "Client key alias used for SML integration") String smlClientKeyAlias; @@ -174,14 +171,6 @@ public class DBDomain extends BaseEntity { this.smlSmpId = smlSmpId; } - public String getSmlClientCertHeader() { - return smlClientCertHeader; - } - - public void setSmlClientCertHeader(String smlClientCertHeader) { - this.smlClientCertHeader = smlClientCertHeader; - } - public String getSmlClientKeyAlias() { return smlClientKeyAlias; } @@ -279,7 +268,6 @@ public class DBDomain extends BaseEntity { .append(id, dbDomain.id).append(domainCode, dbDomain.domainCode) .append(smlSubdomain, dbDomain.smlSubdomain) .append(smlSmpId, dbDomain.smlSmpId) - .append(smlClientCertHeader, dbDomain.smlClientCertHeader) .append(smlClientKeyAlias, dbDomain.smlClientKeyAlias) .append(signatureKeyAlias, dbDomain.signatureKeyAlias) .append(signatureAlgorithm, dbDomain.signatureAlgorithm) diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/doc/DBResource.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/doc/DBResource.java index 5b06e6b48f97a90295bdf3cfca623434c161e7d3..8e7dc163ca574b3175bd3142253921f38f41509b 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/doc/DBResource.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/doc/DBResource.java @@ -33,7 +33,6 @@ import static eu.europa.ec.edelivery.smp.data.dao.QueryNames.*; @Entity @Audited -// the SMP_SG_UNIQ_PARTC_IDX is natural key @Table(name = "SMP_RESOURCE", indexes = {@Index(name = "SMP_RS_UNIQ_IDENT_DOREDEF_IDX", columnList = "IDENTIFIER_SCHEME, IDENTIFIER_VALUE, FK_DOREDEF_ID", unique = true), @Index(name = "SMP_RS_ID_IDX", columnList = "IDENTIFIER_VALUE"), @@ -49,13 +48,6 @@ import static eu.europa.ec.edelivery.smp.data.dao.QueryNames.*; @NamedQuery(name = QUERY_RESOURCES_BY_DOMAIN_ID_RESOURCE_DEF_ID_COUNT, query = "SELECT count(d.id) FROM DBResource d WHERE d.domainResourceDef.domain.id = :domain_id " + " and d.domainResourceDef.resourceDef.id = :resource_def_id ") @NamedQuery(name = QUERY_RESOURCES_BY_DOMAIN_ID_COUNT, query = "SELECT count(d.id) FROM DBResource d WHERE d.domainResourceDef.domain.id = :domain_id ") - -/* -@NamedQuery(name = QUERY_RESOURCE_FILTER_COUNT, query = "SELECT count(r.id) FROM DBResource r WHERE " + - " (:group_id IS NULL OR r.group.id = :group_id) " + - "AND (:domain_id IS NULL OR r.domainResourceDef.domain.id = :domain_id) " + - "AND (:resource_def_id IS NULL OR r.domainResourceDef.resourceDef.id = :resource_def_id) ") -*/ @NamedQuery(name = QUERY_RESOURCE_FILTER_COUNT, query = "SELECT count(r.id) FROM DBResource r " + " JOIN DBDomainResourceDef dr ON dr.id = r.domainResourceDef.id " + " WHERE (:group_id IS NULL OR r.group.id = :group_id) " + @@ -72,17 +64,6 @@ import static eu.europa.ec.edelivery.smp.data.dao.QueryNames.*; " AND (:resource_def_id IS NULL OR dr.resourceDef.id = :resource_def_id) " + " AND (:resource_filter IS NULL OR lower(r.identifierValue) like lower(:resource_filter) OR (r.identifierScheme IS NOT NULL AND lower(r.identifierScheme) like lower(:resource_filter)) )" + "order by r.id asc") - - -//JOIN DBResourceMember rm ON r.id = rm.resource.id -// user.id = :user_id AND rm.role in (:membership_roles) -/* - " (:group_id IS NULL OR r.group.id = :group_id) " + - "AND (:domain_id IS NULL OR r.domainResourceDef.domain.id = :domain_id) " + - "AND (:resource_def_id IS NULL OR r.domainResourceDef.resourceDef.id = :resource_def_id) ") -*/ - - @NamedQuery(name = "DBResource.getServiceGroupByID", query = "SELECT d FROM DBResource d WHERE d.id = :id") @NamedQuery(name = "DBResource.getServiceGroupByIdentifier", query = "SELECT d FROM DBResource d WHERE d.identifierValue = :participantIdentifier " + " AND (:participantScheme IS NULL AND d.identifierScheme IS NULL " + @@ -91,6 +72,47 @@ import static eu.europa.ec.edelivery.smp.data.dao.QueryNames.*; @NamedNativeQuery(name = "DBResource.deleteAllOwnerships", query = "DELETE FROM SMP_RESOURCE_MEMBER WHERE FK_SG_ID=:serviceGroupId") +// get All public +@NamedQuery(name = "DBResource.getPublicSearch", query = "SELECT r FROM DBResource r WHERE r.group.visibility='PUBLIC' " + + " AND (r.group.domain.visibility='PUBLIC' " + + " OR :user_id IS NOT NULL " + + " AND ( (select count(id) from DBDomainMember dm where dm.user.id = :user_id and dm.domain.id = r.group.domain.id) > 0 " + + " OR (select count(id) from DBGroupMember gm where gm.user.id = :user_id and gm.group.domain.id = r.group.domain.id) > 0 " + + " OR (select count(id) from DBResourceMember rm where rm.user.id = :user_id and rm.resource.group.domain.id = r.group.domain.id) > 0 " + + " ) " + + " ) " + + " AND (r.group.visibility='PUBLIC' " + + " OR :user_id IS NOT NULL " + + " AND ( (select count(id) from DBGroupMember gm where gm.user.id = :user_id and gm.group.id = r.group.id) > 0 " + + " OR (select count(id) from DBResourceMember rm where rm.user.id = :user_id and rm.resource.group.id = r.group.id) > 0 " + + " ) " + + " ) " + + " AND ( r.visibility = 'PUBLIC' " + + " OR :user_id IS NOT NULL " + + " AND (select count(id) from DBResourceMember rm where rm.user.id = :user_id and rm.resource.id = r.id) > 0 ) " + + " AND (:resource_identifier IS NULL OR r.identifierValue like :resource_identifier )" + + " AND (:resource_scheme IS NULL OR r.identifierScheme like :resource_scheme) order by r.identifierScheme, r.identifierValue" +) +@NamedQuery(name = "DBResource.getPublicSearchCount", query = "SELECT count(r.id) FROM DBResource r WHERE r.group.visibility='PUBLIC' " + + " AND (r.group.domain.visibility='PUBLIC' " + + " OR :user_id IS NOT NULL " + + " AND ( (select count(id) from DBDomainMember dm where dm.user.id = :user_id and dm.domain.id = r.group.domain.id) > 0 " + + " OR (select count(id) from DBGroupMember gm where gm.user.id = :user_id and gm.group.domain.id = r.group.domain.id) > 0 " + + " OR (select count(id) from DBResourceMember rm where rm.user.id = :user_id and rm.resource.group.domain.id = r.group.domain.id) > 0 " + + " ) " + + " ) " + + " AND (r.group.visibility='PUBLIC' " + + " OR :user_id IS NOT NULL " + + " AND ( (select count(id) from DBGroupMember gm where gm.user.id = :user_id and gm.group.id = r.group.id) > 0 " + + " OR (select count(id) from DBResourceMember rm where rm.user.id = :user_id and rm.resource.group.id = r.group.id) > 0 " + + " ) " + + " ) " + + " AND ( r.visibility = 'PUBLIC' " + + " OR :user_id IS NOT NULL " + + " AND (select count(id) from DBResourceMember rm where rm.user.id = :user_id and rm.resource.id = r.id) > 0 ) " + + " AND (:resource_identifier IS NULL OR r.identifierValue like :resource_identifier )" + + " AND (:resource_scheme IS NULL OR r.identifierScheme like :resource_scheme)" +) public class DBResource extends BaseEntity { @Id diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/doc/DBServiceGroupExtension.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/doc/DBServiceGroupExtension.java deleted file mode 100644 index dc1a6c23f359f233fb9316582375d2d6245be06a..0000000000000000000000000000000000000000 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/doc/DBServiceGroupExtension.java +++ /dev/null @@ -1,80 +0,0 @@ -package eu.europa.ec.edelivery.smp.data.model.doc; - -import eu.europa.ec.edelivery.smp.data.dao.utils.ColumnDescription; -import eu.europa.ec.edelivery.smp.data.model.BaseEntity; -import org.hibernate.envers.Audited; - -import javax.persistence.*; -import java.util.Objects; - -/** - * Database optimization: load xmlContent only when needed and - * keep blobs/clobs in separate table! - * - * @author Joze Rihtarsic - * @since 4.1 - */ - -@Entity -@Audited -@Table(name = "SMP_SG_EXTENSION") -@org.hibernate.annotations.Table(appliesTo = "SMP_SG_EXTENSION", comment = "Service group extension blob") -@NamedQueries({ - @NamedQuery(name = "DBServiceGroupExtension.deleteById", query = "DELETE FROM DBServiceGroupExtension d WHERE d.id = :id"), - -}) -public class DBServiceGroupExtension extends BaseEntity { - - @Id - @ColumnDescription(comment = "Shared primary key with master table SMP_RESOURCE") - private Long id; - - @Lob - @Column(name = "EXTENSION") - @ColumnDescription(comment = "XML extension(s) for servicegroup ") - byte[] extension; - - @OneToOne - @JoinColumn(name = "ID") - @MapsId - DBResource dbServiceGroup; - - @Override - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public DBResource getDbServiceGroup() { - return dbServiceGroup; - } - - public void setDbServiceGroup(DBResource dbServiceGroup) { - this.dbServiceGroup = dbServiceGroup; - } - - public byte[] getExtension() { - return extension; - } - - public void setExtension(byte[] extension) { - this.extension = extension; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - DBServiceGroupExtension that = (DBServiceGroupExtension) o; - return Objects.equals(id, that.id); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), id); - } -} diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/user/DBResourceMember.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/user/DBResourceMember.java index c34140f9f150b3a8dab599ee41ef25ff0b424b92..47b588352af29d37388942d45594665e3def8cad 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/user/DBResourceMember.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/user/DBResourceMember.java @@ -34,6 +34,10 @@ import static eu.europa.ec.edelivery.smp.data.dao.QueryNames.*; @NamedQuery(name = QUERY_RESOURCE_MEMBER_BY_USER_GROUP_RESOURCES_ROLE_COUNT, query = "SELECT count(c) FROM DBResourceMember c " + " WHERE c.user.id = :user_id AND c.resource.group.id = :group_id AND c.role= :membership_role ") +@NamedQuery(name = QUERY_RESOURCE_MEMBER_BY_USER_GROUP_RESOURCES_COUNT, query = "SELECT count(c) FROM DBResourceMember c " + + " WHERE c.user.id = :user_id AND c.resource.group.id = :group_id") + + @NamedQuery(name = QUERY_RESOURCE_MEMBERS_COUNT, query = "SELECT count(c) FROM DBResourceMember c " + " WHERE c.resource.id = :resource_id") @NamedQuery(name = QUERY_RESOURCE_MEMBERS, query = "SELECT c FROM DBResourceMember c " + diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/DomainRO.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/DomainRO.java index 51fca3e65202879a836e4b5c94d517bcfb997f53..c0cddbfcd027681e32907aaeb611573264072def 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/DomainRO.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/DomainRO.java @@ -19,7 +19,6 @@ public class DomainRO extends BaseRO { private String domainCode; private String smlSubdomain; private String smlSmpId; - private String smlClientCertHeader; private String smlClientKeyAlias; private String signatureKeyAlias; private boolean smlClientCertAuth; @@ -61,14 +60,6 @@ public class DomainRO extends BaseRO { this.smlSmpId = smlSmpId; } - public String getSmlClientCertHeader() { - return smlClientCertHeader; - } - - public void setSmlClientCertHeader(String smlClientCertHeader) { - this.smlClientCertHeader = smlClientCertHeader; - } - public String getSmlClientKeyAlias() { return smlClientKeyAlias; } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/security/ResourceGuard.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/security/ResourceGuard.java index 387b621d2765d8258eabd27fbf7a5eb9223d4df7..d2380cebac02249cf4b3919b611e40e8f00c0d6b 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/security/ResourceGuard.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/security/ResourceGuard.java @@ -8,8 +8,10 @@ import eu.europa.ec.edelivery.smp.data.dao.ResourceMemberDao; import eu.europa.ec.edelivery.smp.data.enums.MembershipRoleType; import eu.europa.ec.edelivery.smp.data.enums.VisibilityType; import eu.europa.ec.edelivery.smp.data.model.DBDomain; +import eu.europa.ec.edelivery.smp.data.model.DBGroup; import eu.europa.ec.edelivery.smp.data.model.doc.DBResource; import eu.europa.ec.edelivery.smp.data.model.doc.DBSubresource; +import eu.europa.ec.edelivery.smp.data.model.user.DBUser; import eu.europa.ec.edelivery.smp.exceptions.ErrorCode; import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException; import eu.europa.ec.edelivery.smp.identifiers.Identifier; @@ -68,10 +70,6 @@ public class ResourceGuard { switch (action) { case READ: return canRead(user, subresource); - /* case UPDATE: - return canUpdate(user, subresource); - case CREATE: - return canCreate(user, subresource); */ case DELETE: return canDelete(user, subresource); } @@ -82,12 +80,35 @@ public class ResourceGuard { public boolean canRead(SMPUserDetails user, DBResource resource) { LOG.debug(SMPLogger.SECURITY_MARKER, "User [{}] is trying to read resource [{}]", user, resource); + DBGroup group = resource.getGroup(); + DBDomain domain = group.getDomain(); + DBUser dbuser = user == null ? null : user.getUser(); + // if domain is internal check if user is member of domain, or any internal resources, groups + if (domain.getVisibility() == VisibilityType.PRIVATE && + (dbuser == null || + !(domainMemberDao.isUserDomainMember(dbuser, domain) + || groupMemberDao.isUserAnyDomainGroupResourceMember(dbuser, domain) + || resourceMemberDao.isUserAnyDomainResourceMember(dbuser, domain))) + ) { + LOG.debug(SMPLogger.SECURITY_MARKER, "User [{}] is not authorized to read internal domain [{}] resources", user, domain); + return false; + } + // if group is internal check if user is member of group, or any group resources, + if (group.getVisibility() == VisibilityType.PRIVATE && + (dbuser == null || + !(groupMemberDao.isUserGroupMember(dbuser, Collections.singletonList(group)) + || resourceMemberDao.isUserAnyGroupResourceMember(dbuser, group)) + )) { + LOG.debug(SMPLogger.SECURITY_MARKER, "User [{}] is not authorized to read internal group [{}] resources", user, domain); + return false; + } + // if resource is public anybody can see it if (resource.getVisibility() == VisibilityType.PUBLIC) { LOG.debug(SMPLogger.SECURITY_MARKER, "User [{}] authorized to read public resource [{}]", user, resource); return true; } - if (user == null || user.getUser() == null) { + if (dbuser == null) { LOG.debug(SMPLogger.SECURITY_MARKER, "Anonymous user [{}] is not authorized to read resource [{}]", user, resource); return false; } @@ -97,15 +118,16 @@ public class ResourceGuard { LOG.debug(SMPLogger.SECURITY_MARKER, "User [{}] authorized: [{}] to read private resource [{}]", user, isResourceMember, resource); return isResourceMember; } + /* // if resource is internal the domain, group members and resource member can see it if (resource.getVisibility() == VisibilityType.INTERNAL) { - boolean isAuthorized = domainMemberDao.isUserDomainMember(user.getUser(), resource.getDomainResourceDef().getDomain()) - || groupMemberDao.isUserGroupMember(user.getUser(), Collections.singletonList(resource.getGroup())); + boolean isAuthorized = domainMemberDao.isUserDomainMember(dbuser, resource.getDomainResourceDef().getDomain()) + || groupMemberDao.isUserGroupMember(dbuser, Collections.singletonList(resource.getGroup())); LOG.debug(SMPLogger.SECURITY_MARKER, "User [{}] authorized: [{}] to read internal resource [{}]", user, isAuthorized, resource); return isAuthorized; } - +*/ LOG.debug(SMPLogger.SECURITY_MARKER, "User [{}] is not authorized to read resource [{}]", user, resource); return false; } @@ -171,29 +193,6 @@ public class ResourceGuard { return canUpdate(user, subresource); } - /** - * Method validates if user is member of the resource with admin rights - * - * @param userIdentifier - * @param resourceIdentifier - */ - public boolean isResourceAdmin(String userIdentifier, String resourceIdentifier) { - Identifier pt = identifierService.normalizeParticipantIdentifier(resourceIdentifier); - return isResourceAdmin(userIdentifier, pt.getValue(), pt.getScheme()); - } - - public boolean isResourceAdmin(String userIdentifier, String resourceIdentifierValue, String resourceIdentifierScheme) { - // TODO - /** - * ParticipantIdentifierType pt = identifierService.normalizeParticipantIdentifier(serviceGroupIdentifier); - * Optional<DBResource> osg = serviceGroupDao.findServiceGroup(pt.getValue(), pt.getScheme()); - * Optional<DBUser> own = userDao.findUserByIdentifier(ownerIdentifier); - * return osg.isPresent() && own.isPresent() && osg.get().getUsers().contains(own.get()); - * } - */ - return false; - } - /** * Method validates if any of the service group users contains userID * diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/DomainService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/DomainService.java index 6b9ff97424de45997b49c86ef69f23d9158ac1ed..66e9ab52e7564b0492bdf5afe2ca1f36b445247b 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/DomainService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/DomainService.java @@ -5,10 +5,10 @@ import eu.europa.ec.edelivery.smp.data.dao.DomainDao; import eu.europa.ec.edelivery.smp.data.dao.ResourceDao; import eu.europa.ec.edelivery.smp.data.model.DBDomain; import eu.europa.ec.edelivery.smp.data.model.doc.DBResource; +import eu.europa.ec.edelivery.smp.data.model.doc.DBResourceFilter; import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException; import eu.europa.ec.edelivery.smp.logging.SMPLogger; import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory; -import eu.europa.ec.edelivery.smp.services.ui.filters.ResourceFilter; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -23,6 +23,7 @@ import static eu.europa.ec.edelivery.smp.exceptions.ErrorCode.*; /** * Service for domain + * * @author Joze Rihtarsic * @since 4.1 */ @@ -38,13 +39,12 @@ public class DomainService { private SMLIntegrationService smlIntegrationService; @Autowired - private ResourceDao serviceGroupDao; + private ResourceDao resourceDao; @Autowired private DomainDao domainDao; - /** * Method checks if domain is in right format. Domain must contains only alphanomeric chars and it must * not be longer than 50 chars. @@ -76,44 +76,33 @@ public class DomainService { /** * If domain is not yet registered and sml integration is on. Than it tries to register domain and all participants * on that domain. If integration is off it return an configuration exception. - * + * <p> * Method is not in transaction - but sub-methods are. if registering domain or particular serviceGroup succeed * then the database flag (SML_REGISTERED) is turned on ( if method fails * while execution the SML_REGISTERED reflect the real status in SML). Running the method again updates only * serviceGroup which are not yet registered. * - * * @param domain */ - public void registerDomainAndParticipants(DBDomain domain){ + public void registerDomainAndParticipants(DBDomain domain) { LOG.info("Start registerDomainAndParticipants for domain:" + domain.getDomainCode()); smlIntegrationService.registerDomain(domain); - // get all participant for domain and register them - ResourceFilter serviceGroupFilter = new ResourceFilter(); - serviceGroupFilter.setDomain(domain); - - // register all service groups - List<DBResource> serviceGroupList = serviceGroupDao.getServiceGroupList(-1, -1, null, null, serviceGroupFilter); - for (DBResource sg: serviceGroupList){ - smlIntegrationService.registerParticipant(sg.getIdentifierValue(), sg.getIdentifierScheme(), domain.getDomainCode()); + DBResourceFilter filter = DBResourceFilter.createBuilder().domain(domain).build(); + List<DBResource> resources = resourceDao.getResourcesForFilter(-1, -1, filter); + for (DBResource resource : resources) { + smlIntegrationService.registerParticipant(resource, domain); } } - public void unregisterDomainAndParticipantsFromSml(DBDomain domain){ - - // get all participant for domain and register them - ResourceFilter serviceGroupFilter = new ResourceFilter(); - serviceGroupFilter.setDomain(domain); + public void unregisterDomainAndParticipantsFromSml(DBDomain domain) { - // register all service groups - List<DBResource> serviceGroupList = serviceGroupDao.getServiceGroupList(-1, -1, null, null, serviceGroupFilter); - LOG.info("Unregister participants (count: {}) for domain: {}: ", serviceGroupList.size(), domain.getDomainCode()); - for (DBResource sg: serviceGroupList){ - smlIntegrationService.unregisterParticipant(sg.getIdentifierValue(), sg.getIdentifierScheme(), domain.getDomainCode()); + DBResourceFilter filter = DBResourceFilter.createBuilder().domain(domain).build(); + List<DBResource> resources = resourceDao.getResourcesForFilter(-1, -1, filter); + for (DBResource resource : resources) { + smlIntegrationService.unregisterParticipant(resource, domain); } - smlIntegrationService.unRegisterDomain(domain); } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/SMLIntegrationService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/SMLIntegrationService.java index ac8851de540a9bc333e20e2380ec558376f34de8..758b51974c7fece93812080e821d3e32e5820a3e 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/SMLIntegrationService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/SMLIntegrationService.java @@ -3,21 +3,20 @@ package eu.europa.ec.edelivery.smp.services; import eu.europa.ec.edelivery.smp.conversion.IdentifierService; import eu.europa.ec.edelivery.smp.data.dao.DomainDao; -import eu.europa.ec.edelivery.smp.data.dao.ResourceDao; import eu.europa.ec.edelivery.smp.data.model.DBDomain; -import eu.europa.ec.edelivery.smp.data.model.DBDomainResourceDef; +import eu.europa.ec.edelivery.smp.data.model.doc.DBResource; import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException; import eu.europa.ec.edelivery.smp.identifiers.Identifier; import eu.europa.ec.edelivery.smp.logging.SMPLogger; import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory; -import eu.europa.ec.edelivery.smp.logging.SMPMessageCode; import eu.europa.ec.edelivery.smp.sml.SmlConnector; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import static eu.europa.ec.edelivery.smp.exceptions.ErrorCode.CONFIGURATION_ERROR; -import static eu.europa.ec.edelivery.smp.logging.SMPMessageCode.BUS_SML_UNREGISTER_SERVICE_GROUP; +import static eu.europa.ec.edelivery.smp.logging.SMPMessageCode.*; /** @@ -39,9 +38,6 @@ public class SMLIntegrationService { @Autowired private SmlConnector smlConnector; - @Autowired - private ResourceDao serviceGroupDao; - @Autowired private DomainDao domainDao; @@ -85,94 +81,77 @@ public class SMLIntegrationService { /** - * Method in transaction update servicegroupDomain status and registers participant to SML. + * Method in transaction update resource status and registers it to SML. * If registration fails - transaction is rolled back * - * @param participantId - Participant schema - * @param participantSchema - Participant schema - * @param domainCode - register to domain + * @param resource + * @param domain */ - @Transactional - public void registerParticipant(String participantId, String participantSchema, String domainCode) { - /* - LOG.businessDebug(BUS_SML_REGISTER_SERVICE_GROUP, participantId, participantSchema, domainCode); + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void registerParticipant(DBResource resource, DBDomain domain) { + + LOG.businessDebug(BUS_SML_REGISTER_SERVICE_GROUP, resource.getIdentifierValue(), resource.getIdentifierScheme(), domain.getDomainCode()); if (!isSMLIntegrationEnabled()) { String msg = "SML integration is not enabled!"; - LOG.businessError(BUS_SML_REGISTER_SERVICE_GROUP_FAILED, participantId, participantSchema, domainCode, msg); + LOG.businessError(BUS_SML_REGISTER_SERVICE_GROUP_FAILED, resource.getIdentifierValue(), resource.getIdentifierScheme(), domain.getDomainCode(), msg); throw new SMPRuntimeException(CONFIGURATION_ERROR, msg); } - DBDomainResourceDef serviceGroupDomain = getAndValidateServiceGroupDomain(participantId, - participantSchema, domainCode, BUS_SML_REGISTER_SERVICE_GROUP_FAILED); - - ParticipantIdentifierType normalizedParticipantId = identifierService - .normalizeParticipant(participantSchema, participantId); - - + Identifier normalizedParticipantId = identifierService + .normalizeParticipant(resource.getIdentifierScheme(), resource.getIdentifierValue()); // register only not registered services - if (!serviceGroupDomain.isSmlRegistered()) { + if (!resource.isSmlRegistered()) { // update value - serviceGroupDomain.setSmlRegistered(true); - serviceGroupDao.updateServiceGroupDomain(serviceGroupDomain); - smlConnector.registerInDns(normalizedParticipantId, serviceGroupDomain.getDomain()); - LOG.businessDebug(BUS_SML_REGISTER_SERVICE_GROUP, participantId, participantSchema, domainCode); + resource.setSmlRegistered(true); + smlConnector.registerInDns(normalizedParticipantId, domain); + LOG.businessDebug(BUS_SML_REGISTER_SERVICE_GROUP, resource.getIdentifierValue(), resource.getIdentifierScheme(), domain.getDomainCode()); } else { - LOG.businessWarn(BUS_SML_REGISTER_SERVICE_GROUP_ALREADY_REGISTERED, participantId, participantSchema, domainCode); + LOG.businessWarn(BUS_SML_REGISTER_SERVICE_GROUP_ALREADY_REGISTERED, resource.getIdentifierValue(), resource.getIdentifierScheme(), domain.getDomainCode()); } -*/ + } /** - * Method in transaction update servicegroupDomain status and unregisters participant to SML. - * Method is meant for unregistering participants which are still in database. If they are delete - * then this method should not be used. + * Method in transaction update resource status and unregisters participant to SML. * <p> * If registration fails - transaction is rolled back * - * @param participantId - Participant schema - * @param participantSchema - Participant schema - * @param domainCode - register to domain + * @param resource + * @param domain */ - @Transactional - public void unregisterParticipant(String participantId, String participantSchema, String domainCode) { - /* LOG.businessDebug(BUS_SML_UNREGISTER_SERVICE_GROUP, participantId, participantSchema, domainCode); + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void unregisterParticipant(DBResource resource, DBDomain domain) { + LOG.businessDebug(BUS_SML_UNREGISTER_SERVICE_GROUP, resource.getIdentifierValue(), resource.getIdentifierScheme(), domain.getDomainCode()); if (!isSMLIntegrationEnabled()) { String msg = "SML integration is not enabled!"; - LOG.businessError(BUS_SML_UNREGISTER_SERVICE_GROUP_FAILED, participantId, participantSchema, domainCode, msg); + LOG.businessError(BUS_SML_UNREGISTER_SERVICE_GROUP_FAILED, resource.getIdentifierValue(), resource.getIdentifierScheme(), domain.getDomainCode(), msg); throw new SMPRuntimeException(CONFIGURATION_ERROR, msg); } - - DBDomainResourceDef serviceGroupDomain = getAndValidateServiceGroupDomain(participantId, participantSchema, domainCode, BUS_SML_UNREGISTER_SERVICE_GROUP_FAILED); - // unregister only registered participants - if (serviceGroupDomain.isSmlRegistered()) { + if (resource.isSmlRegistered()) { // update value - serviceGroupDomain.setSmlRegistered(false); - serviceGroupDao.updateServiceGroupDomain(serviceGroupDomain); - unregisterParticipantFromSML(participantId, participantSchema, serviceGroupDomain.getDomain()); - LOG.businessDebug(BUS_SML_UNREGISTER_SERVICE_GROUP, participantId, participantSchema, domainCode); + resource.setSmlRegistered(false); + unregisterParticipantFromSML(resource, domain); + LOG.businessDebug(BUS_SML_UNREGISTER_SERVICE_GROUP, resource.getIdentifierValue(), resource.getIdentifierScheme(), domain.getDomainCode()); } else { - LOG.businessWarn(BUS_SML_UNREGISTER_SERVICE_GROUP_ALREADY_REGISTERED, participantId, participantSchema, domainCode); + LOG.businessWarn(BUS_SML_UNREGISTER_SERVICE_GROUP_ALREADY_REGISTERED, resource.getIdentifierValue(), resource.getIdentifierScheme(), domain.getDomainCode()); } - - */ } /** * Method unregisters participant from SML. It does not check if Participant is in database or of is unregistered * - * @param participantId - Participant schema - * @param participantSchema - Participant schema - * @param domain - register to domain + * @param resource - Participant + * @param domain - unregister to domain */ - public boolean unregisterParticipantFromSML(String participantId, String participantSchema, DBDomain domain) { - LOG.businessDebug(BUS_SML_UNREGISTER_SERVICE_GROUP, participantId, participantSchema, domain.getDomainCode()); + public boolean unregisterParticipantFromSML(DBResource resource, DBDomain domain) { + LOG.businessDebug(BUS_SML_UNREGISTER_SERVICE_GROUP, resource.getIdentifierValue(), resource.getIdentifierScheme(), domain.getDomainCode()); Identifier normalizedParticipantId = identifierService - .normalizeParticipant(participantSchema, participantId); + .normalizeParticipant(resource.getIdentifierScheme(), resource.getIdentifierValue()); // unregister only registered participants return smlConnector.unregisterFromDns(normalizedParticipantId, domain); @@ -198,28 +177,6 @@ public class SMLIntegrationService { } - private DBDomainResourceDef getAndValidateServiceGroupDomain(String participantId, String participantSchema, String domainCode, SMPMessageCode messageCode) { - /* // retrieve participant (session must be on - lazy loading... ) - Optional<DBResource> optionalServiceGroup = serviceGroupDao.findServiceGroup(participantId, participantSchema); - if (!optionalServiceGroup.isPresent()) { - String msg = "Service group not exists anymore !"; - LOG.businessError(messageCode, participantId, participantId, domainCode, msg); - throw new SMPRuntimeException(SG_NOT_EXISTS, participantId, participantSchema); - } - - DBResource serviceGroup = optionalServiceGroup.get(); - Optional<DBDomainResourceDef> optionalServiceGroupDomain = serviceGroup.getServiceGroupForDomain(domainCode); - if (!optionalServiceGroupDomain.isPresent()) { - String msg = "Service group is not registered for domain on this SMP - register participant on domain first!"; - LOG.businessError(messageCode, participantId, participantId, domainCode, msg); - throw new SMPRuntimeException(SG_NOT_REGISTRED_FOR_DOMAIN, domainCode, participantId, participantSchema); - } - - - return optionalServiceGroupDomain.get(); */ - return null; - } - public boolean isSMLIntegrationEnabled() { return configurationService.isSMLIntegrationEnabled(); } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/resource/ResourceResolverService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/resource/ResourceResolverService.java index 529eec63f8ca54d62092389e719c751ef5692ced..0ee093ec18e704909035369b792ea374825bafa0 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/resource/ResourceResolverService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/resource/ResourceResolverService.java @@ -19,6 +19,7 @@ import eu.europa.ec.edelivery.smp.services.ConfigurationService; import eu.europa.ec.edelivery.smp.servlet.ResourceAction; import eu.europa.ec.edelivery.smp.servlet.ResourceRequest; import org.apache.commons.lang3.StringUtils; +import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -117,10 +118,10 @@ public class ResourceResolverService { locationVector.setResource(resource); if (resourceGuard.userIsNotAuthorizedForAction(user, resourceRequest.getAction(), resource, domain)) { - LOG.info(SECURITY_MARKER, "User [{}] is NOT authorized for action [{}] on the resource [{}]", user, resourceRequest.getAction(), resource); - throw new SMPRuntimeException(ErrorCode.USER_IS_NOT_OWNER, user.getUsername(), resource.getIdentifierValue(), resource.getIdentifierScheme()); + LOG.info(SECURITY_MARKER, "User [{}] is NOT authorized for action [{}] on the resource [{}]", getUsername(user), resourceRequest.getAction(), resource); + throw new SMPRuntimeException(ErrorCode.UNAUTHORIZED); } else { - LOG.info(SECURITY_MARKER, "User: [{}] is authorized for action [{}] on the resource [{}]", user, resourceRequest.getAction(), resource); + LOG.info(SECURITY_MARKER, "User: [{}] is authorized for action [{}] on the resource [{}]", getUsername(user), resourceRequest.getAction(), resource); } if (pathParameters.size() == ++iParameterIndex) { @@ -294,7 +295,10 @@ public class ResourceResolverService { if (configurationService.getParticipantSchemeMandatory() && StringUtils.isBlank(identifier.getScheme())) { throw new SMPRuntimeException(SML_INVALID_IDENTIFIER, identifier.getValue()); } + } + public String getUsername(UserDetails user){ + return user ==null? "Anonymous":user.getUsername(); } } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/spi/SmpXmlSignatureService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/spi/SmpXmlSignatureService.java index 0a84ef9010576c880415044a096b6eb5551d6313..756ba2024dadecf79905b4b989af104d27ddc025 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/spi/SmpXmlSignatureService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/spi/SmpXmlSignatureService.java @@ -38,6 +38,7 @@ import javax.xml.crypto.dsig.keyinfo.X509Data; import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec; import javax.xml.crypto.dsig.spec.TransformParameterSpec; import java.security.InvalidAlgorithmParameterException; +import java.security.Key; import java.security.NoSuchAlgorithmException; import java.security.cert.X509Certificate; import java.util.ArrayList; @@ -54,8 +55,6 @@ import static javax.xml.crypto.dsig.Transform.ENVELOPED; public final class SmpXmlSignatureService implements SmpXmlSignatureApi { private static final SMPLogger LOG = SMPLoggerFactory.getLogger(SmpXmlSignatureService.class); - - private static final String DEFAULT_SIGNATURE_METHOD = org.apache.xml.security.signature.XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256; private static final String DEFAULT_HASH_METHOD = javax.xml.crypto.dsig.DigestMethod.SHA256; DomainDao domainDao; @@ -70,13 +69,14 @@ public final class SmpXmlSignatureService implements SmpXmlSignatureApi { private static XMLSignatureFactory getDomSigFactory() { // According to Javadoc, only static methods of this factory are thread-safe // We cannot share and re-use the same instance in every place - return XMLSignatureFactory.getInstance("DOM"); + // set apache santuario xmlsec signature factory + return XMLSignatureFactory.getInstance("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI()); } /** * Creates an Enveloped XML signature which is embed to the specified node (parentSignatureNode) of the document. * The marshalled <code>XMLSignature</code> will be added as the last - * child element of the specified pparentSignatureNode. + * child element of the specified parentSignatureNode. * * @param parentSignatureNode the parent of the signing node. The element must be part of the XML document to be signed * @param signedElementURIList the parent node the list of URIs to be signed. If List is empty then the whole document is signed @@ -108,7 +108,8 @@ public final class SmpXmlSignatureService implements SmpXmlSignatureApi { createEnvelopedSignature(documentToSign.getDocumentElement(), Collections.emptyList(), keyAlias, signatureAlgorithm, signatureHashMethod); } - public void createEnvelopedSignature(Element parentSignatureNode, List<String> signedElementURIList, String keyAlias, String signatureAlgorithm, String signatureHashMethod) { + public void createEnvelopedSignature(Element parentSignatureNode, List<String> signedElementURIList, String keyAlias, + String signatureAlgorithm, String signatureHashMethod) { LOG.info("Sing document with alias {}", keyAlias); try { if (StringUtils.isBlank(keyAlias) && uiKeystoreService.getKeystoreEntriesList().size() > 1) { @@ -117,21 +118,26 @@ public final class SmpXmlSignatureService implements SmpXmlSignatureApi { } XMLSignatureFactory domSigFactory = getDomSigFactory(); + Key signingKey = uiKeystoreService.getKey(keyAlias); + String signAlg = getSignatureAlgorithmForKey(signingKey, signatureAlgorithm); + String referenceHash = StringUtils.defaultIfEmpty(signatureHashMethod, DEFAULT_HASH_METHOD); + + List<Reference> referenceList; if (signedElementURIList.isEmpty()) { // Create a Reference to the ENVELOPED document // URI "" means that the whole document is signed - referenceList = singletonList(createReferenceForUri("", domSigFactory, signatureHashMethod)); + referenceList = singletonList(createReferenceForUri("", domSigFactory, referenceHash)); } else { - referenceList = signedElementURIList.stream().map(uri -> createReferenceForUri(uri, domSigFactory, signatureHashMethod)).collect(Collectors.toList()); + referenceList = signedElementURIList.stream().map(uri -> createReferenceForUri(uri, domSigFactory, referenceHash)).collect(Collectors.toList()); } - - + LOG.info("Create signature with signature algorithm : [{}]", signAlg); SignedInfo singedInfo = domSigFactory.newSignedInfo( domSigFactory.newCanonicalizationMethod(INCLUSIVE, (C14NMethodParameterSpec) null), - domSigFactory.newSignatureMethod(StringUtils.defaultIfEmpty(signatureAlgorithm, DEFAULT_SIGNATURE_METHOD), null), + domSigFactory.newSignatureMethod(signAlg, null), referenceList); + DOMSignContext domSignContext = new DOMSignContext(uiKeystoreService.getKey(keyAlias), parentSignatureNode); // Create the XMLSignature, but don't sign it yet @@ -149,7 +155,7 @@ public final class SmpXmlSignatureService implements SmpXmlSignatureApi { try { return domSigFactory.newReference( elementUri, - domSigFactory.newDigestMethod(StringUtils.defaultIfEmpty(signatureHashMethod, DEFAULT_HASH_METHOD), null), + domSigFactory.newDigestMethod(signatureHashMethod, null), singletonList(domSigFactory.newTransform(ENVELOPED, (TransformParameterSpec) null)), null, null); @@ -168,4 +174,23 @@ public final class SmpXmlSignatureService implements SmpXmlSignatureApi { return keyInfoFactory.newKeyInfo(singletonList(x509Data)); } + public String getSignatureAlgorithmForKey(Key key, String algorithm) { + if (StringUtils.isNotBlank(algorithm)) { + return algorithm; + } + + if (StringUtils.equalsAnyIgnoreCase(key.getAlgorithm(), "1.3.101.112","ed25519")) { + return org.apache.xml.security.signature.XMLSignature.ALGO_ID_SIGNATURE_EDDSA_ED25519; + } + + if (StringUtils.equalsAnyIgnoreCase(key.getAlgorithm(), "1.3.101.113","ed448")) { + return org.apache.xml.security.signature.XMLSignature.ALGO_ID_SIGNATURE_EDDSA_ED448; + } + + if (StringUtils.equalsIgnoreCase(key.getAlgorithm(), "ec")) { + return org.apache.xml.security.signature.XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256; + } + return org.apache.xml.security.signature.XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256; + } + } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainService.java index fcd081cf44d1735c982ac8a564958d6777ad10a5..118d92e93e902be8e26c37e95f1c6042dd4c0c33 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainService.java @@ -38,15 +38,14 @@ public class UIDomainService extends UIServiceBase<DBDomain, DomainRO> { private ResourceDefDao resourceDefDao; private DomainResourceDefDao domainResourceDefDao; private ConversionService conversionService; - private SmlConnector smlConnector; - public UIDomainService(ConversionService conversionService, DomainDao domainDao, ResourceDao resourceDao, ResourceDefDao resourceDefDao, DomainResourceDefDao domainResourceDefDao, SmlConnector smlConnector) { + + public UIDomainService(ConversionService conversionService, DomainDao domainDao, ResourceDao resourceDao, ResourceDefDao resourceDefDao, DomainResourceDefDao domainResourceDefDao) { this.conversionService = conversionService; this.domainDao = domainDao; this.resourceDao = resourceDao; this.resourceDefDao = resourceDefDao; this.domainResourceDefDao = domainResourceDefDao; - this.smlConnector = smlConnector; } @Override @@ -117,7 +116,7 @@ public class UIDomainService extends UIServiceBase<DBDomain, DomainRO> { if (domain == null) { throw new BadRequestException(ErrorBusinessCode.NOT_FOUND, "Domain does not exist in database!"); } - if (domain.isSmlRegistered() && StringUtils.equals(data.getSmlSmpId(), domain.getSmlSmpId())){ + if (domain.isSmlRegistered() && !StringUtils.equals(data.getSmlSmpId(), domain.getSmlSmpId())){ String msg = "SMP-SML identifier must not change for registered domain ["+domain.getDomainCode()+"]!"; throw new BadRequestException(ErrorBusinessCode.NOT_FOUND, msg); } @@ -125,7 +124,6 @@ public class UIDomainService extends UIServiceBase<DBDomain, DomainRO> { domain.setSmlSubdomain(data.getSmlSubdomain()); domain.setSmlSmpId(data.getSmlSmpId()); domain.setSmlClientKeyAlias(data.getSmlClientKeyAlias()); - domain.setSmlClientCertHeader(data.getSmlClientCertHeader()); domain.setSmlClientCertAuth(data.isSmlClientCertAuth()); } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIResourceService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIResourceService.java index adebe411abcf950aae3dc7d62fdb69aa4e55f07c..4964662149367487d617f6822f899dcea910c6bb 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIResourceService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIResourceService.java @@ -2,6 +2,7 @@ package eu.europa.ec.edelivery.smp.services.ui; import eu.europa.ec.edelivery.smp.data.dao.*; import eu.europa.ec.edelivery.smp.data.enums.MembershipRoleType; +import eu.europa.ec.edelivery.smp.data.model.DBDomain; import eu.europa.ec.edelivery.smp.data.model.DBDomainResourceDef; import eu.europa.ec.edelivery.smp.data.model.DBGroup; import eu.europa.ec.edelivery.smp.data.model.doc.DBDocument; @@ -17,7 +18,7 @@ import eu.europa.ec.edelivery.smp.exceptions.ErrorCode; import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException; import eu.europa.ec.edelivery.smp.logging.SMPLogger; import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory; -import eu.europa.ec.edelivery.smp.sml.SmlConnector; +import eu.europa.ec.edelivery.smp.services.SMLIntegrationService; import org.apache.commons.lang3.StringUtils; import org.springframework.core.convert.ConversionService; import org.springframework.stereotype.Service; @@ -51,10 +52,13 @@ public class UIResourceService { private final ResourceDefDao resourceDefDao; private final DomainResourceDefDao domainResourceDefDao; private final ConversionService conversionService; - private final SmlConnector smlConnector; + private final SMLIntegrationService smlIntegrationService; - public UIResourceService(ResourceDao resourceDao, ResourceMemberDao resourceMemberDao, ResourceDefDao resourceDefDao, DomainResourceDefDao domainResourceDefDao, UserDao userDao, GroupDao groupDao, ConversionService conversionService, SmlConnector smlConnector) { + public UIResourceService(ResourceDao resourceDao, ResourceMemberDao resourceMemberDao, ResourceDefDao resourceDefDao, + DomainResourceDefDao domainResourceDefDao, UserDao userDao, GroupDao groupDao, + ConversionService conversionService, + SMLIntegrationService smlIntegrationService) { this.resourceDao = resourceDao; this.resourceMemberDao = resourceMemberDao; this.resourceDefDao = resourceDefDao; @@ -62,7 +66,7 @@ public class UIResourceService { this.groupDao = groupDao; this.userDao = userDao; this.conversionService = conversionService; - this.smlConnector = smlConnector; + this.smlIntegrationService = smlIntegrationService; } @@ -145,6 +149,11 @@ public class UIResourceService { if (!Objects.equals(resource.getGroup().getDomain().getId(), domainId)) { throw new SMPRuntimeException(ErrorCode.INVALID_REQUEST, ACTION_RESOURCE_CREATE, "Group does not belong to the given domain!"); } + DBDomain resourceDomain = resource.getGroup().getDomain(); + if (smlIntegrationService.isSMLIntegrationEnabled() && + resourceDomain.isSmlRegistered() && resource.isSmlRegistered()) { + smlIntegrationService.unregisterParticipant(resource, resourceDomain); + } resourceDao.remove(resource); return conversionService.convert(resource, ResourceRO.class); @@ -192,6 +201,13 @@ public class UIResourceService { dbResourceMember.setResource(resource); dbResourceMember.setUser(user); resourceMemberDao.persist(dbResourceMember); + // try to register it to + DBDomain resourceDomain = resource.getGroup().getDomain(); + if (smlIntegrationService.isSMLIntegrationEnabled() && + resourceDomain.isSmlRegistered()) { + smlIntegrationService.registerParticipant(resource, resourceDomain); + } + return conversionService.convert(resource, ResourceRO.class); } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIServiceGroupSearchService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIServiceGroupSearchService.java index 4a84c124705464cdfad22859e7a0044ce380b5ab..2f1092e35459f261276086e42c58c0f69e65e6bc 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIServiceGroupSearchService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIServiceGroupSearchService.java @@ -6,13 +6,14 @@ import eu.europa.ec.edelivery.smp.data.dao.ResourceDao; import eu.europa.ec.edelivery.smp.data.dao.UserDao; import eu.europa.ec.edelivery.smp.data.model.DBDomain; import eu.europa.ec.edelivery.smp.data.model.doc.DBResource; -import eu.europa.ec.edelivery.smp.data.ui.DomainRO; +import eu.europa.ec.edelivery.smp.data.model.user.DBUser; import eu.europa.ec.edelivery.smp.data.ui.ServiceGroupSearchRO; import eu.europa.ec.edelivery.smp.data.ui.ServiceMetadataRO; import eu.europa.ec.edelivery.smp.data.ui.ServiceResult; import eu.europa.ec.edelivery.smp.logging.SMPLogger; import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory; import eu.europa.ec.edelivery.smp.services.ui.filters.ResourceFilter; +import eu.europa.ec.edelivery.smp.utils.SessionSecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -28,7 +29,7 @@ public class UIServiceGroupSearchService extends UIServiceBase<DBResource, Servi DomainDao domainDao; @Autowired - ResourceDao serviceGroupDao; + ResourceDao resourceDao; @Autowired UserDao userDao; @@ -36,7 +37,7 @@ public class UIServiceGroupSearchService extends UIServiceBase<DBResource, Servi @Override protected BaseDao<DBResource> getDatabaseDao() { - return serviceGroupDao; + return resourceDao; } /** @@ -57,19 +58,19 @@ public class UIServiceGroupSearchService extends UIServiceBase<DBResource, Servi ServiceResult<ServiceGroupSearchRO> sg = new ServiceResult<>(); sg.setPage(page < 0 ? 0 : page); sg.setPageSize(pageSize); - long iCnt = serviceGroupDao.getServiceGroupCount(filter); + DBUser user = SessionSecurityUtils.getSessionUserDetails() != null ? SessionSecurityUtils.getSessionUserDetails().getUser() : null; + + long iCnt = resourceDao.getPublicResourcesSearchCount(user, filter.getIdentifierSchemeLike(), filter.getIdentifierValueLike()); sg.setCount(iCnt); if (iCnt > 0) { - int iStartIndex = pageSize<0?-1:page * pageSize; - if (iStartIndex >= iCnt && page > 0){ - page = page -1; + int iStartIndex = pageSize < 0 ? -1 : page * pageSize; + if (iStartIndex >= iCnt && page > 0) { + page = page - 1; sg.setPage(page); // go back for a page - iStartIndex = pageSize<0?-1:page * pageSize; + iStartIndex = pageSize < 0 ? -1 : page * pageSize; } - - - List<DBResource> lst = serviceGroupDao.getServiceGroupList(iStartIndex, pageSize, sortField, sortOrder, filter); + List<DBResource> lst = resourceDao.getPublicResourcesSearch(page, pageSize, user, filter.getIdentifierSchemeLike(), filter.getIdentifierValueLike()); List<ServiceGroupSearchRO> lstRo = new ArrayList<>(); for (DBResource resource : lst) { ServiceGroupSearchRO serviceGroupRo = convertToRo(resource); @@ -96,12 +97,12 @@ public class UIServiceGroupSearchService extends UIServiceBase<DBResource, Servi DBDomain domain = resource.getDomainResourceDef().getDomain(); resource.getSubresources().forEach(subresource -> { - ServiceMetadataRO smdro = new ServiceMetadataRO(); - smdro.setDocumentIdentifier(subresource.getIdentifierValue()); - smdro.setDocumentIdentifierScheme(subresource.getIdentifierScheme()); - smdro.setDomainCode(domain.getDomainCode()); - smdro.setSmlSubdomain(domain.getSmlSubdomain()); - serviceGroupRo.getServiceMetadata().add(smdro); + ServiceMetadataRO smdro = new ServiceMetadataRO(); + smdro.setDocumentIdentifier(subresource.getIdentifierValue()); + smdro.setDocumentIdentifierScheme(subresource.getIdentifierScheme()); + smdro.setDomainCode(domain.getDomainCode()); + smdro.setSmlSubdomain(domain.getSmlSubdomain()); + serviceGroupRo.getServiceMetadata().add(smdro); }); diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIServiceGroupService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIServiceGroupService.java index 52fbe52f1c8d009556f6fda415167887d1e64431..b3e3c33791914340dc7a46e429dd238c1016077f 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIServiceGroupService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIServiceGroupService.java @@ -182,6 +182,7 @@ public class UIServiceGroupService extends UIServiceBase<DBResource, ServiceGrou if (!smlIntegrationService.isSMLIntegrationEnabled()) { return; } + /* for (ParticipantSMLRecord record : lstRecords) { if (record.getStatus() == SMLStatusEnum.REGISTER) { boolean result = smlIntegrationService.registerParticipantToSML(record.getParticipantIdentifier(), @@ -195,6 +196,8 @@ public class UIServiceGroupService extends UIServiceBase<DBResource, ServiceGrou updateServiceGroupDomainStatus(result, record); } } + + */ } protected void updateServiceGroupDomainStatus(boolean smlActionStatus, ParticipantSMLRecord record) { diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UISubresourceService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UISubresourceService.java index c5681ec80a030eaeaeffb43bb407bf22110b6bdb..2b2754f652d01da25a13d43cb51c4ee1ab685458 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UISubresourceService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UISubresourceService.java @@ -75,6 +75,9 @@ public class UISubresourceService { } resource.getSubresources().remove(subresource); subresourceDao.remove(subresource); + + + return conversionService.convert(subresource, SubresourceRO.class); } @@ -106,6 +109,8 @@ public class UISubresourceService { subresourceDao.persist(subresource); // create first member as admin user + + return conversionService.convert(subresource, SubresourceRO.class); } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/sml/SmlClientFactory.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/sml/SmlClientFactory.java index 5337dd3efbe3aa302faca0de8d2ed70af31fd9d5..6f4116ea7cbed2c44123cac577d2e02282905b9d 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/sml/SmlClientFactory.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/sml/SmlClientFactory.java @@ -38,12 +38,8 @@ import org.springframework.stereotype.Component; @Component public class SmlClientFactory { - private static final String SERVICE_METADATA_CONTEXT = "manageservicemetadata"; - private static final String IDENTIFIER_CONTEXT = "manageparticipantidentifier"; private static final SMPLogger LOG = SMPLoggerFactory.getLogger(SmlClientFactory.class); - private static final String CLIENT_CERT_HEADER_KEY = "Client-Cert"; - @Autowired ConfigurationService configurationService; @@ -52,7 +48,7 @@ public class SmlClientFactory { @Bean @Scope("prototype") - public IManageParticipantIdentifierWS create(String clientKeyAlias, String clientCertHttpHeader, boolean clientCertAuthentication) { + public IManageParticipantIdentifierWS create() { LOG.info("create IManageParticipantIdentifierWS"); @@ -61,14 +57,12 @@ public class SmlClientFactory { .setWsdlURL(ManageBusinessIdentifierService.class.getResource("/ManageBusinessIdentifierService-1.0.wsdl")); factory.setServiceName(ManageBusinessIdentifierService.SERVICE); factory.setEndpointName(ManageBusinessIdentifierService.ManageBusinessIdentifierServicePort); - IManageParticipantIdentifierWS smlPort = factory.create(IManageParticipantIdentifierWS.class); - - return smlPort; + return factory.create(IManageParticipantIdentifierWS.class); } @Bean @Scope("prototype") - public IManageServiceMetadataWS createSmp(String clientKeyAlias, String clientCertHttpHeader, boolean clientCertAuthentication) { + public IManageServiceMetadataWS createSmp() { LOG.info("create IManageServiceMetadataWS"); JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); @@ -76,7 +70,6 @@ public class SmlClientFactory { .setWsdlURL(ManageServiceMetadataService.class.getResource("/ManageServiceMetadataService-1.0.wsdl")); factory.setServiceName(ManageServiceMetadataService.SERVICE); factory.setEndpointName(ManageServiceMetadataService.ManageServiceMetadataServicePort); - IManageServiceMetadataWS smlPort = factory.create(IManageServiceMetadataWS.class); - return smlPort; + return factory.create(IManageServiceMetadataWS.class); } } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/sml/SmlConnector.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/sml/SmlConnector.java index bed087e00fb81eadb0e5e89c249be6113bfc714f..10b0c69cf320e8ee9bfd3b25260c0641afd87e6c 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/sml/SmlConnector.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/sml/SmlConnector.java @@ -17,10 +17,10 @@ import eu.europa.ec.bdmsl.ws.soap.BadRequestFault; import eu.europa.ec.bdmsl.ws.soap.IManageParticipantIdentifierWS; import eu.europa.ec.bdmsl.ws.soap.IManageServiceMetadataWS; import eu.europa.ec.bdmsl.ws.soap.NotFoundFault; +import eu.europa.ec.edelivery.smp.config.enums.SMPPropertyEnum; import eu.europa.ec.edelivery.smp.conversion.IdentifierService; import eu.europa.ec.edelivery.smp.data.model.DBDomain; import eu.europa.ec.edelivery.smp.data.ui.CertificateRO; -import eu.europa.ec.edelivery.smp.config.enums.SMPPropertyEnum; import eu.europa.ec.edelivery.smp.exceptions.ErrorCode; import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException; import eu.europa.ec.edelivery.smp.identifiers.Identifier; @@ -264,8 +264,7 @@ public class SmlConnector implements ApplicationContextAware { private IManageParticipantIdentifierWS getParticipantWSClient(DBDomain domain) { - IManageParticipantIdentifierWS iManageServiceMetadataWS = ctx.getBean(IManageParticipantIdentifierWS.class, getSmlClientKeyAliasForDomain(domain), - domain.getSmlClientCertHeader(), domain.isSmlClientCertAuth()); + IManageParticipantIdentifierWS iManageServiceMetadataWS = ctx.getBean(IManageParticipantIdentifierWS.class); // configure connection configureClient(IDENTIFIER_VALUE_CONTEXT, iManageServiceMetadataWS, domain); @@ -275,8 +274,7 @@ public class SmlConnector implements ApplicationContextAware { private IManageServiceMetadataWS getSMPManagerWSClient(DBDomain domain) { - IManageServiceMetadataWS iManageServiceMetadataWS = ctx.getBean(IManageServiceMetadataWS.class, - getSmlClientKeyAliasForDomain(domain), domain.getSmlClientCertHeader(), domain.isSmlClientCertAuth()); + IManageServiceMetadataWS iManageServiceMetadataWS = ctx.getBean(IManageServiceMetadataWS.class); // configure value connection configureClient(SERVICE_METADATA_CONTEXT, iManageServiceMetadataWS, domain); @@ -305,9 +303,7 @@ public class SmlConnector implements ApplicationContextAware { public void configureClient(String serviceEndpoint, Object smlPort, DBDomain domain) { String clientKeyAlias = getSmlClientKeyAliasForDomain(domain); - String clientCertHttpHeader = domain.getSmlClientCertHeader(); boolean clientCertAuthentication = domain.isSmlClientCertAuth(); - Client client = ClientProxy.getClient(smlPort); URL url = configurationService.getSMLIntegrationUrl(); if (url == null) { @@ -320,22 +316,12 @@ public class SmlConnector implements ApplicationContextAware { } catch (MalformedURLException e) { throw new IllegalArgumentException("Malformed SML URL: " + url, e); } + boolean useTLS = urlSMPManagment.getProtocol().equalsIgnoreCase("https"); Map<String, Object> requestContext = ((BindingProvider) smlPort).getRequestContext(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, urlSMPManagment.toString()); - // check if there is only one cert in keystore - if (!clientCertAuthentication && StringUtils.isBlank(clientKeyAlias)) { - List<CertificateRO> list = keystoreService.getKeystoreEntriesList(); - if (list.size() == 1) { - // set the default alias - clientKeyAlias = list.get(0).getAlias(); - } else if (list.isEmpty()) { - throw new IllegalStateException("Empty keystore! Import Key for SML authentication to keystore!"); - } else { - throw new IllegalStateException("More than one key in Keystore! Define alias for the domain SML authentication!"); - } - } + CertificateRO certificateRO = getClientCertificate(clientKeyAlias); if (!clientCertAuthentication && !useTLS) { LOG.warn("SML integration is wrongly configured. Uses 2-way-SSL HTTPS but URL is not HTTPS! Url: [{}].", urlSMPManagment); @@ -344,17 +330,33 @@ public class SmlConnector implements ApplicationContextAware { HTTPConduit httpConduit = (HTTPConduit) client.getConduit(); configureClientAuthentication(httpConduit, requestContext, - clientCertAuthentication ? clientCertHttpHeader : clientKeyAlias, + certificateRO, clientCertAuthentication, useTLS); configureFaultHandling(requestContext); configureProxy(httpConduit, urlSMPManagment); configurePayloadLogging(client); } + public CertificateRO getClientCertificate(String alias) { + List<CertificateRO> list = keystoreService.getKeystoreEntriesList(); + if (StringUtils.isBlank(alias)) { + // legacy behaviour - if only one certificate then there is no need to define it + if (list.size() == 1) { + return list.get(0); + } + throw new IllegalStateException("Invalid integration configuration. Missing Client cert configuration!"); + } + + return list.stream().filter(cert -> StringUtils.equalsIgnoreCase(alias, cert.getAlias())) + .findFirst().orElseThrow(() -> new IllegalStateException("Invalid integration configuration. Missing Client cert configuration!")); + + } + + + public void configureClientAuthentication(HTTPConduit httpConduit, Map<String, Object> requestContext, CertificateRO certificateRO, boolean clientCertAuthentication, boolean useTLS) { + LOG.info("Connect to SML (smlClientAuthentication: [{}] use Client-CertHeader: [{}])", certificateRO, clientCertAuthentication); - public void configureClientAuthentication(HTTPConduit httpConduit, Map<String, Object> requestContext, String smlClientAuthentication, boolean clientCertAuthentication, boolean useTLS) { - LOG.info("Connect to SML (smlClientAuthentication: {} use Client-CertHeader: {})", smlClientAuthentication, clientCertAuthentication); - if (StringUtils.isBlank(smlClientAuthentication)) { + if (certificateRO==null) { throw new IllegalStateException("SML integration is wrongly configured, at least one authentication option is required: 2-way-SSL or Client-Cert header"); } @@ -374,13 +376,13 @@ public class SmlConnector implements ApplicationContextAware { } if (!clientCertAuthentication) { - LOG.debug("SML X509 certificate authentication with alias {}.", smlClientAuthentication); - tlsParams.setCertAlias(smlClientAuthentication); + LOG.debug("SML X509 certificate authentication with alias [{}].", certificateRO.getAlias()); + tlsParams.setCertAlias(certificateRO.getAlias()); tlsParams.setKeyManagers(keystoreService.getKeyManagers()); } else { - LOG.debug("User Client cert header to authenticate to SML {}.", smlClientAuthentication); + LOG.debug("User Client cert header to authenticate to SML {}.", certificateRO.getClientCertHeader()); Map<String, List<String>> customHeaders = new HashMap<>(); - customHeaders.put(CLIENT_CERT_HEADER_KEY, Collections.singletonList(smlClientAuthentication)); + customHeaders.put(CLIENT_CERT_HEADER_KEY, Collections.singletonList(certificateRO.getClientCertHeader())); requestContext.put(MessageContext.HTTP_REQUEST_HEADERS, customHeaders); } if (useTLS) { diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/config/SmlIntegrationConfiguration.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/config/SmlIntegrationConfiguration.java index 84feda5328e12810eec0da67098957730c97a772..684d5766c3647de9d9b24e387db8f4a153f68bff 100644 --- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/config/SmlIntegrationConfiguration.java +++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/config/SmlIntegrationConfiguration.java @@ -50,7 +50,6 @@ public class SmlIntegrationConfiguration { defaultDomain.setSmlRegistered(false); defaultDomain.setSmlClientCertAuth(false); defaultDomain.setSmlClientKeyAlias("clientAlias"); - defaultDomain.setSmlClientCertHeader("clientCertClientHeader"); setThrowExceptionAfterParticipantCallCount(-1); setThrowException(null); } diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/AuditIntegrationTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/AuditIntegrationTest.java index 11e95d9145eda685c6d6d4eb2cb40fb68a3d6260..1f0fc7856e8e5c09814f40387f2206a28bf01be5 100644 --- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/AuditIntegrationTest.java +++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/AuditIntegrationTest.java @@ -17,7 +17,6 @@ import eu.europa.ec.edelivery.smp.data.enums.CredentialType; import eu.europa.ec.edelivery.smp.data.enums.VisibilityType; import eu.europa.ec.edelivery.smp.data.model.*; import eu.europa.ec.edelivery.smp.data.model.doc.DBResource; -import eu.europa.ec.edelivery.smp.data.model.doc.DBServiceGroupExtension; import eu.europa.ec.edelivery.smp.data.model.doc.DBSubresource; import eu.europa.ec.edelivery.smp.data.model.user.DBCertificate; import eu.europa.ec.edelivery.smp.data.model.user.DBCredential; @@ -65,7 +64,6 @@ public class AuditIntegrationTest extends AbstractBaseDao{ assertTrue(ar.isEntityClassAudited(DBDomain.class)); assertTrue(ar.isEntityClassAudited(DBUser.class)); assertTrue(ar.isEntityClassAudited(DBCertificate.class)); - assertTrue(ar.isEntityClassAudited(DBServiceGroupExtension.class)); assertTrue(ar.isEntityClassAudited(DBAlert.class)); } @@ -75,7 +73,6 @@ public class AuditIntegrationTest extends AbstractBaseDao{ DBDomain domain = createDBDomain(); Map<String, Object> alterVal = new HashMap<>(); alterVal.put("signatureKeyAlias", UUID.randomUUID().toString()); - alterVal.put("smlClientCertHeader", UUID.randomUUID().toString()); alterVal.put("smlClientKeyAlias", UUID.randomUUID().toString()); alterVal.put("smlSubdomain", UUID.randomUUID().toString()); diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/GroupMemberDaoTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/GroupMemberDaoTest.java index b2b377ab9c53b49e566ac06c8760051c584cba60..69edc50d32ed1d97c975fd5c1166d8d8564a9f5b 100644 --- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/GroupMemberDaoTest.java +++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/GroupMemberDaoTest.java @@ -1,16 +1,9 @@ package eu.europa.ec.edelivery.smp.data.dao; -import eu.europa.ec.edelivery.smp.conversion.DBGroupToGroupROConverter; import eu.europa.ec.edelivery.smp.data.enums.MembershipRoleType; -import eu.europa.ec.edelivery.smp.data.model.DBDomain; import eu.europa.ec.edelivery.smp.data.model.DBGroup; -import eu.europa.ec.edelivery.smp.data.model.doc.DBResource; -import eu.europa.ec.edelivery.smp.data.model.user.DBDomainMember; import eu.europa.ec.edelivery.smp.data.model.user.DBGroupMember; -import eu.europa.ec.edelivery.smp.data.model.user.DBResourceMember; import eu.europa.ec.edelivery.smp.data.model.user.DBUser; -import eu.europa.ec.edelivery.smp.testutil.TestConstants; -import eu.europa.ec.edelivery.smp.testutil.TestDBUtils; import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Test; @@ -20,11 +13,12 @@ import java.util.Collections; import java.util.List; import static org.junit.Assert.*; + /** * @author Joze Rihtarsic * @since 5.0 */ -public class GroupMemberDaoTest extends AbstractBaseDao { +public class GroupMemberDaoTest extends AbstractBaseDao { @Autowired GroupMemberDao testInstance; @@ -110,7 +104,7 @@ public class GroupMemberDaoTest extends AbstractBaseDao { member.setRole(MembershipRoleType.VIEWER); testUtilsDao.persistFlushDetach(member); - boolean result = testInstance.isUserAnyDomainGroupResourceMemberWithRole(user, testUtilsDao.getD1(),MembershipRoleType.VIEWER); + boolean result = testInstance.isUserAnyDomainGroupResourceMemberWithRole(user, testUtilsDao.getD1(), MembershipRoleType.VIEWER); assertTrue(result); result = testInstance.isUserAnyDomainGroupResourceMemberWithRole(user, testUtilsDao.getD1(), MembershipRoleType.ADMIN); assertFalse(result); diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/ResourceDaoSearchTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/ResourceDaoSearchTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2f3da56a58f96c840ee494e2a15194ab7c9770f2 --- /dev/null +++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/ResourceDaoSearchTest.java @@ -0,0 +1,74 @@ +package eu.europa.ec.edelivery.smp.data.dao; + + +import eu.europa.ec.edelivery.smp.data.enums.MembershipRoleType; +import eu.europa.ec.edelivery.smp.data.model.DBDomain; +import eu.europa.ec.edelivery.smp.data.model.DBGroup; +import eu.europa.ec.edelivery.smp.data.model.doc.DBDocument; +import eu.europa.ec.edelivery.smp.data.model.doc.DBResource; +import eu.europa.ec.edelivery.smp.data.model.doc.DBResourceFilter; +import eu.europa.ec.edelivery.smp.data.model.ext.DBResourceDef; +import eu.europa.ec.edelivery.smp.data.model.user.DBUser; +import eu.europa.ec.edelivery.smp.testutil.TestDBUtils; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.transaction.Transactional; +import java.util.List; +import java.util.Optional; + +import static eu.europa.ec.edelivery.smp.testutil.TestConstants.*; + +/** + * Purpose of class is to test all resource methods with database. + * + * @author Joze Rihtarsic + * @since 5.0 + */ + +public class ResourceDaoSearchTest extends AbstractBaseDao { + + private static final Logger LOG = LoggerFactory.getLogger(ResourceDaoSearchTest.class); + @Autowired + ResourceDao testInstance; + + @Before + public void prepareDatabase() { + // setup initial data! + testUtilsDao.clearData(); + testUtilsDao.createResourcePrivateInternalMemberships(); + + + } + + @Test + public void getAllPublicResources() { + List<DBResource> result = testInstance.getPublicResourcesSearch(-1,-1,null, null, null); + //System.out.println(result.get(0)); + Assert.assertEquals(2, result.size()); + + + result = testInstance.getPublicResourcesSearch(-1,-1,testUtilsDao.getUser1(), null, null); + //System.out.println(result.get(0)); + Assert.assertEquals(3, result.size()); + + } + + @Test + public void getAllPublicResourcesCount() { + Long result = testInstance.getPublicResourcesSearchCount(null, null, null); + //System.out.println(result.get(0)); + Assert.assertEquals(2, result.intValue()); + + + result = testInstance.getPublicResourcesSearchCount(testUtilsDao.getUser1(), null, null); + //System.out.println(result.get(0)); + Assert.assertEquals(3, result.intValue()); + + } + +} diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/TestUtilsDao.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/TestUtilsDao.java index dfc9e1fcbfaa8f8bccca57c189460d9d888db7eb..e54128c029f395945bace1be48f29d971f94829c 100644 --- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/TestUtilsDao.java +++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/data/dao/TestUtilsDao.java @@ -1,6 +1,7 @@ package eu.europa.ec.edelivery.smp.data.dao; import eu.europa.ec.edelivery.smp.data.enums.MembershipRoleType; +import eu.europa.ec.edelivery.smp.data.enums.VisibilityType; import eu.europa.ec.edelivery.smp.data.model.DBDomain; import eu.europa.ec.edelivery.smp.data.model.DBDomainResourceDef; import eu.europa.ec.edelivery.smp.data.model.DBGroup; @@ -77,6 +78,8 @@ public class TestUtilsDao { DBResourceMember resourceMemberU1R1_D2G1RD1_Admin; DBResourceMember resourceMemberU1R2_D2G1RD1_Viewer; + DBResource resourcePrivateD1G1RD1; + // DBResource resourceInternalD1G1RD1; DBExtension extension; @@ -113,6 +116,9 @@ public class TestUtilsDao { resourceMemberU1R1_D2G1RD1_Admin = null; resourceMemberU1R2_D2G1RD1_Viewer = null; + resourcePrivateD1G1RD1 = null; + //resourceInternalD1G1RD1 = null; + extension = null; } @@ -259,6 +265,7 @@ public class TestUtilsDao { resourceMemberU1R1_D2G1RD1_Admin = createResourceMembership(MembershipRoleType.ADMIN, user1, resourceD1G1RD1); resourceMemberU1R2_D2G1RD1_Viewer = createResourceMembership(MembershipRoleType.VIEWER, user1, resourceD2G1RD1); + persistFlushDetach(resourceMemberU1R1_D2G1RD1_Admin); persistFlushDetach(resourceMemberU1R2_D2G1RD1_Viewer); @@ -266,6 +273,41 @@ public class TestUtilsDao { assertNotNull(resourceMemberU1R2_D2G1RD1_Viewer.getId()); } + @Transactional + public void createResourcePrivateInternalMemberships() { + if (resourcePrivateD1G1RD1 != null) { + LOG.trace("privateInternalMemberships are already initialized!"); + return; + } + createResourceMemberships(); + + resourcePrivateD1G1RD1 = TestDBUtils.createDBResource(TEST_SG_ID_1+"Private", TEST_SG_SCHEMA_1, true); + resourcePrivateD1G1RD1.setVisibility(VisibilityType.PRIVATE); + resourcePrivateD1G1RD1.setGroup(groupD1G1); + resourcePrivateD1G1RD1.setDomainResourceDef(domainResourceDefD1R1); + /* + resourceInternalD1G1RD1 = TestDBUtils.createDBResource(TEST_SG_ID_1+"Internal", TEST_SG_SCHEMA_1, true); + resourceInternalD1G1RD1.setVisibility(VisibilityType.PRIVATE); + resourceInternalD1G1RD1.setGroup(groupD1G1); + resourceInternalD1G1RD1.setDomainResourceDef(domainResourceDefD1R1); + + */ + + //persistFlushDetach(resourceInternalD1G1RD1); + persistFlushDetach(resourcePrivateD1G1RD1); + + //assertNotNull(resourceInternalD1G1RD1.getId()); + assertNotNull(resourcePrivateD1G1RD1.getId()); + + + + DBResourceMember privateRM_U1R1_D1G1Admin = createResourceMembership(MembershipRoleType.ADMIN, user1, resourcePrivateD1G1RD1); + //DBResourceMember internalRM_U1R1_D1G1Viewer = createResourceMembership(MembershipRoleType.VIEWER, user1, resourceInternalD1G1RD1); + + persistFlushDetach(privateRM_U1R1_D1G1Admin); + // persistFlushDetach(internalRM_U1R1_D1G1Viewer); + } + public DBDomainMember createDomainMembership(MembershipRoleType roleType, DBUser user, DBDomain domain){ DBDomainMember domainMember = new DBDomainMember(); domainMember.setRole(roleType); diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/SMLIntegrationServiceNoSMLIntegrationTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/SMLIntegrationServiceNoSMLIntegrationTest.java index fb263ff2103a417b1e5dd88f80e6f419d7394d9a..d4dca15eab5b2f87fa51143d84a50daa1561229a 100644 --- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/SMLIntegrationServiceNoSMLIntegrationTest.java +++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/SMLIntegrationServiceNoSMLIntegrationTest.java @@ -76,7 +76,7 @@ public class SMLIntegrationServiceNoSMLIntegrationTest extends AbstractServiceIn testInstance.unRegisterDomain(testDomain01); } - +/* @Test public void registerOnlyParticipantDomainToSml() { @@ -85,6 +85,6 @@ public class SMLIntegrationServiceNoSMLIntegrationTest extends AbstractServiceIn // when testInstance.registerParticipant(TEST_SG_ID_1, TEST_SG_SCHEMA_1, TEST_DOMAIN_CODE_1); } - +*/ } diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/SMLIntegrationServiceTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/SMLIntegrationServiceTest.java index e63bee6ff03e01ddbcf312fa77a69d710b0751cc..585c3a090ea27c4389e8dd2e95040a2a3c50d093 100644 --- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/SMLIntegrationServiceTest.java +++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/SMLIntegrationServiceTest.java @@ -126,7 +126,7 @@ public class SMLIntegrationServiceTest extends AbstractServiceIntegrationTest { Mockito.verifyNoMoreInteractions(integrationMock.getSmpManagerClientMocks().toArray()); } - +/* @Test public void registerParticipant() throws NotFoundFault, UnauthorizedFault, InternalErrorFault, BadRequestFault { /* given (init database - check setup) @@ -134,7 +134,8 @@ public class SMLIntegrationServiceTest extends AbstractServiceIntegrationTest { * Users: USERNAME_1, USER_CERT_2 * ServiceGroup1: TEST_SG_ID_1, TEST_SG_SCHEMA_1 * - Domain: TEST_DOMAIN_CODE_1 - */ + * + // when testInstance.registerParticipant(TEST_SG_ID_1, TEST_SG_SCHEMA_1, TEST_DOMAIN_CODE_1); @@ -152,7 +153,7 @@ public class SMLIntegrationServiceTest extends AbstractServiceIntegrationTest { * Users: USERNAME_1, USER_CERT_2 * ServiceGroup1: TEST_SG_ID_NO_SCHEME, null * - Domain: TEST_DOMAIN_CODE_1 - */ + * // when testInstance.registerParticipant(TEST_SG_ID_NO_SCHEME, null, TEST_DOMAIN_CODE_1); @@ -170,7 +171,7 @@ public class SMLIntegrationServiceTest extends AbstractServiceIntegrationTest { * Users: USERNAME_1, USER_CERT_2 * ServiceGroup1: TEST_SG_ID_1, TEST_SG_SCHEMA_1 * - Domain: TEST_DOMAIN_CODE_1 - */ + * // when testInstance.registerParticipant(TEST_SG_ID_1, TEST_SG_SCHEMA_1, TEST_DOMAIN_CODE_1); @@ -200,7 +201,7 @@ public class SMLIntegrationServiceTest extends AbstractServiceIntegrationTest { testInstance.registerParticipant(TEST_SG_ID_1, TEST_SG_SCHEMA_1, TEST_DOMAIN_CODE_2); } - +*/ @Test public void registerParticipantToSML() throws NotFoundFault, UnauthorizedFault, InternalErrorFault, BadRequestFault { DBDomain testDomain01 = domainDao.getDomainByCode(TEST_DOMAIN_CODE_1).get(); @@ -212,7 +213,7 @@ public class SMLIntegrationServiceTest extends AbstractServiceIntegrationTest { verify(integrationMock.getParticipantManagmentClientMocks().get(0)).create(any()); Mockito.verifyNoMoreInteractions(integrationMock.getParticipantManagmentClientMocks().toArray()); } - +/* @Test public void unregisterParticipantFromSML() throws NotFoundFault, UnauthorizedFault, InternalErrorFault, BadRequestFault { DBDomain testDomain01 = domainDao.getDomainByCode(TEST_DOMAIN_CODE_1).get(); @@ -225,4 +226,6 @@ public class SMLIntegrationServiceTest extends AbstractServiceIntegrationTest { verify(integrationMock.getParticipantManagmentClientMocks().get(0)).delete(any()); Mockito.verifyNoMoreInteractions(integrationMock.getParticipantManagmentClientMocks().toArray()); } + + */ } diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainServiceTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainServiceTest.java index 9813f4592b3fec979bb9b74b03eb3ed6384d326f..be69c4b1afaee4dfe2c1bf50ba264d755820676a 100644 --- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainServiceTest.java +++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainServiceTest.java @@ -58,7 +58,6 @@ public class UIDomainServiceTest extends AbstractServiceTest { domainRO.setSmlSubdomain("New SmlSubdomain"); domainRO.setSmlSmpId("NewSmlSmpId"); domainRO.setSmlClientKeyAlias("NewClientKeyAlias"); - domainRO.setSmlClientCertHeader("NewtCertHeader"); domainRO.setSmlClientCertAuth(false); DBDomain domain = testUtilsDao.getD1(); testInstance.updateDomainSmlIntegrationData(domain.getId(), domainRO); @@ -67,7 +66,6 @@ public class UIDomainServiceTest extends AbstractServiceTest { assertEquals(domainRO.getSmlSubdomain(), result.getSmlSubdomain()); assertEquals(domainRO.getSmlSmpId(), result.getSmlSmpId()); assertEquals(domainRO.getSmlClientKeyAlias(), result.getSmlClientKeyAlias()); - assertEquals(domainRO.getSmlClientCertHeader(), result.getSmlClientCertHeader()); assertEquals(domainRO.isSmlClientCertAuth(), result.isSmlClientCertAuth()); } diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/sml/SmlClientFactoryAuthenticationByClientCertFromKeystoreTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/sml/SmlClientFactoryAuthenticationByClientCertFromKeystoreTest.java index f82c629c5312e67446b8aff10c8bfc06afd6f1c6..20b9efdc96ff4e2e336cc0deb0c0df821b9b26d8 100644 --- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/sml/SmlClientFactoryAuthenticationByClientCertFromKeystoreTest.java +++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/sml/SmlClientFactoryAuthenticationByClientCertFromKeystoreTest.java @@ -95,7 +95,7 @@ public class SmlClientFactoryAuthenticationByClientCertFromKeystoreTest extends @Test public void factoryProducesPreconfiguredCxfClientThatAuthenticatesItselfWithGivenCertAlias() { //given - IManageParticipantIdentifierWS client = smlClientFactory.create(null, null, false); + IManageParticipantIdentifierWS client = smlClientFactory.create(); DBDomain domain = new DBDomain(); domain.setSmlClientKeyAlias("second_domain_alias"); domain.setSmlClientCertAuth(false); @@ -121,7 +121,7 @@ public class SmlClientFactoryAuthenticationByClientCertFromKeystoreTest extends public void factoryProducesPreconfiguredCxfSMPClientThatAuthenticatesItselfWithGivenCertAlias() { //given - IManageServiceMetadataWS client = smlClientFactory.createSmp(null, null, false); + IManageServiceMetadataWS client = smlClientFactory.createSmp(); DBDomain domain = new DBDomain(); domain.setSmlClientKeyAlias("second_domain_alias"); domain.setSmlClientCertAuth(false); @@ -144,7 +144,7 @@ public class SmlClientFactoryAuthenticationByClientCertFromKeystoreTest extends @Test public void factoryProducesClientWithAnotherCertFromKeystore() { //given - IManageParticipantIdentifierWS client = smlClientFactory.create(null, null, false); + IManageParticipantIdentifierWS client = smlClientFactory.create(); DBDomain domain = new DBDomain(); domain.setSmlClientKeyAlias("single_domain_key"); domain.setSmlClientCertAuth(false); @@ -165,7 +165,7 @@ public class SmlClientFactoryAuthenticationByClientCertFromKeystoreTest extends public void factoryProducesSMPClientWithAnotherCertFromKeystore() { //given - IManageServiceMetadataWS client = smlClientFactory.createSmp(null, null, false); + IManageServiceMetadataWS client = smlClientFactory.createSmp(); DBDomain domain = new DBDomain(); domain.setSmlClientKeyAlias("single_domain_key"); domain.setSmlClientCertAuth(false); @@ -185,7 +185,7 @@ public class SmlClientFactoryAuthenticationByClientCertFromKeystoreTest extends @Test public void factoryProducesClientNoDefinedAlias() { //given - IManageParticipantIdentifierWS client = smlClientFactory.create(null, null, false); + IManageParticipantIdentifierWS client = smlClientFactory.create(); DBDomain domain = new DBDomain(); domain.setSmlClientKeyAlias(null); domain.setSmlClientCertAuth(false); @@ -203,7 +203,7 @@ public class SmlClientFactoryAuthenticationByClientCertFromKeystoreTest extends public void factoryProducesSMPClientNoDefinedAlias() { //given - IManageServiceMetadataWS client = smlClientFactory.createSmp(null, null, false); + IManageServiceMetadataWS client = smlClientFactory.createSmp(); DBDomain domain = new DBDomain(); domain.setSmlClientKeyAlias(null); domain.setSmlClientCertAuth(false); @@ -225,7 +225,7 @@ public class SmlClientFactoryAuthenticationByClientCertFromKeystoreTest extends keystoreService.refreshData(); - IManageParticipantIdentifierWS client = smlClientFactory.create(null, null, false); + IManageParticipantIdentifierWS client = smlClientFactory.create(); DBDomain domain = new DBDomain(); domain.setSmlClientKeyAlias(null); domain.setSmlClientCertAuth(false); diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/sml/SmlClientFactoryAuthenticationByClientCertHttpHeader.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/sml/SmlClientFactoryAuthenticationByClientCertHttpHeader.java index 84510f88b5ebdb541b1a191df39a721534839de9..b714eccb3b7f6d6500809b2e3404b2b69c80a5bb 100644 --- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/sml/SmlClientFactoryAuthenticationByClientCertHttpHeader.java +++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/sml/SmlClientFactoryAuthenticationByClientCertHttpHeader.java @@ -71,9 +71,8 @@ public class SmlClientFactoryAuthenticationByClientCertHttpHeader extends Abstra @Test public void factoryProducesPreconfiguredCxfClientThatAuthenticatesItselfWithGivenCertAlias() { //given - IManageParticipantIdentifierWS client = smlClientFactory.create(null, null, false); + IManageParticipantIdentifierWS client = smlClientFactory.create(); DBDomain domain = new DBDomain(); - domain.setSmlClientCertHeader(CLIENT_CERT_HTTP_HEADER); domain.setSmlClientCertAuth(true); // when testInstance.configureClient("manageparticipantidentifier", client, domain); @@ -94,9 +93,8 @@ public class SmlClientFactoryAuthenticationByClientCertHttpHeader extends Abstra public void factoryProducesPreconfiguredCxfSMPClientThatAuthenticatesItselfWithGivenCertAlias() { //given - IManageServiceMetadataWS client = smlClientFactory.createSmp(null, null, false); + IManageServiceMetadataWS client = smlClientFactory.createSmp(); DBDomain domain = new DBDomain(); - domain.setSmlClientCertHeader(CLIENT_CERT_HTTP_HEADER); domain.setSmlClientCertAuth(true); // when testInstance.configureClient("manageservicemetadata", client, domain); @@ -117,7 +115,7 @@ public class SmlClientFactoryAuthenticationByClientCertHttpHeader extends Abstra public void factoryProducesSMPClientNoDefinedAlias() { //given - IManageServiceMetadataWS client = smlClientFactory.createSmp(null, null, false); + IManageServiceMetadataWS client = smlClientFactory.createSmp(); DBDomain domain = new DBDomain(); domain.setSmlClientKeyAlias(null); domain.setSmlClientCertAuth(true); diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/TestDBUtils.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/TestDBUtils.java index 4bc491eeb01adb174aea9cc5edbb896da615ea19..7efc4cf24dea9201ffaf9a531141ed8c06b24e5e 100644 --- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/TestDBUtils.java +++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/testutil/TestDBUtils.java @@ -31,7 +31,6 @@ public class TestDBUtils { DBDomain domain = new DBDomain(); domain.setDomainCode(domainCode); domain.setSignatureKeyAlias(anyString()); - domain.setSmlClientCertHeader(anyString()); domain.setSmlClientKeyAlias(anyString()); domain.setSmlSubdomain(anyString()); domain.setSmlSmpId(anyString()); @@ -159,6 +158,7 @@ public class TestDBUtils { DBResource resource = new DBResource(); resource.setIdentifierValue(id); resource.setIdentifierScheme(sch); + resource.setVisibility(VisibilityType.PUBLIC); if (withExtension) { DBDocument document = createDBDocument(); DBDocumentVersion documentVersion = createDBDocumentVersion(); diff --git a/smp-server-library/src/test/resources/cleanup-database.sql b/smp-server-library/src/test/resources/cleanup-database.sql index 1a7873843bee16c7cfe25f0426b9ea340b69fe36..db26999a5b8bb568807c9060f426983775183a46 100755 --- a/smp-server-library/src/test/resources/cleanup-database.sql +++ b/smp-server-library/src/test/resources/cleanup-database.sql @@ -1,7 +1,3 @@ --- delete this table once is removed -DELETE FROM SMP_SG_EXTENSION; -DELETE FROM SMP_SG_EXTENSION_AUD; - DELETE FROM SMP_ALERT; DELETE FROM SMP_ALERT_AUD; DELETE FROM SMP_ALERT_PROPERTY; diff --git a/smp-soapui-tests/groovy/mysql-4.1_integration_test_data.sql b/smp-soapui-tests/groovy/mysql-4.1_integration_test_data.sql index 6236e0929b308b7325657304f5489205d603dacc..154f5797879c55553207aca2a963ddcfb55ac2cc 100644 --- a/smp-soapui-tests/groovy/mysql-4.1_integration_test_data.sql +++ b/smp-soapui-tests/groovy/mysql-4.1_integration_test_data.sql @@ -36,8 +36,8 @@ insert into SMP_CERTIFICATE (ID, CERTIFICATE_ID, SUBJECT, ISSUER, SERIALNUMBER,V (14, 'CN=EHEALTH_z_ẞ_W_,O=European_z_ẞ_W_Commission,C=BE:f71ee8b11cb3b787','CN=EHEALTH_z_ẞ_W_,O=European_z_ẞ_W_Commission,C=BE','CN=EHEALTH_z_ẞ_W_,O=European_z_ẞ_W_Commission,C=BE','f71ee8b11cb3b787', date_add(NOW(),interval -1 year), date_add(NOW(),interval 1 year), NOW(), NOW()); -insert into SMP_DOMAIN (ID, DOMAIN_CODE, VISIBILITY, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_CLIENT_CERT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values -(1, 'testdomain','PUBLIC', 'test-domain', 'CEF-SMP-002','sample_key',1,0, NOW(), NOW()); +insert into SMP_DOMAIN (ID, DOMAIN_CODE, VISIBILITY, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_CLIENT_KEY_ALIAS, SML_CLIENT_CERT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values +(1, 'testdomain','PUBLIC', 'test-domain', 'CEF-SMP-002','sample_key','smp_domain_01',1,0, NOW(), NOW()); insert into SMP_EXTENSION ( ID, IDENTIFIER, IMPLEMENTATION_NAME, NAME, VERSION, DESCRIPTION, CREATED_ON, LAST_UPDATED_ON) values (1, 'edelivery-oasis-smp-extension', 'OasisSMPExtension','Oasis SMP 1.0 and 2.0','1.0', 'Oasis SMP 1.0 and 2.0 extension', NOW(), NOW()); diff --git a/smp-soapui-tests/groovy/oracle-4.1_integration_test_data.sql b/smp-soapui-tests/groovy/oracle-4.1_integration_test_data.sql index ad70067322cd58a37ca34b9fd6f7992e13329949..85be9de712c5599bb3098b43f558eeae08a0043d 100644 --- a/smp-soapui-tests/groovy/oracle-4.1_integration_test_data.sql +++ b/smp-soapui-tests/groovy/oracle-4.1_integration_test_data.sql @@ -1,5 +1,3 @@ -DELETE FROM SMP_SG_EXTENSION; -DELETE FROM SMP_SG_EXTENSION_AUD; DELETE FROM SMP_ALERT; DELETE FROM SMP_ALERT_AUD; @@ -98,8 +96,8 @@ insert into SMP_CERTIFICATE (ID, CERTIFICATE_ID, SUBJECT, ISSUER, SERIALNUMBER,V (14, 'CN=EHEALTH_z_ẞ_W_,O=European_z_ẞ_W_Commission,C=BE:f71ee8b11cb3b787','CN=EHEALTH_z_ẞ_W_,O=European_z_ẞ_W_Commission,C=BE','CN=EHEALTH_z_ẞ_W_,O=European_z_ẞ_W_Commission,C=BE','f71ee8b11cb3b787', sysdate - 365, sysdate + 365, sysdate, sysdate); -insert into SMP_DOMAIN (ID, DOMAIN_CODE, VISIBILITY, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_CLIENT_CERT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values -(1, 'testdomain','PUBLIC', 'test-domain', 'CEF-SMP-002','sample_key',1,0, sysdate, sysdate); +insert into SMP_DOMAIN (ID, DOMAIN_CODE, VISIBILITY, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS,SML_CLIENT_KEY_ALIAS, SML_CLIENT_CERT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values +(1, 'testdomain','PUBLIC', 'test-domain', 'CEF-SMP-002','sample_key','sample_key',1,0, sysdate, sysdate); insert into SMP_GROUP (ID, FK_DOMAIN_ID, NAME, VISIBILITY, CREATED_ON, LAST_UPDATED_ON) values (1, 1, 'Test group', 'PUBLIC', sysdate, sysdate); diff --git a/smp-webapp/pom.xml b/smp-webapp/pom.xml index a24778bc65d3f16949711562509a86c0f83488c0..c511d272ad563a473cc6ae6ed3319499b56fc8ca 100644 --- a/smp-webapp/pom.xml +++ b/smp-webapp/pom.xml @@ -10,8 +10,6 @@ <packaging>war</packaging> <name>smp-webapp</name> <description>SMP REST service WEB APP</description> - - <properties> <maven.deploy.skip>false</maven.deploy.skip> <buildtimestamp>${maven.build.timestamp}</buildtimestamp> diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/edit/SubresourceEditController.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/edit/SubresourceEditController.java index 5f0935abc703934ff020f068c624fa375f3af5d1..99f98db9e3912d80fc0d1356af0b6167a1561979 100644 --- a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/edit/SubresourceEditController.java +++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/edit/SubresourceEditController.java @@ -1,20 +1,12 @@ package eu.europa.ec.edelivery.smp.ui.edit; -import eu.europa.ec.edelivery.smp.data.enums.MembershipRoleType; -import eu.europa.ec.edelivery.smp.data.ui.MemberRO; -import eu.europa.ec.edelivery.smp.data.ui.ResourceRO; -import eu.europa.ec.edelivery.smp.data.ui.ServiceResult; import eu.europa.ec.edelivery.smp.data.ui.SubresourceRO; -import eu.europa.ec.edelivery.smp.exceptions.ErrorCode; -import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException; import eu.europa.ec.edelivery.smp.logging.SMPLogger; import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory; -import eu.europa.ec.edelivery.smp.services.ui.UIResourceService; import eu.europa.ec.edelivery.smp.services.ui.UISubresourceService; import eu.europa.ec.edelivery.smp.ui.ResourceConstants; import eu.europa.ec.edelivery.smp.utils.SessionSecurityUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.util.MimeTypeUtils; import org.springframework.web.bind.annotation.*; @@ -24,7 +16,6 @@ import java.util.List; import static eu.europa.ec.edelivery.smp.ui.ResourceConstants.*; /** - * * @author Joze Rihtarsic * @since 5.0 */ @@ -50,7 +41,7 @@ public class SubresourceEditController { @PreAuthorize("@smpAuthorizationService.isCurrentlyLoggedIn(#userEncId) " + " and @smpAuthorizationService.isResourceMember(#resourceEncId) ") public List<SubresourceRO> getSubResourcesForResource(@PathVariable(PATH_PARAM_ENC_USER_ID) String userEncId, - @PathVariable(PATH_PARAM_ENC_RESOURCE_ID) String resourceEncId) { + @PathVariable(PATH_PARAM_ENC_RESOURCE_ID) String resourceEncId) { Long resourceId = SessionSecurityUtils.decryptEntityId(resourceEncId); logAdminAccess("getSubResourcesForResource: " + resourceId); @@ -60,10 +51,10 @@ public class SubresourceEditController { @DeleteMapping(path = SUB_CONTEXT_PATH_EDIT_SUBRESOURCE_DELETE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE) @PreAuthorize("@smpAuthorizationService.isCurrentlyLoggedIn(#userEncId) " + " and @smpAuthorizationService.isResourceMember(#resourceEncId) ") - public SubresourceRO deleteResourceFromGroup(@PathVariable(PATH_PARAM_ENC_USER_ID) String userEncId, - @PathVariable(PATH_PARAM_ENC_RESOURCE_ID) String resourceEncId, - @PathVariable(PATH_PARAM_ENC_SUBRESOURCE_ID) String subresourceEncId) { - logAdminAccess("deleteResourceFromGroup"); + public SubresourceRO deleteSubresourceFromGroup(@PathVariable(PATH_PARAM_ENC_USER_ID) String userEncId, + @PathVariable(PATH_PARAM_ENC_RESOURCE_ID) String resourceEncId, + @PathVariable(PATH_PARAM_ENC_SUBRESOURCE_ID) String subresourceEncId) { + logAdminAccess("deleteSubresourceFromGroup"); Long resourceId = SessionSecurityUtils.decryptEntityId(resourceEncId); Long subresourceId = SessionSecurityUtils.decryptEntityId(subresourceEncId); return uiSubresourceService.deleteSubresourceFromResource(subresourceId, resourceId); @@ -73,8 +64,8 @@ public class SubresourceEditController { @PreAuthorize("@smpAuthorizationService.isCurrentlyLoggedIn(#userEncId) " + " and @smpAuthorizationService.isResourceMember(#resourceEncId) ") public SubresourceRO createSubresource(@PathVariable(PATH_PARAM_ENC_USER_ID) String userEncId, - @PathVariable(PATH_PARAM_ENC_RESOURCE_ID) String resourceEncId, - @RequestBody SubresourceRO subresourceRO) { + @PathVariable(PATH_PARAM_ENC_RESOURCE_ID) String resourceEncId, + @RequestBody SubresourceRO subresourceRO) { logAdminAccess("createSubresource"); Long subresourceId = SessionSecurityUtils.decryptEntityId(resourceEncId); return uiSubresourceService.createResourceForGroup(subresourceRO, subresourceId); diff --git a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-data.sql b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-data.sql index 73865c521d19acf366273fdd70ae00bfb2d09f35..2097540b3f00a0433ea2aea6e2ac7f06a2092134 100644 --- a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-data.sql +++ b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-data.sql @@ -7,8 +7,8 @@ insert into SMP_CREDENTIAL (ID, FK_USER_ID, CREDENTIAL_ACTIVE, CREDENTIAL_NAME, (2, 2, 1, 'user', '$2a$06$FDmjewn/do3C219uysNm9.XG8mIn.ubHnMydAzC8lsv61HsRpOR36', 'USERNAME_PASSWORD','UI', NOW(), NOW()); -insert into SMP_DOMAIN (ID, DOMAIN_CODE, VISIBILITY, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_CLIENT_CERT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values -(1, 'testdomain','PUBLIC', 'test-domain', 'DOMI-SMP-001','sample_key',1,0, NOW(), NOW()); +insert into SMP_DOMAIN (ID, DOMAIN_CODE, VISIBILITY, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_CLIENT_KEY_ALIAS, SML_CLIENT_CERT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values +(1, 'testdomain','PUBLIC', 'test-domain', 'DOMI-SMP-001','sample_key','smp_domain_01',1,0, NOW(), NOW()); insert into SMP_GROUP (ID, FK_DOMAIN_ID, NAME, VISIBILITY, CREATED_ON, LAST_UPDATED_ON) values (1, 1, 'Test group', 'PUBLIC', NOW(), NOW()); diff --git a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-drop.ddl b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-drop.ddl index 2a844489ddfa4ed58f458328896aeee1ffdc46ec..d4e8af153a8f1ea5fd7895b17b9362e3b77619b2 100644 --- a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-drop.ddl +++ b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-drop.ddl @@ -135,14 +135,6 @@ drop foreign key FKknykp2wcby9fxk234yaaix1pe; - alter table SMP_SG_EXTENSION - drop - foreign key FKc3joya5el7ke4ch8f76a4ad0s; - - alter table SMP_SG_EXTENSION_AUD - drop - foreign key FKmdo9v2422adwyebvl34qa3ap6; - alter table SMP_SUBRESOURCE drop foreign key FK7y1ydnq350mbs3c8yrq2fhnsk; @@ -237,10 +229,6 @@ drop table if exists SMP_REV_INFO; - drop table if exists SMP_SG_EXTENSION; - - drop table if exists SMP_SG_EXTENSION_AUD; - drop table if exists SMP_SUBRESOURCE; drop table if exists SMP_SUBRESOURCE_AUD; diff --git a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb.ddl b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb.ddl index cc9eb935dffdbb83a30ae7024aa00a5607c337c1..eca731eb51360ac34b7d523abe532c36153cf871 100644 --- a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb.ddl +++ b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb.ddl @@ -207,7 +207,6 @@ SIGNATURE_DIGEST_METHOD varchar(256) CHARACTER SET utf8 COLLATE utf8_bin comment 'Set signature hash method. Ex.: http://www.w3.org/2001/04/xmlenc#sha256', SIGNATURE_KEY_ALIAS varchar(256) CHARACTER SET utf8 COLLATE utf8_bin comment 'Signature key alias used for SML integration', SML_CLIENT_CERT_AUTH bit not null comment 'Flag for SML authentication type - use ClientCert header or HTTPS ClientCertificate (key)', - SML_CLIENT_CERT_HEADER varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin comment 'Client-Cert header used behind RP - ClientCertHeader for SML integration', SML_CLIENT_KEY_ALIAS varchar(256) CHARACTER SET utf8 COLLATE utf8_bin comment 'Client key alias used for SML integration', SML_REGISTERED bit not null comment 'Flag for: Is domain registered in SML', SML_SMP_ID varchar(256) CHARACTER SET utf8 COLLATE utf8_bin comment 'SMP ID used for SML integration', @@ -228,7 +227,6 @@ SIGNATURE_DIGEST_METHOD varchar(256) CHARACTER SET utf8 COLLATE utf8_bin, SIGNATURE_KEY_ALIAS varchar(256) CHARACTER SET utf8 COLLATE utf8_bin, SML_CLIENT_CERT_AUTH bit, - SML_CLIENT_CERT_HEADER varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin, SML_CLIENT_KEY_ALIAS varchar(256) CHARACTER SET utf8 COLLATE utf8_bin, SML_REGISTERED bit, SML_SMP_ID varchar(256) CHARACTER SET utf8 COLLATE utf8_bin, @@ -441,24 +439,6 @@ primary key (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - create table SMP_SG_EXTENSION ( - ID bigint not null, - CREATED_ON datetime not null, - LAST_UPDATED_ON datetime not null, - EXTENSION longblob comment 'XML extension(s) for servicegroup ', - primary key (ID) - ) comment='Service group extension blob' ENGINE=InnoDB DEFAULT CHARSET=utf8; - - create table SMP_SG_EXTENSION_AUD ( - ID bigint not null, - REV bigint not null, - REVTYPE tinyint, - CREATED_ON datetime, - LAST_UPDATED_ON datetime, - EXTENSION longblob, - primary key (ID, REV) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - create table SMP_SUBRESOURCE ( ID bigint not null auto_increment comment 'Shared primary key with master table SMP_SUBRESOURCE', CREATED_ON datetime not null, @@ -775,16 +755,6 @@ create index SMP_SMD_DOC_SCH_IDX on SMP_SUBRESOURCE (IDENTIFIER_SCHEME); foreign key (REV) references SMP_REV_INFO (id); - alter table SMP_SG_EXTENSION - add constraint FKc3joya5el7ke4ch8f76a4ad0s - foreign key (ID) - references SMP_RESOURCE (ID); - - alter table SMP_SG_EXTENSION_AUD - add constraint FKmdo9v2422adwyebvl34qa3ap6 - foreign key (REV) - references SMP_REV_INFO (id); - alter table SMP_SUBRESOURCE add constraint FK7y1ydnq350mbs3c8yrq2fhnsk foreign key (FK_DOCUMENT_ID) diff --git a/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-data.sql b/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-data.sql index 3cffd4311a12f14ed129dddbe19bdcc2871575d3..44abff239940174988bc207f91b2740bb795b514 100644 --- a/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-data.sql +++ b/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-data.sql @@ -4,4 +4,5 @@ insert into SMP_USER (ID, USERNAME, PASSWORD, ROLE, ACTIVE, CREATED_ON, LAST_UPD -- insert domain -insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SIGNATURE_KEY_ALIAS,SML_BLUE_COAT_AUTH, SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (SMP_DOMAIN_SEQ.nextval, 'testDomain','domain','sample_key',1,0, sysdate, sysdate); +insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SIGNATURE_KEY_ALIAS, SML_CLIENT_KEY_ALIAS, SML_CLIENT_CERT_AUTH, SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values +(SMP_DOMAIN_SEQ.nextval, 'testDomain','domain','sample_key', 'smp_domain_01',1,0, sysdate, sysdate); diff --git a/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-drop.ddl b/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-drop.ddl index f50b3b22ddc07c4cf4d8a5876d330302279b0178..952ef7b688b5eb6ca3abb21bfbf939cee9b6cb44 100644 --- a/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-drop.ddl +++ b/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-drop.ddl @@ -69,10 +69,6 @@ drop table SMP_REV_INFO cascade constraints; - drop table SMP_SG_EXTENSION cascade constraints; - - drop table SMP_SG_EXTENSION_AUD cascade constraints; - drop table SMP_SUBRESOURCE cascade constraints; drop table SMP_SUBRESOURCE_AUD cascade constraints; diff --git a/smp-webapp/src/main/smp-setup/database-scripts/oracle10g.ddl b/smp-webapp/src/main/smp-setup/database-scripts/oracle10g.ddl index d8fb4266a74ae6a275ad4200134549accb77127f..09b563d16c4bd90f3a8911b8f3ead87986a289f5 100644 --- a/smp-webapp/src/main/smp-setup/database-scripts/oracle10g.ddl +++ b/smp-webapp/src/main/smp-setup/database-scripts/oracle10g.ddl @@ -333,7 +333,6 @@ create sequence SMP_USER_SEQ start with 1 increment by 1; SIGNATURE_DIGEST_METHOD varchar2(256 char), SIGNATURE_KEY_ALIAS varchar2(256 char), SML_CLIENT_CERT_AUTH number(1,0) not null, - SML_CLIENT_CERT_HEADER varchar2(4000 char), SML_CLIENT_KEY_ALIAS varchar2(256 char), SML_REGISTERED number(1,0) not null, SML_SMP_ID varchar2(256 char), @@ -366,9 +365,6 @@ create sequence SMP_USER_SEQ start with 1 increment by 1; comment on column SMP_DOMAIN.SML_CLIENT_CERT_AUTH is 'Flag for SML authentication type - use ClientCert header or HTTPS ClientCertificate (key)'; - comment on column SMP_DOMAIN.SML_CLIENT_CERT_HEADER is - 'Client-Cert header used behind RP - ClientCertHeader for SML integration'; - comment on column SMP_DOMAIN.SML_CLIENT_KEY_ALIAS is 'Client key alias used for SML integration'; @@ -396,7 +392,6 @@ create sequence SMP_USER_SEQ start with 1 increment by 1; SIGNATURE_DIGEST_METHOD varchar2(256 char), SIGNATURE_KEY_ALIAS varchar2(256 char), SML_CLIENT_CERT_AUTH number(1,0), - SML_CLIENT_CERT_HEADER varchar2(4000 char), SML_CLIENT_KEY_ALIAS varchar2(256 char), SML_REGISTERED number(1,0), SML_SMP_ID varchar2(256 char), @@ -642,30 +637,6 @@ create sequence SMP_USER_SEQ start with 1 increment by 1; primary key (id) ); - create table SMP_SG_EXTENSION ( - ID number(19,0) not null, - CREATED_ON timestamp not null, - LAST_UPDATED_ON timestamp not null, - EXTENSION blob, - primary key (ID) - ); - - comment on table SMP_SG_EXTENSION is - 'Service group extension blob'; - - comment on column SMP_SG_EXTENSION.EXTENSION is - 'XML extension(s) for servicegroup '; - - create table SMP_SG_EXTENSION_AUD ( - ID number(19,0) not null, - REV number(19,0) not null, - REVTYPE number(3,0), - CREATED_ON timestamp, - LAST_UPDATED_ON timestamp, - EXTENSION blob, - primary key (ID, REV) - ); - create table SMP_SUBRESOURCE ( ID number(19,0) not null, CREATED_ON timestamp not null, @@ -1024,16 +995,6 @@ create index SMP_SMD_DOC_SCH_IDX on SMP_SUBRESOURCE (IDENTIFIER_SCHEME); foreign key (REV) references SMP_REV_INFO; - alter table SMP_SG_EXTENSION - add constraint FKc3joya5el7ke4ch8f76a4ad0s - foreign key (ID) - references SMP_RESOURCE; - - alter table SMP_SG_EXTENSION_AUD - add constraint FKmdo9v2422adwyebvl34qa3ap6 - foreign key (REV) - references SMP_REV_INFO; - alter table SMP_SUBRESOURCE add constraint FK7y1ydnq350mbs3c8yrq2fhnsk foreign key (FK_DOCUMENT_ID) diff --git a/smp-webapp/src/test/resources/cleanup-database.sql b/smp-webapp/src/test/resources/cleanup-database.sql index 1a7873843bee16c7cfe25f0426b9ea340b69fe36..db26999a5b8bb568807c9060f426983775183a46 100755 --- a/smp-webapp/src/test/resources/cleanup-database.sql +++ b/smp-webapp/src/test/resources/cleanup-database.sql @@ -1,7 +1,3 @@ --- delete this table once is removed -DELETE FROM SMP_SG_EXTENSION; -DELETE FROM SMP_SG_EXTENSION_AUD; - DELETE FROM SMP_ALERT; DELETE FROM SMP_ALERT_AUD; DELETE FROM SMP_ALERT_PROPERTY; diff --git a/smp-webapp/src/test/resources/webapp_integration_test_data.sql b/smp-webapp/src/test/resources/webapp_integration_test_data.sql index db3ddeec33e361e9ae1169bf4e26b71ba5e2e8ad..cb98cb6b12087811ff3ccf8b0065d6e179f25b7c 100644 --- a/smp-webapp/src/test/resources/webapp_integration_test_data.sql +++ b/smp-webapp/src/test/resources/webapp_integration_test_data.sql @@ -94,9 +94,9 @@ insert into SMP_CERTIFICATE (ID, CERTIFICATE_ID, VALID_FROM, VALID_TO, CREATED_O -- insert into SMP_CERTIFICATE (ID, CERTIFICATE_ID, VALID_FROM, VALID_TO, CREATED_ON, LAST_UPDATED_ON) values (14, 'CN=GRP:TEST_\+\,& \=eau!,O=European Commission,C=BE:0000000000001234', null,null, NOW(), NOW()); -- -------------- -- Configure domains -insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS,SML_REGISTERED,SML_CLIENT_CERT_AUTH,SML_CLIENT_CERT_HEADER, CREATED_ON, LAST_UPDATED_ON) values -(1, 'domain','subdomain', 'CEF-SMP-001','single_domain_key',0,1,'SML_CLIENT_CERT_HEADER', NOW(), NOW()), -(2, 'domainTwo','newdomain', 'CEF-SMP-002','single_domain_key',0,1,'SML_CLIENT_CERT_HEADER', NOW(), NOW()); +insert into SMP_DOMAIN (ID, VISIBILITY, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS,SML_REGISTERED,SML_CLIENT_CERT_AUTH, CREATED_ON, LAST_UPDATED_ON) values +(1,'PUBLIC', 'domain','subdomain', 'CEF-SMP-001','single_domain_key',0,1, NOW(), NOW()), +(2, 'PUBLIC', 'domainTwo','newdomain', 'CEF-SMP-002','single_domain_key',0,1,NOW(), NOW()); insert into SMP_GROUP (ID, FK_DOMAIN_ID, NAME, VISIBILITY, CREATED_ON, LAST_UPDATED_ON) values (1, 1, 'domain group', 'PUBLIC', NOW(), NOW());