Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VAS]:bug-11607: remove sanitize check on provider dtos #1459

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public IdentityProviderExternalController(final IdentityProviderExternalService
@Secured(ServicesData.ROLE_GET_PROVIDERS)
public List<IdentityProviderDto> getAll(final Optional<String> criteria, @RequestParam final Optional<String> embedded) {

SanityChecker.sanitizeCriteria(criteria);
EnumUtils.checkValidEnum(ProviderEmbeddedOptions.class, embedded);
LOGGER.debug("Get all criteria={} embedded={}", criteria, embedded);
return identityProviderCrudService.getAll(criteria, embedded);
Expand Down Expand Up @@ -131,7 +130,6 @@ public ResponseEntity<Void> checkExist(final String criteria) {
public IdentityProviderDto create(final @Valid @RequestBody IdentityProviderDto dto)
throws InvalidParseOperationException, PreconditionFailedException {

SanityChecker.sanitizeCriteria(dto);
LOGGER.debug("Create {}", dto);
return identityProviderCrudService.create(dto);
}
Expand All @@ -149,7 +147,6 @@ public IdentityProviderDto patch(final @PathVariable("id") String id, @RequestBo

ParameterChecker.checkParameter("Identifier is mandatory : ", id);
SanityChecker.checkSecureParameter(id);
SanityChecker.sanitizeCriteria(partialDto);
LOGGER.debug("Patch {} with {}", id, partialDto);
Assert.isTrue(StringUtils.equals(id, (String) partialDto.get("id")), "The DTO identifier must match the path identifier for update.");
return identityProviderCrudService.patch(partialDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@

/**
* The controller to check existence, create, read, update and delete the identity providers.
*
*
*/
@RestController
@RequestMapping(RestApi.V1_PROVIDERS_URL)
Expand All @@ -83,34 +81,40 @@
@Api(tags = "identityproviders", value = "Identity Providers Management", description = "Identity Providers Management")
public class IdentityProviderInternalController implements CrudController<IdentityProviderDto> {

private static final VitamUILogger LOGGER = VitamUILoggerFactory.getInstance(IdentityProviderInternalController.class);
private static final VitamUILogger LOGGER =
VitamUILoggerFactory.getInstance(IdentityProviderInternalController.class);

@Autowired
private IdentityProviderInternalService internalIdentityProviderService;

/**
* Get All with criteria and embedded request.
*
* @param criteria
* @param embedded
* @return
*/
@GetMapping
public List<IdentityProviderDto> getAll(final Optional<String> criteria, @RequestParam final Optional<String> embedded) {
public List<IdentityProviderDto> getAll(final Optional<String> criteria,
@RequestParam final Optional<String> embedded) {
LOGGER.debug("Get all criteria={}, embedded={}", criteria, embedded);
EnumUtils.checkValidEnum(ProviderEmbeddedOptions.class, embedded);
return internalIdentityProviderService.getAll(criteria, embedded);
}

/**
* GetOne with criteria, item id and embedded request.
*
* @param id
* @param criteria
* @param embedded
* @return
*/
@GetMapping(CommonConstants.PATH_ID)
public IdentityProviderDto getOne(final @PathVariable("id") String id, final @RequestParam Optional<String> criteria,
final @RequestParam Optional<String> embedded) throws InvalidParseOperationException, PreconditionFailedException {
public IdentityProviderDto getOne(final @PathVariable("id") String id,
final @RequestParam Optional<String> criteria,
final @RequestParam Optional<String> embedded)
throws InvalidParseOperationException, PreconditionFailedException {

ParameterChecker.checkParameter("The Identifier is a mandatory parameter: ", id);
SanityChecker.checkSecureParameter(id);
Expand All @@ -137,15 +141,15 @@ public ResponseEntity<Void> checkExist(final String criteria) {
public IdentityProviderDto create(final @Valid @RequestBody IdentityProviderDto dto)
throws InvalidParseOperationException, PreconditionFailedException {
LOGGER.debug("Create {}", dto);
SanityChecker.sanitizeCriteria(dto);
return internalIdentityProviderService.create(dto);
}

/**
* {@inheritDoc}
*/
@Override
public IdentityProviderDto update(final @PathVariable("id") String id, final @Valid @RequestBody IdentityProviderDto dto) {
public IdentityProviderDto update(final @PathVariable("id") String id,
final @Valid @RequestBody IdentityProviderDto dto) {
throw new UnsupportedOperationException("update not implemented");
}

Expand All @@ -154,13 +158,15 @@ public IdentityProviderDto update(final @PathVariable("id") String id, final @Va
*/
@Override
@PatchMapping(CommonConstants.PATH_ID)
public IdentityProviderDto patch(final @PathVariable("id") String id, @RequestBody final Map<String, Object> partialDto)
public IdentityProviderDto patch(final @PathVariable("id") String id,
@RequestBody final Map<String, Object> partialDto)
throws InvalidParseOperationException, PreconditionFailedException {
LOGGER.debug("Patch {}", id, partialDto);
ParameterChecker.checkParameter("The Identifier is a mandatory parameter: ", id);
SanityChecker.checkSecureParameter(id);
SanityChecker.sanitizeCriteria(partialDto);
Assert.isTrue(StringUtils.equals(id, (String) partialDto.get("id")), "The DTO identifier must match the path identifier for update.");
Assert.isTrue(StringUtils.equals(id, (String) partialDto.get("id")),
"The DTO identifier must match the path identifier for update.");
return internalIdentityProviderService.patch(partialDto);
}
}