This commit is contained in:
Phillip Webb
2016-08-29 20:20:45 +01:00
parent 850141c405
commit 565ad79856
19 changed files with 151 additions and 137 deletions

View File

@@ -364,6 +364,7 @@ public class EndpointWebMvcChildContextConfiguration {
}
abstract void customize(T container);
}
static class TomcatAccessLogCustomizer

View File

@@ -188,8 +188,9 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
}
if (isSpringSecurityAuthentication(principal)) {
Authentication authentication = (Authentication) principal;
List<String> roles = Arrays.asList(StringUtils.trimArrayElements(StringUtils
.commaDelimitedListToStringArray(this.roleResolver.getProperty("roles", "ROLE_ADMIN"))));
List<String> roles = Arrays.asList(StringUtils
.trimArrayElements(StringUtils.commaDelimitedListToStringArray(
this.roleResolver.getProperty("roles", "ROLE_ADMIN"))));
for (GrantedAuthority authority : authentication.getAuthorities()) {
String name = authority.getAuthority();
for (String role : roles) {

View File

@@ -42,7 +42,7 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link EndpointWebMvcHypermediaManagementContextConfigurationTests}.
* Tests for {@link EndpointWebMvcHypermediaManagementContextConfiguration}.
*
* @author Andy Wilkinson
*/

View File

@@ -60,15 +60,18 @@ public class HealthMvcEndpointTests {
private MockEnvironment environment;
private UsernamePasswordAuthenticationToken user = createAuthenticationToken("ROLE_USER");
private UsernamePasswordAuthenticationToken user = createAuthenticationToken(
"ROLE_USER");
private UsernamePasswordAuthenticationToken admin = createAuthenticationToken("ROLE_ADMIN");
private UsernamePasswordAuthenticationToken admin = createAuthenticationToken(
"ROLE_ADMIN");
private UsernamePasswordAuthenticationToken hero = createAuthenticationToken("ROLE_HERO");
private UsernamePasswordAuthenticationToken hero = createAuthenticationToken(
"ROLE_HERO");
private UsernamePasswordAuthenticationToken createAuthenticationToken(String authority) {
return new UsernamePasswordAuthenticationToken(
"user", "password",
private UsernamePasswordAuthenticationToken createAuthenticationToken(
String authority) {
return new UsernamePasswordAuthenticationToken("user", "password",
AuthorityUtils.commaSeparatedStringToAuthorityList(authority));
}