spring-restcontroller

validate json payload in spring boot rest to throw error if unknown property or empty property has been sent as part of json payload

[亡魂溺海] 提交于 2020-08-26 06:52:51
问题 JSON Request: { "notificationType" : "ISSUER_OTP1ee2asasa", "content" : "hi fff this is fff template content for SBI email good and mobile dfdfdfd and remaining balance is 333 and your name is hahaha.", "medium" : "EMAIL", "asa":"ddddd", "":"" } POJO: package com.innoviti.notification.model; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation

How do I configure @PreAuthorize to recognize the ID of my logged in user?

十年热恋 提交于 2020-07-31 04:01:03
问题 I'm trying to create a Spring Boot 2.1 application. I have created the following rest controller ... @RestController @RequestMapping("/api/users") public class UserController { ... @PutMapping("/{id}") @PreAuthorize("authentication.principal.id == #id") public ResponseEntity<User> update(@RequestBody User user, @PathVariable UUID id) { final User updatedUser = userService.update(id, user); if (updatedUser == null) { return ResponseEntity.notFound().build(); } else { return ResponseEntity.ok

How do I configure @PreAuthorize to recognize the ID of my logged in user?

无人久伴 提交于 2020-07-31 04:00:23
问题 I'm trying to create a Spring Boot 2.1 application. I have created the following rest controller ... @RestController @RequestMapping("/api/users") public class UserController { ... @PutMapping("/{id}") @PreAuthorize("authentication.principal.id == #id") public ResponseEntity<User> update(@RequestBody User user, @PathVariable UUID id) { final User updatedUser = userService.update(id, user); if (updatedUser == null) { return ResponseEntity.notFound().build(); } else { return ResponseEntity.ok

How do I configure @PreAuthorize to recognize the ID of my logged in user?

落花浮王杯 提交于 2020-07-31 03:59:28
问题 I'm trying to create a Spring Boot 2.1 application. I have created the following rest controller ... @RestController @RequestMapping("/api/users") public class UserController { ... @PutMapping("/{id}") @PreAuthorize("authentication.principal.id == #id") public ResponseEntity<User> update(@RequestBody User user, @PathVariable UUID id) { final User updatedUser = userService.update(id, user); if (updatedUser == null) { return ResponseEntity.notFound().build(); } else { return ResponseEntity.ok

Exception message not included in response when throwing ResponseStatusException in Spring Boot

纵然是瞬间 提交于 2020-07-08 15:00:50
问题 My Spring Boot application provides the following REST controller: @RestController @RequestMapping("/api/verify") public class VerificationController { final VerificationService verificationService; Logger logger = LoggerFactory.getLogger(VerificationController.class); public VerificationController(VerificationService verificationService) { this.verificationService = verificationService; } @GetMapping public void verify( @RequestParam(value = "s1") String s1, @RequestParam(value = "s2")

Exception message not included in response when throwing ResponseStatusException in Spring Boot

99封情书 提交于 2020-07-08 15:00:07
问题 My Spring Boot application provides the following REST controller: @RestController @RequestMapping("/api/verify") public class VerificationController { final VerificationService verificationService; Logger logger = LoggerFactory.getLogger(VerificationController.class); public VerificationController(VerificationService verificationService) { this.verificationService = verificationService; } @GetMapping public void verify( @RequestParam(value = "s1") String s1, @RequestParam(value = "s2")

KeycloakRestTemplate with spring application

☆樱花仙子☆ 提交于 2020-06-28 01:57:55
问题 I have a spring client with spring rest api's which are protected with keycloak. I am trying to call it using keycloakresttemplate from another client which is a pure java code with no security. I am getting the keycloak access token from java client and setting it in the header of rest url. It is not able to initialize the keycloakresttemplate. Any view why I am facing this issue. //Below is the code to hit the spring url using keycloakresttemplate.I have added Dependency of keycloack

KeycloakRestTemplate with spring application

☆樱花仙子☆ 提交于 2020-06-28 01:57:35
问题 I have a spring client with spring rest api's which are protected with keycloak. I am trying to call it using keycloakresttemplate from another client which is a pure java code with no security. I am getting the keycloak access token from java client and setting it in the header of rest url. It is not able to initialize the keycloakresttemplate. Any view why I am facing this issue. //Below is the code to hit the spring url using keycloakresttemplate.I have added Dependency of keycloack