Search in sources :

Example 6 with IdmProfileFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmProfileFilter in project CzechIdMng by bcvsolutions.

the class IdmIdentityController method expandPanel.

/**
 * Expand panel on frontend - persist updated identity profile setting.
 *
 * @param backendId identity codeable identifier
 * @param panelId panel identitfier ~ uiKey
 * @return updated profile
 * @since 11.2.0
 */
@RequestMapping(value = "/{backendId}/profile/panels/{panelId}/expand", method = RequestMethod.PATCH)
@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.PROFILE_UPDATE + "')")
@ApiOperation(value = "Expand panel", nickname = "expandPanel", tags = { IdmIdentityController.TAG }, notes = "Expand panel - persist updated identity profile setting.", authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.PROFILE_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.PROFILE_UPDATE, description = "") }) })
public ResponseEntity<?> expandPanel(@ApiParam(value = "Identity's uuid identifier or username.", required = true) @PathVariable @NotNull String backendId, @ApiParam(value = "Panel identifier - uiKey.", required = true) @PathVariable @NotNull String panelId) {
    IdmIdentityDto identity = getDto(backendId);
    if (identity == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
    }
    IdmProfileDto profile = profileService.expandPanel(backendId, panelId, IdmBasePermission.UPDATE);
    // 
    // refresh with permissions are needed
    IdmProfileFilter context = new IdmProfileFilter();
    context.setAddPermissions(true);
    profile = profileController.getService().get(profile, context, IdmBasePermission.READ);
    // 
    return new ResponseEntity<>(profileController.toResource(profile), HttpStatus.OK);
}
Also used : IdmProfileDto(eu.bcvsolutions.idm.core.api.dto.IdmProfileDto) ResponseEntity(org.springframework.http.ResponseEntity) IdmProfileFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmProfileFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with IdmProfileFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmProfileFilter in project CzechIdMng by bcvsolutions.

the class IdmIdentityController method uploadProfileImage.

/**
 * Upload new profile picture
 *
 * @param backendId
 * @param fileName
 * @param data
 * @return
 * @throws IOException
 * @since 9.0.0
 */
@ResponseBody
@RequestMapping(value = "/{backendId}/profile/image", method = RequestMethod.POST)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.PROFILE_UPDATE + "')")
@ApiOperation(value = "Update profile picture", nickname = "postProfilePicture", tags = { IdmProfileController.TAG }, notes = "Upload new profile image", authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.PROFILE_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.PROFILE_UPDATE, description = "") }) })
public ResponseEntity<?> uploadProfileImage(@ApiParam(value = "Identity's uuid identifier or username.", required = false) @PathVariable String backendId, @RequestParam(required = true, name = "fileName") @NotNull String fileName, @RequestParam(required = true, name = "data") MultipartFile data) {
    IdmProfileDto profile = profileService.findOrCreateByIdentity(backendId, IdmBasePermission.READ, IdmBasePermission.CREATE);
    // 
    profile = profileService.uploadImage(profile, data, fileName, IdmBasePermission.UPDATE);
    // refresh with permissions are needed
    IdmProfileFilter context = new IdmProfileFilter();
    context.setAddPermissions(true);
    profile = profileController.getService().get(profile, context, IdmBasePermission.READ);
    // 
    return new ResponseEntity<>(profileController.toResource(profile), HttpStatus.OK);
}
Also used : IdmProfileDto(eu.bcvsolutions.idm.core.api.dto.IdmProfileDto) ResponseEntity(org.springframework.http.ResponseEntity) IdmProfileFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmProfileFilter) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with IdmProfileFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmProfileFilter in project CzechIdMng by bcvsolutions.

the class IdmIdentityController method deleteProfileImage.

/**
 * Deletes image attachment from identity
 *
 * @return
 * @since 9.0.0
 */
@RequestMapping(value = "/{backendId}/profile/image", method = RequestMethod.DELETE)
@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.PROFILE_UPDATE + "')")
@ApiOperation(value = "Profile picture", nickname = "deleteProfilePicure", tags = { IdmIdentityController.TAG }, notes = "Deletes profile picture from identity.", authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.PROFILE_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.PROFILE_UPDATE, description = "") }) })
public ResponseEntity<?> deleteProfileImage(@ApiParam(value = "Identity's uuid identifier or username.", required = true) @PathVariable String backendId) {
    IdmProfileDto profile = profileService.findOneByIdentity(backendId, IdmBasePermission.READ, IdmBasePermission.UPDATE);
    // 
    profile = profileService.deleteImage(profile, IdmBasePermission.UPDATE);
    // refresh with permissions are needed
    IdmProfileFilter context = new IdmProfileFilter();
    context.setAddPermissions(true);
    profile = profileController.getService().get(profile, context, IdmBasePermission.READ);
    // 
    return new ResponseEntity<>(profileController.toResource(profile), HttpStatus.OK);
}
Also used : IdmProfileDto(eu.bcvsolutions.idm.core.api.dto.IdmProfileDto) ResponseEntity(org.springframework.http.ResponseEntity) IdmProfileFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmProfileFilter) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

IdmProfileFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmProfileFilter)8 IdmProfileDto (eu.bcvsolutions.idm.core.api.dto.IdmProfileDto)6 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)5 ApiOperation (io.swagger.annotations.ApiOperation)4 ResponseEntity (org.springframework.http.ResponseEntity)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)2 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)1 IdmEntityStateDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto)1 IdmIdentityRoleValidRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto)1 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)1 IdmContractGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter)1 IdmContractSliceFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter)1 IdmContractSliceGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceGuaranteeFilter)1 IdmDelegationDefinitionFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmDelegationDefinitionFilter)1 IdmRoleGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter)1 IdmRoleRequestFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleRequestFilter)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1