use of eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException in project CzechIdMng by bcvsolutions.
the class AbstractReadWriteDtoController method patch.
/**
* Patch is not implemented yet
*
* @param backendId
* @param nativeRequest
* @return
* @throws HttpMessageNotReadableException
*/
public ResponseEntity<?> patch(String backendId, HttpServletRequest nativeRequest) throws HttpMessageNotReadableException {
DTO updateDto = getDto(backendId);
if (updateDto == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
//
ServletServerHttpRequest request = new ServletServerHttpRequest(nativeRequest);
try {
modelMapper.map(getMapper().readerForUpdating(updateDto).readValue(request.getBody()), updateDto);
} catch (IOException ex) {
throw new ResultCodeException(CoreResultCode.BAD_REQUEST, ex);
}
updateDto = patchDto(updateDto);
return new ResponseEntity<>(toResource(updateDto), HttpStatus.OK);
}
use of eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException in project CzechIdMng by bcvsolutions.
the class AbstractReadDtoController method get.
/**
* Returns response DTO by given backendId
*
* @param backendId
* @return
*/
@ApiOperation(value = "Read record", authorizations = { @Authorization(SwaggerConfig.AUTHENTICATION_BASIC), @Authorization(SwaggerConfig.AUTHENTICATION_CIDMST) })
public ResponseEntity<?> get(@ApiParam(value = "Record's uuid identifier or unique code, if record supports Codeable interface.", required = true) @PathVariable @NotNull String backendId) {
DTO dto = getDto(backendId);
if (dto == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
ResourceSupport resource = toResource(dto);
if (resource == null) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
//
return new ResponseEntity<>(resource, HttpStatus.OK);
}
use of eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException in project CzechIdMng by bcvsolutions.
the class IdmRoleRequestController method get.
@Override
@ResponseBody
@RequestMapping(value = "/{backendId}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLE_REQUEST_READ + "')")
@ApiOperation(value = "Role request detail. Returns request doesn't contains concepts (from version 9.7.0!).", nickname = "getRoleRequest", response = IdmRoleRequestDto.class, tags = { IdmRoleRequestController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_REQUEST_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_REQUEST_READ, description = "") }) })
public ResponseEntity<?> get(@ApiParam(value = "Role request's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
//
IdmRoleRequestFilter filter = new IdmRoleRequestFilter();
filter.setIncludeApprovers(true);
IdmRoleRequestDto requestDto = getService().get(backendId, filter, IdmBasePermission.READ);
if (requestDto == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
ResourceSupport resource = toResource(requestDto);
if (resource == null) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<>(resource, HttpStatus.OK);
}
use of eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException in project CzechIdMng by bcvsolutions.
the class IdmProfileController method twoFactorConfirm.
@ResponseBody
@ApiOperation(value = "Login - additional two factor authentication confirm", notes = "Additional two factor authentication with TOTP verification code.", response = IdmProfileDto.class, tags = { IdmProfileController.TAG })
@RequestMapping(path = "/{backendId}/two-factor/confirm", method = RequestMethod.PUT)
public ResponseEntity<?> twoFactorConfirm(@ApiParam(value = "Profile's uuid identifier or username.", required = true) @PathVariable @NotNull String backendId, @ApiParam(value = "Verification secret and code.", required = true) @Valid @RequestBody(required = true) TwoFactorRegistrationConfirmDto registrationConfirm) {
IdmProfileDto dto = getDto(backendId);
if (dto == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
//
twoFactorAuthenticationManager.confirm(dto.getIdentity(), registrationConfirm);
//
return new ResponseEntity<>(toResource(getDto(dto)), HttpStatus.OK);
}
use of eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException in project CzechIdMng by bcvsolutions.
the class SysRemoteServerController method getConnectorFrameworks.
/**
* Return available connector frameworks with connectors on remote connector server.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{backendId}/frameworks")
@PreAuthorize("hasAuthority('" + AccGroupPermission.REMOTESERVER_READ + "')")
@ApiOperation(value = "Get available connectors", nickname = "getAvailableConnectors", tags = { SysRemoteServerController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = AccGroupPermission.REMOTESERVER_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = AccGroupPermission.REMOTESERVER_READ, description = "") }) }, notes = "Available connector frameworks with connectors on remote connector server.")
public ResponseEntity<Map<String, Set<IcConnectorInfo>>> getConnectorFrameworks(@ApiParam(value = "Remote server uuid identifier or code.", required = true) @PathVariable @NotNull String backendId) {
SysConnectorServerDto connectorServer = getDto(backendId);
if (connectorServer == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
Map<String, Set<IcConnectorInfo>> infos = new HashMap<>();
//
try {
for (IcConfigurationService config : icConfiguration.getIcConfigs().values()) {
connectorServer.setPassword(remoteServerService.getPassword(connectorServer.getId()));
infos.put(config.getFramework(), config.getAvailableRemoteConnectors(connectorServer));
}
} catch (IcInvalidCredentialException e) {
throw new ResultCodeException(AccResultCode.REMOTE_SERVER_INVALID_CREDENTIAL, ImmutableMap.of("server", e.getHost() + ":" + e.getPort()), e);
} catch (IcServerNotFoundException e) {
throw new ResultCodeException(AccResultCode.REMOTE_SERVER_NOT_FOUND, ImmutableMap.of("server", e.getHost() + ":" + e.getPort()), e);
} catch (IcCantConnectException e) {
throw new ResultCodeException(AccResultCode.REMOTE_SERVER_CANT_CONNECT, ImmutableMap.of("server", e.getHost() + ":" + e.getPort()), e);
} catch (IcRemoteServerException e) {
throw new ResultCodeException(AccResultCode.REMOTE_SERVER_UNEXPECTED_ERROR, ImmutableMap.of("server", e.getHost() + ":" + e.getPort()), e);
}
//
return new ResponseEntity<Map<String, Set<IcConnectorInfo>>>(infos, HttpStatus.OK);
}
Aggregations