Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 1eed4e3b authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Pull request #191: Small fixes.

Merge in EDELIVERY/smp from bugfix/EDELIVERY-9189-keystore-file-is-not-getting-imported to development

* commit '57e98fd918e645993d2ef7a2ae68260a1d078976':
  Small fixes.
parents 038792fe 8e34803b
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,6 @@ export interface SearchTableValidationResult{
validOperation: boolean;
stringMessage?: string;
listId?: Array<number>;
listId?: Array<string>;
listDeleteNotPermitedId?: Array<number>;
}
......@@ -54,7 +54,7 @@ export class DomainController implements SearchTableController {
validateDeleteOperation(rows: Array<SearchTableEntity>){
var deleteRowIds = rows.map(rows => rows.id);
return this.http.post<SearchTableValidationResult>(SmpConstants.REST_INTERNAL_DOMAIN_VALIDATE_DELETE, deleteRowIds);
return this.http.put<SearchTableValidationResult>(SmpConstants.REST_INTERNAL_DOMAIN_VALIDATE_DELETE, deleteRowIds);
}
public newValidationResult(result: boolean, message: string): SearchTableValidationResult {
......
......@@ -65,6 +65,7 @@ export class UserController implements SearchTableController {
public newRow(): UserRo {
return {
id: null,
userId:null,
index: null,
username: '',
emailAddress: '',
......@@ -79,12 +80,12 @@ export class UserController implements SearchTableController {
this.lookups.refreshUserLookup();
}
validateDeleteOperation(rows: Array<SearchTableEntity>) {
var deleteRowIds = rows.map(rows => rows.id);
validateDeleteOperation(rows: Array<UserRo>) {
var deleteRowIds = rows.map(rows => rows.userId);
return this.http.post<SearchTableValidationResult>(SmpConstants.REST_INTERNAL_USER_VALIDATE_DELETE, deleteRowIds);
}
public newValidationResult(lst: Array<number>): SearchTableValidationResult {
public newValidationResult(lst: Array<string>): SearchTableValidationResult {
return {
validOperation: false,
stringMessage: null,
......
......@@ -96,32 +96,6 @@
</mat-form-field>
</div>
</mat-card-content>
<mat-card-title>
<mat-slide-toggle mat-no-ink class="mat-primary" [formControl]="userForm.controls['userToggle']"
(change)="onUserToggleChanged($event)" id="userAccessToken_id">
User access token authentication
</mat-slide-toggle>
<div *ngIf="userForm.errors?.userDetailsOrCertificateRequired && (userForm.get('userToggle').dirty || userForm.get('certificateToggle').dirty)"
class="has-error">You need to generate access token
</div>
<button mat-raised-button color="primary" (click)="regenerateAccessToken()">
<mat-icon>check_circle</mat-icon>
<span>Regenerate access token</span>
</button>
</mat-card-title>
<mat-card-content>
<div class="panel" class="user-panel">
<mat-form-field class="username">
<input matInput placeholder="accessToken" [formControl]="userForm.controls['accessTokenId']"
id="accessToken_id" maxlength="255" />
</mat-form-field>
</div>
</mat-card-content>
</mat-card>
<mat-card fxFlex="60">
<mat-card-title>
......
......@@ -214,18 +214,6 @@ export class UserDetailsDialogComponent {
this.dialogRef.close(true);
}
regenerateAccessToken() {
/*
let accessTokenPromise: Promise<AccessTokenRo> = this.userDetailsService.regenerateAccessToken(this.userId, "AccessPassword");
accessTokenPromise.then(response => {
this.alertService.success("Token with\n id: " + response.identifier + " and\nvalue: " + response.value + " was generated!")
this.userForm.patchValue({
'accessTokenId': response.identifier})
}, err => {
this.alertService.error("Failed to generated access token. Please try again. If this happens again please contact Administrator!")
});*/
}
uploadCertificate(event) {
this.newCertFile=null;
const file = event.target.files[0];
......
......@@ -2,6 +2,7 @@ import {SearchTableEntity} from '../common/search-table/search-table-entity.mode
import {CertificateRo} from './certificate-ro.model';
export interface UserRo extends SearchTableEntity {
userId?: string
username: string;
emailAddress: string;
password?: string;
......
......@@ -53,9 +53,9 @@ public class KeystoreResource {
return sg;
}
@PreAuthorize("@smpAuthorizationService.systemAdministrator || @smpAuthorizationService.isCurrentlyLoggedIn(#id)")
@PostMapping(path = "/{id}/upload/{keystoreType}/{password}", produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_OCTET_STREAM_VALUE)
public KeystoreImportResult uploadKeystore(@PathVariable("id") Long id,
@PreAuthorize("@smpAuthorizationService.systemAdministrator || @smpAuthorizationService.isCurrentlyLoggedIn(#userEncId)")
@PostMapping(path = "/{user-enc-id}/upload/{keystoreType}/{password}", produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_OCTET_STREAM_VALUE)
public KeystoreImportResult uploadKeystore(@PathVariable("user-enc-id") String userEncId,
@PathVariable("keystoreType") String keystoreType,
@PathVariable("password") String password,
@RequestBody byte[] fileBytes) {
......@@ -77,11 +77,11 @@ public class KeystoreResource {
return keystoreImportResult;
}
@PreAuthorize("@smpAuthorizationService.systemAdministrator || @smpAuthorizationService.isCurrentlyLoggedIn(#id)")
@DeleteMapping(value = "/{id}/delete/{alias}", produces = APPLICATION_JSON_VALUE)
public KeystoreImportResult deleteCertificate(@PathVariable("id") Long id,
@PreAuthorize("@smpAuthorizationService.systemAdministrator || @smpAuthorizationService.isCurrentlyLoggedIn(#userEncId)")
@DeleteMapping(value = "/{user-enc-id}/delete/{alias}", produces = APPLICATION_JSON_VALUE)
public KeystoreImportResult deleteCertificate(@PathVariable("user-enc-id") String userEncId,
@PathVariable("alias") String alias) {
LOG.info("Remove alias by user id {}, alias {}.", id, alias);
LOG.info("Remove alias by user id {}, alias {}.", userEncId, alias);
KeystoreImportResult keystoreImportResult = new KeystoreImportResult();
try {
uiKeystoreService.deleteKey(alias);
......
......@@ -15,6 +15,7 @@ import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory;
import eu.europa.ec.edelivery.smp.services.ui.UITruststoreService;
import eu.europa.ec.edelivery.smp.services.ui.UIUserService;
import eu.europa.ec.edelivery.smp.services.ui.filters.UserFilter;
import eu.europa.ec.edelivery.smp.utils.SecurityUtils;
import eu.europa.ec.edelivery.smp.utils.SessionSecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
......@@ -25,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static eu.europa.ec.edelivery.smp.ui.ResourceConstants.CONTEXT_PATH_INTERNAL_USER;
......@@ -78,8 +80,9 @@ public class UserAdminResource {
@PutMapping(produces = {"application/json"})
@RequestMapping(path = "validate-delete", method = RequestMethod.POST)
@Secured({SMPAuthority.S_AUTHORITY_TOKEN_SYSTEM_ADMIN})
public DeleteEntityValidation validateDeleteUsers(@RequestBody List<Long> query) {
public DeleteEntityValidation validateDeleteUsers(@RequestBody List<String> queryEncIds) {
DBUser user = getCurrentUser();
List<Long> query = queryEncIds.stream().map(SessionSecurityUtils::decryptEntityId).collect(Collectors.toList());
DeleteEntityValidation dres = new DeleteEntityValidation();
if (query.contains(user.getId())) {
dres.setValidOperation(false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment