@Test public void setAttributeForUser() { User user = new User("hacker", "secret", Arrays.asList("USER")); api(user, "/api/users"); List<String> values = Arrays.asList("value1", "value2"); api(values, "/api/attributes/" + NEW_ATTRIBUTE + "/hacker"); assertEquals(values, idpConfiguration.getUsers().stream() .filter(userAuthenticationToken -> userAuthenticationToken.getPrincipal().equals("hacker")).findFirst().get() .getAttributes().get(NEW_ATTRIBUTE)); }
@PutMapping("/attributes/{name:.+}/{userName:.+}") public void setAttributeForUser(@PathVariable String name, @PathVariable String userName, @RequestBody List<String> values) { LOG.info("Request to set attribute {} to {} for user {}", name, values, userName); configuration().getUsers().stream().filter(userAuthenticationToken -> userAuthenticationToken.getName().equals (userName)).findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("User %s first " + "must be created", userName))).getAttributes().put(name, values); }
IdpController extends SharedController { @PutMapping("/attributes/{name:.+}/{userName:.+}") public void setAttributeForUser(@PathVariable String name, @PathVariable String userName, @RequestBody List<String> values) { LOG.info("Request to set attribute {} to {} for user {}", name, values, userName); configuration().getUsers().stream().filter(userAuthenticationToken -> userAuthenticationToken.getName().equals (userName)).findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("User %s first " + "must be created", userName))).getAttributes().put(name, values); } }
IdpController extends SharedController { @PutMapping("/attributes/{name:.+}/{userName:.+}") public void setAttributeForUser(@PathVariable String name, @PathVariable String userName, @RequestBody List<String> values) { LOG.info("Request to set attribute {} to {} for user {}", name, values, userName); configuration().getUsers().stream().filter(userAuthenticationToken -> userAuthenticationToken.getName().equals (userName)).findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("User %s first " + "must be created", userName))).getAttributes().put(name, values); } @Autowired  IdpController(IdpConfiguration configuration); }
IdpController extends SharedController { @PutMapping("/attributes/{name:.+}/{userName:.+}") public void setAttributeForUser(@PathVariable String name, @PathVariable String userName, @RequestBody List<String> values) { LOG.info("Request to set attribute {} to {} for user {}", name, values, userName); configuration().getUsers().stream().filter(userAuthenticationToken -> userAuthenticationToken.getName().equals (userName)).findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("User %s first " + "must be created", userName))).getAttributes().put(name, values); } @Autowired  IdpController(IdpConfiguration configuration); @PutMapping("/attributes") void setAttributes(@RequestBody Map<String, List<String>> attributes); @PutMapping("/attributes/{name:.+}") void setAttribute(@PathVariable String name, @RequestBody List<String> values); @PutMapping("/attributes/{name:.+}/{userName:.+}") void setAttributeForUser(@PathVariable String name, @PathVariable String userName,
                                  @RequestBody List<String> values); @DeleteMapping("/attributes/{name:.+}") void removeAttribute(@PathVariable String name); @DeleteMapping("/attributes/{name:.+}/{userName:.+}") void removeAttributeForUser(@PathVariable String name, @PathVariable String userName); @PutMapping("/users") void addUser(@RequestBody User user); @PutMapping("authmethod") void setAuthenticationMethod(@RequestBody String authenticationMethod); @PutMapping("/acsendpoint") void setAcsEndpoint(@RequestBody String acsEndpoint); }
IdpController extends SharedController { @PutMapping("/attributes/{name:.+}/{userName:.+}") public void setAttributeForUser(@PathVariable String name, @PathVariable String userName, @RequestBody List<String> values) { LOG.info("Request to set attribute {} to {} for user {}", name, values, userName); configuration().getUsers().stream().filter(userAuthenticationToken -> userAuthenticationToken.getName().equals (userName)).findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("User %s first " + "must be created", userName))).getAttributes().put(name, values); } @Autowired  IdpController(IdpConfiguration configuration); @PutMapping("/attributes") void setAttributes(@RequestBody Map<String, List<String>> attributes); @PutMapping("/attributes/{name:.+}") void setAttribute(@PathVariable String name, @RequestBody List<String> values); @PutMapping("/attributes/{name:.+}/{userName:.+}") void setAttributeForUser(@PathVariable String name, @PathVariable String userName,
                                  @RequestBody List<String> values); @DeleteMapping("/attributes/{name:.+}") void removeAttribute(@PathVariable String name); @DeleteMapping("/attributes/{name:.+}/{userName:.+}") void removeAttributeForUser(@PathVariable String name, @PathVariable String userName); @PutMapping("/users") void addUser(@RequestBody User user); @PutMapping("authmethod") void setAuthenticationMethod(@RequestBody String authenticationMethod); @PutMapping("/acsendpoint") void setAcsEndpoint(@RequestBody String acsEndpoint);  }