@Test public void extractPrincipalReturnsUnknownMachineCoffeeUserIfNameKeyIsMissing() { userInfoHashMap.put("clientOnly", true); userInfoHashMap.remove("name"); Object principal = sut.extractPrincipal(userInfoHashMap); assertThat(principal, instanceOf(MachineCoffeeNetUser.class)); MachineCoffeeNetUser machineCoffeeUser = (MachineCoffeeNetUser) principal; assertThat(machineCoffeeUser.getUsername(), is("UNKNOWN")); assertThat(machineCoffeeUser.getAuthorities().size(), is(1)); }
@Override public Object extractPrincipal(Map<String, Object> map) { if ((boolean) map.getOrDefault("clientOnly", false)) { return extractClientDetails(map); } else { return extractUserDetails(map); } }
CoffeeNetPrincipalExtractor implements PrincipalExtractor { @Override public Object extractPrincipal(Map<String, Object> map) { if ((boolean) map.getOrDefault("clientOnly", false)) { return extractClientDetails(map); } else { return extractUserDetails(map); } } }
CoffeeNetPrincipalExtractor implements PrincipalExtractor { @Override public Object extractPrincipal(Map<String, Object> map) { if ((boolean) map.getOrDefault("clientOnly", false)) { return extractClientDetails(map); } else { return extractUserDetails(map); } } CoffeeNetPrincipalExtractor(AuthoritiesExtractor authoritiesExtractor); }
CoffeeNetPrincipalExtractor implements PrincipalExtractor { @Override public Object extractPrincipal(Map<String, Object> map) { if ((boolean) map.getOrDefault("clientOnly", false)) { return extractClientDetails(map); } else { return extractUserDetails(map); } } CoffeeNetPrincipalExtractor(AuthoritiesExtractor authoritiesExtractor); @Override Object extractPrincipal(Map<String, Object> map); }
CoffeeNetPrincipalExtractor implements PrincipalExtractor { @Override public Object extractPrincipal(Map<String, Object> map) { if ((boolean) map.getOrDefault("clientOnly", false)) { return extractClientDetails(map); } else { return extractUserDetails(map); } } CoffeeNetPrincipalExtractor(AuthoritiesExtractor authoritiesExtractor); @Override Object extractPrincipal(Map<String, Object> map);  }