diff --git a/pom.xml b/pom.xml
index 7450d57f5be..59652833665 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
- 0.0.9
+ 0.0.11
0.0.1.RELEASE
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java
index b18fba1ff87..0ad2e1d9ef2 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEndpointElementCondition.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,15 +40,13 @@ public abstract class OnEndpointElementCondition extends SpringBootCondition {
private final Class extends Annotation> annotationType;
- protected OnEndpointElementCondition(String prefix,
- Class extends Annotation> annotationType) {
+ protected OnEndpointElementCondition(String prefix, Class extends Annotation> annotationType) {
this.prefix = prefix;
this.annotationType = annotationType;
}
@Override
- public ConditionOutcome getMatchOutcome(ConditionContext context,
- AnnotatedTypeMetadata metadata) {
+ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
AnnotationAttributes annotationAttributes = AnnotationAttributes
.fromMap(metadata.getAnnotationAttributes(this.annotationType.getName()));
String endpointName = annotationAttributes.getString("value");
@@ -59,25 +57,21 @@ public abstract class OnEndpointElementCondition extends SpringBootCondition {
return getDefaultEndpointsOutcome(context);
}
- protected ConditionOutcome getEndpointOutcome(ConditionContext context,
- String endpointName) {
+ protected ConditionOutcome getEndpointOutcome(ConditionContext context, String endpointName) {
Environment environment = context.getEnvironment();
String enabledProperty = this.prefix + endpointName + ".enabled";
if (environment.containsProperty(enabledProperty)) {
boolean match = environment.getProperty(enabledProperty, Boolean.class, true);
- return new ConditionOutcome(match,
- ConditionMessage.forCondition(this.annotationType).because(
- this.prefix + endpointName + ".enabled is " + match));
+ return new ConditionOutcome(match, ConditionMessage.forCondition(this.annotationType)
+ .because(this.prefix + endpointName + ".enabled is " + match));
}
return null;
}
protected ConditionOutcome getDefaultEndpointsOutcome(ConditionContext context) {
- boolean match = Boolean.valueOf(context.getEnvironment()
- .getProperty(this.prefix + "defaults.enabled", "true"));
- return new ConditionOutcome(match,
- ConditionMessage.forCondition(this.annotationType).because(
- this.prefix + "defaults.enabled is considered " + match));
+ boolean match = Boolean.valueOf(context.getEnvironment().getProperty(this.prefix + "defaults.enabled", "true"));
+ return new ConditionOutcome(match, ConditionMessage.forCondition(this.annotationType)
+ .because(this.prefix + "defaults.enabled is considered " + match));
}
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/amqp/RabbitHealthIndicatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/amqp/RabbitHealthIndicatorAutoConfiguration.java
index c73559729b8..1c09abf877b 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/amqp/RabbitHealthIndicatorAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/amqp/RabbitHealthIndicatorAutoConfiguration.java
@@ -46,13 +46,12 @@ import org.springframework.context.annotation.Configuration;
@ConditionalOnEnabledHealthIndicator("rabbit")
@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class)
@AutoConfigureAfter(RabbitAutoConfiguration.class)
-public class RabbitHealthIndicatorAutoConfiguration extends
- CompositeHealthIndicatorConfiguration {
+public class RabbitHealthIndicatorAutoConfiguration
+ extends CompositeHealthIndicatorConfiguration {
@Bean
@ConditionalOnMissingBean(name = "rabbitHealthIndicator")
- public HealthIndicator rabbitHealthIndicator(
- Map rabbitTemplates) {
+ public HealthIndicator rabbitHealthIndicator(Map rabbitTemplates) {
return createHealthIndicator(rabbitTemplates);
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditAutoConfiguration.java
index 6d0c31490d0..7af9e5f4e37 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditAutoConfiguration.java
@@ -41,8 +41,7 @@ import org.springframework.context.annotation.Configuration;
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(AuditEventRepository.class)
-@ConditionalOnProperty(prefix = "management.auditevents", name = "enabled",
- matchIfMissing = true)
+@ConditionalOnProperty(prefix = "management.auditevents", name = "enabled", matchIfMissing = true)
public class AuditAutoConfiguration {
@Bean
@@ -52,16 +51,14 @@ public class AuditAutoConfiguration {
}
@Bean
- @ConditionalOnClass(
- name = "org.springframework.security.authentication.event.AbstractAuthenticationEvent")
+ @ConditionalOnClass(name = "org.springframework.security.authentication.event.AbstractAuthenticationEvent")
@ConditionalOnMissingBean(AbstractAuthenticationAuditListener.class)
public AuthenticationAuditListener authenticationAuditListener() throws Exception {
return new AuthenticationAuditListener();
}
@Bean
- @ConditionalOnClass(
- name = "org.springframework.security.access.event.AbstractAuthorizationEvent")
+ @ConditionalOnClass(name = "org.springframework.security.access.event.AbstractAuthorizationEvent")
@ConditionalOnMissingBean(AbstractAuthorizationAuditListener.class)
public AuthorizationAuditListener authorizationAuditListener() throws Exception {
return new AuthorizationAuditListener();
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointAutoConfiguration.java
index b0b72b66120..c67d7950b4a 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointAutoConfiguration.java
@@ -42,8 +42,7 @@ public class AuditEventsEndpointAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(AuditEventRepository.class)
- public AuditEventsEndpoint auditEventsEndpoint(
- AuditEventRepository auditEventRepository) {
+ public AuditEventsEndpoint auditEventsEndpoint(AuditEventRepository auditEventRepository) {
return new AuditEventsEndpoint(auditEventRepository);
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/beans/BeansEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/beans/BeansEndpointAutoConfiguration.java
index a398570b82a..48287e8f987 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/beans/BeansEndpointAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/beans/BeansEndpointAutoConfiguration.java
@@ -36,8 +36,7 @@ public class BeansEndpointAutoConfiguration {
@Bean
@ConditionalOnMissingBean
- public BeansEndpoint beansEndpoint(
- ConfigurableApplicationContext applicationContext) {
+ public BeansEndpoint beansEndpoint(ConfigurableApplicationContext applicationContext) {
return new BeansEndpoint(applicationContext);
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfiguration.java
index f8118eaee7b..f17d0bbb1d0 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfiguration.java
@@ -53,8 +53,7 @@ public class CachesEndpointAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(CachesEndpoint.class)
- public CachesEndpointWebExtension cachesEndpointWebExtension(
- CachesEndpoint cachesEndpoint) {
+ public CachesEndpointWebExtension cachesEndpointWebExtension(CachesEndpoint cachesEndpoint) {
return new CachesEndpointWebExtension(cachesEndpoint);
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraHealthIndicatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraHealthIndicatorAutoConfiguration.java
index 512e611c4f6..70fc6daa3b5 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraHealthIndicatorAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraHealthIndicatorAutoConfiguration.java
@@ -50,16 +50,14 @@ import org.springframework.data.cassandra.core.CassandraOperations;
@ConditionalOnBean(CassandraOperations.class)
@ConditionalOnEnabledHealthIndicator("cassandra")
@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class)
-@AutoConfigureAfter({ CassandraAutoConfiguration.class,
- CassandraDataAutoConfiguration.class,
+@AutoConfigureAfter({ CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class,
CassandraReactiveHealthIndicatorAutoConfiguration.class })
-public class CassandraHealthIndicatorAutoConfiguration extends
- CompositeHealthIndicatorConfiguration {
+public class CassandraHealthIndicatorAutoConfiguration
+ extends CompositeHealthIndicatorConfiguration {
@Bean
@ConditionalOnMissingBean(name = "cassandraHealthIndicator")
- public HealthIndicator cassandraHealthIndicator(
- Map cassandraOperations) {
+ public HealthIndicator cassandraHealthIndicator(Map cassandraOperations) {
return createHealthIndicator(cassandraOperations);
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java
index a032295cafe..93f33f1b06a 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryAuthorizationException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2018 the original author or authors.
+ * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,8 +32,7 @@ public class CloudFoundryAuthorizationException extends RuntimeException {
this(reason, message, null);
}
- public CloudFoundryAuthorizationException(Reason reason, String message,
- Throwable cause) {
+ public CloudFoundryAuthorizationException(Reason reason, String message, Throwable cause) {
super(message, cause);
this.reason = reason;
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java
index a41ce4ffd93..7f510589564 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java
@@ -50,18 +50,16 @@ public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer {
* @param filters filters to apply
*/
public CloudFoundryWebEndpointDiscoverer(ApplicationContext applicationContext,
- ParameterValueMapper parameterValueMapper,
- EndpointMediaTypes endpointMediaTypes, List endpointPathMappers,
- Collection invokerAdvisors,
+ ParameterValueMapper parameterValueMapper, EndpointMediaTypes endpointMediaTypes,
+ List endpointPathMappers, Collection invokerAdvisors,
Collection> filters) {
- super(applicationContext, parameterValueMapper, endpointMediaTypes,
- endpointPathMappers, invokerAdvisors, filters);
+ super(applicationContext, parameterValueMapper, endpointMediaTypes, endpointPathMappers, invokerAdvisors,
+ filters);
}
@Override
protected boolean isExtensionExposed(Object extensionBean) {
- if (isHealthEndpointExtension(extensionBean)
- && !isCloudFoundryHealthEndpointExtension(extensionBean)) {
+ if (isHealthEndpointExtension(extensionBean) && !isCloudFoundryHealthEndpointExtension(extensionBean)) {
// Filter regular health endpoint extensions so a CF version can replace them
return false;
}
@@ -69,14 +67,12 @@ public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer {
}
private boolean isHealthEndpointExtension(Object extensionBean) {
- return MergedAnnotations.from(extensionBean.getClass())
- .get(EndpointWebExtension.class).getValue("endpoint", Class.class)
- .map(HealthEndpoint.class::isAssignableFrom).orElse(false);
+ return MergedAnnotations.from(extensionBean.getClass()).get(EndpointWebExtension.class)
+ .getValue("endpoint", Class.class).map(HealthEndpoint.class::isAssignableFrom).orElse(false);
}
private boolean isCloudFoundryHealthEndpointExtension(Object extensionBean) {
- return MergedAnnotations.from(extensionBean.getClass())
- .isPresent(EndpointCloudFoundryExtension.class);
+ return MergedAnnotations.from(extensionBean.getClass()).isPresent(EndpointCloudFoundryExtension.class);
}
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/Token.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/Token.java
index 202333d0b45..5e32f256adc 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/Token.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/Token.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2018 the original author or authors.
+ * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,12 +61,10 @@ public class Token {
private Map parseJson(String base64) {
try {
byte[] bytes = Base64Utils.decodeFromUrlSafeString(base64);
- return JsonParserFactory.getJsonParser()
- .parseMap(new String(bytes, StandardCharsets.UTF_8));
+ return JsonParserFactory.getJsonParser().parseMap(new String(bytes, StandardCharsets.UTF_8));
}
catch (RuntimeException ex) {
- throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN,
- "Token could not be parsed", ex);
+ throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN, "Token could not be parsed", ex);
}
}
@@ -103,8 +101,7 @@ public class Token {
private T getRequired(Map map, String key, Class type) {
Object value = map.get(key);
if (value == null) {
- throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN,
- "Unable to get value from key " + key);
+ throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN, "Unable to get value from key " + key);
}
if (!type.isInstance(value)) {
throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN,
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundryReactiveHealthEndpointWebExtension.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundryReactiveHealthEndpointWebExtension.java
index ab68f44a99a..11c9a09e6f5 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundryReactiveHealthEndpointWebExtension.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundryReactiveHealthEndpointWebExtension.java
@@ -39,8 +39,7 @@ public class CloudFoundryReactiveHealthEndpointWebExtension {
private final ReactiveHealthEndpointWebExtension delegate;
- public CloudFoundryReactiveHealthEndpointWebExtension(
- ReactiveHealthEndpointWebExtension delegate) {
+ public CloudFoundryReactiveHealthEndpointWebExtension(ReactiveHealthEndpointWebExtension delegate) {
this.delegate = delegate;
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundrySecurityInterceptor.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundrySecurityInterceptor.java
index 9ca595754ef..096313574ec 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundrySecurityInterceptor.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundrySecurityInterceptor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2018 the original author or authors.
+ * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,8 +39,7 @@ import org.springframework.web.server.ServerWebExchange;
*/
class CloudFoundrySecurityInterceptor {
- private static final Log logger = LogFactory
- .getLog(CloudFoundrySecurityInterceptor.class);
+ private static final Log logger = LogFactory.getLog(CloudFoundrySecurityInterceptor.class);
private final ReactiveTokenValidator tokenValidator;
@@ -48,12 +47,10 @@ class CloudFoundrySecurityInterceptor {
private final String applicationId;
- private static final Mono SUCCESS = Mono
- .just(SecurityResponse.success());
+ private static final Mono SUCCESS = Mono.just(SecurityResponse.success());
CloudFoundrySecurityInterceptor(ReactiveTokenValidator tokenValidator,
- ReactiveCloudFoundrySecurityService cloudFoundrySecurityService,
- String applicationId) {
+ ReactiveCloudFoundrySecurityService cloudFoundrySecurityService, String applicationId) {
this.tokenValidator = tokenValidator;
this.cloudFoundrySecurityService = cloudFoundrySecurityService;
this.applicationId = applicationId;
@@ -65,15 +62,14 @@ class CloudFoundrySecurityInterceptor {
return SUCCESS;
}
if (!StringUtils.hasText(this.applicationId)) {
- return Mono.error(new CloudFoundryAuthorizationException(
- Reason.SERVICE_UNAVAILABLE, "Application id is not available"));
+ return Mono.error(new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
+ "Application id is not available"));
}
if (this.cloudFoundrySecurityService == null) {
- return Mono.error(new CloudFoundryAuthorizationException(
- Reason.SERVICE_UNAVAILABLE, "Cloud controller URL is not available"));
+ return Mono.error(new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
+ "Cloud controller URL is not available"));
}
- return check(exchange, id).then(SUCCESS).doOnError(this::logError)
- .onErrorResume(this::getErrorResponse);
+ return check(exchange, id).then(SUCCESS).doOnError(this::logError).onErrorResume(this::getErrorResponse);
}
private void logError(Throwable ex) {
@@ -84,13 +80,11 @@ class CloudFoundrySecurityInterceptor {
try {
Token token = getToken(exchange.getRequest());
return this.tokenValidator.validate(token)
- .then(this.cloudFoundrySecurityService
- .getAccessLevel(token.toString(), this.applicationId))
+ .then(this.cloudFoundrySecurityService.getAccessLevel(token.toString(), this.applicationId))
.filter((accessLevel) -> accessLevel.isAccessAllowed(id))
- .switchIfEmpty(Mono.error(new CloudFoundryAuthorizationException(
- Reason.ACCESS_DENIED, "Access denied")))
- .doOnSuccess((accessLevel) -> exchange.getAttributes()
- .put("cloudFoundryAccessLevel", accessLevel))
+ .switchIfEmpty(
+ Mono.error(new CloudFoundryAuthorizationException(Reason.ACCESS_DENIED, "Access denied")))
+ .doOnSuccess((accessLevel) -> exchange.getAttributes().put("cloudFoundryAccessLevel", accessLevel))
.then();
}
catch (CloudFoundryAuthorizationException ex) {
@@ -104,15 +98,13 @@ class CloudFoundrySecurityInterceptor {
return Mono.just(new SecurityResponse(cfException.getStatusCode(),
"{\"security_error\":\"" + cfException.getMessage() + "\"}"));
}
- return Mono.just(new SecurityResponse(HttpStatus.INTERNAL_SERVER_ERROR,
- throwable.getMessage()));
+ return Mono.just(new SecurityResponse(HttpStatus.INTERNAL_SERVER_ERROR, throwable.getMessage()));
}
private Token getToken(ServerHttpRequest request) {
String authorization = request.getHeaders().getFirst("Authorization");
String bearerPrefix = "bearer ";
- if (authorization == null
- || !authorization.toLowerCase(Locale.ENGLISH).startsWith(bearerPrefix)) {
+ if (authorization == null || !authorization.toLowerCase(Locale.ENGLISH).startsWith(bearerPrefix)) {
throw new CloudFoundryAuthorizationException(Reason.MISSING_AUTHORIZATION,
"Authorization header is missing or invalid");
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundryWebFluxEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundryWebFluxEndpointHandlerMapping.java
index 7a790421106..5a3307157ab 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundryWebFluxEndpointHandlerMapping.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundryWebFluxEndpointHandlerMapping.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2018 the original author or authors.
+ * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,17 +50,15 @@ import org.springframework.web.server.ServerWebExchange;
* @author Phillip Webb
* @author Brian Clozel
*/
-class CloudFoundryWebFluxEndpointHandlerMapping
- extends AbstractWebFluxEndpointHandlerMapping {
+class CloudFoundryWebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointHandlerMapping {
private final CloudFoundrySecurityInterceptor securityInterceptor;
private final EndpointLinksResolver linksResolver;
CloudFoundryWebFluxEndpointHandlerMapping(EndpointMapping endpointMapping,
- Collection endpoints,
- EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration,
- CloudFoundrySecurityInterceptor securityInterceptor,
+ Collection endpoints, EndpointMediaTypes endpointMediaTypes,
+ CorsConfiguration corsConfiguration, CloudFoundrySecurityInterceptor securityInterceptor,
EndpointLinksResolver linksResolver) {
super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration);
this.linksResolver = linksResolver;
@@ -68,10 +66,9 @@ class CloudFoundryWebFluxEndpointHandlerMapping
}
@Override
- protected ReactiveWebOperation wrapReactiveWebOperation(ExposableWebEndpoint endpoint,
- WebOperation operation, ReactiveWebOperation reactiveWebOperation) {
- return new SecureReactiveWebOperation(reactiveWebOperation,
- this.securityInterceptor, endpoint.getEndpointId());
+ protected ReactiveWebOperation wrapReactiveWebOperation(ExposableWebEndpoint endpoint, WebOperation operation,
+ ReactiveWebOperation reactiveWebOperation) {
+ return new SecureReactiveWebOperation(reactiveWebOperation, this.securityInterceptor, endpoint.getEndpointId());
}
@Override
@@ -84,30 +81,26 @@ class CloudFoundryWebFluxEndpointHandlerMapping
@Override
public Publisher> links(ServerWebExchange exchange) {
ServerHttpRequest request = exchange.getRequest();
- return CloudFoundryWebFluxEndpointHandlerMapping.this.securityInterceptor
- .preHandle(exchange, "").map((securityResponse) -> {
+ return CloudFoundryWebFluxEndpointHandlerMapping.this.securityInterceptor.preHandle(exchange, "")
+ .map((securityResponse) -> {
if (!securityResponse.getStatus().equals(HttpStatus.OK)) {
return new ResponseEntity<>(securityResponse.getStatus());
}
- AccessLevel accessLevel = exchange
- .getAttribute(AccessLevel.REQUEST_ATTRIBUTE);
+ AccessLevel accessLevel = exchange.getAttribute(AccessLevel.REQUEST_ATTRIBUTE);
Map links = CloudFoundryWebFluxEndpointHandlerMapping.this.linksResolver
.resolveLinks(request.getURI().toString());
return new ResponseEntity<>(
- Collections.singletonMap("_links",
- getAccessibleLinks(accessLevel, links)),
+ Collections.singletonMap("_links", getAccessibleLinks(accessLevel, links)),
HttpStatus.OK);
});
}
- private Map getAccessibleLinks(AccessLevel accessLevel,
- Map links) {
+ private Map getAccessibleLinks(AccessLevel accessLevel, Map links) {
if (accessLevel == null) {
return new LinkedHashMap<>();
}
return links.entrySet().stream()
- .filter((entry) -> entry.getKey().equals("self")
- || accessLevel.isAccessAllowed(entry.getKey()))
+ .filter((entry) -> entry.getKey().equals("self") || accessLevel.isAccessAllowed(entry.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
@@ -129,8 +122,7 @@ class CloudFoundryWebFluxEndpointHandlerMapping
private final EndpointId endpointId;
- SecureReactiveWebOperation(ReactiveWebOperation delegate,
- CloudFoundrySecurityInterceptor securityInterceptor,
+ SecureReactiveWebOperation(ReactiveWebOperation delegate, CloudFoundrySecurityInterceptor securityInterceptor,
EndpointId endpointId) {
this.delegate = delegate;
this.securityInterceptor = securityInterceptor;
@@ -138,16 +130,13 @@ class CloudFoundryWebFluxEndpointHandlerMapping
}
@Override
- public Mono> handle(ServerWebExchange exchange,
- Map body) {
- return this.securityInterceptor
- .preHandle(exchange, this.endpointId.toLowerCaseString())
- .flatMap((securityResponse) -> flatMapResponse(exchange, body,
- securityResponse));
+ public Mono> handle(ServerWebExchange exchange, Map body) {
+ return this.securityInterceptor.preHandle(exchange, this.endpointId.toLowerCaseString())
+ .flatMap((securityResponse) -> flatMapResponse(exchange, body, securityResponse));
}
- private Mono> flatMapResponse(ServerWebExchange exchange,
- Map body, SecurityResponse securityResponse) {
+ private Mono> flatMapResponse(ServerWebExchange exchange, Map body,
+ SecurityResponse securityResponse) {
if (!securityResponse.getStatus().equals(HttpStatus.OK)) {
return Mono.just(new ResponseEntity<>(securityResponse.getStatus()));
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java
index 2d931b117d2..5fbce52668c 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java
@@ -75,10 +75,8 @@ import org.springframework.web.server.WebFilter;
* @since 2.0.0
*/
@Configuration(proxyBeanMethods = false)
-@ConditionalOnProperty(prefix = "management.cloudfoundry", name = "enabled",
- matchIfMissing = true)
-@AutoConfigureAfter({ HealthEndpointAutoConfiguration.class,
- InfoEndpointAutoConfiguration.class })
+@ConditionalOnProperty(prefix = "management.cloudfoundry", name = "enabled", matchIfMissing = true)
+@AutoConfigureAfter({ HealthEndpointAutoConfiguration.class, InfoEndpointAutoConfiguration.class })
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
@ConditionalOnCloudPlatform(CloudPlatform.CLOUD_FOUNDRY)
public class ReactiveCloudFoundryActuatorAutoConfiguration {
@@ -89,21 +87,18 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
@ConditionalOnBean({ HealthEndpoint.class, ReactiveHealthEndpointWebExtension.class })
public CloudFoundryReactiveHealthEndpointWebExtension cloudFoundryReactiveHealthEndpointWebExtension(
ReactiveHealthEndpointWebExtension reactiveHealthEndpointWebExtension) {
- return new CloudFoundryReactiveHealthEndpointWebExtension(
- reactiveHealthEndpointWebExtension);
+ return new CloudFoundryReactiveHealthEndpointWebExtension(reactiveHealthEndpointWebExtension);
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnAvailableEndpoint
@ConditionalOnBean({ InfoEndpoint.class, GitProperties.class })
- public CloudFoundryInfoEndpointWebExtension cloudFoundryInfoEndpointWebExtension(
- GitProperties properties, ObjectProvider infoContributors) {
+ public CloudFoundryInfoEndpointWebExtension cloudFoundryInfoEndpointWebExtension(GitProperties properties,
+ ObjectProvider infoContributors) {
List contributors = infoContributors.orderedStream()
.map((infoContributor) -> (infoContributor instanceof GitInfoContributor)
- ? new GitInfoContributor(properties,
- InfoPropertiesInfoContributor.Mode.FULL)
- : infoContributor)
+ ? new GitInfoContributor(properties, InfoPropertiesInfoContributor.Mode.FULL) : infoContributor)
.collect(Collectors.toList());
return new CloudFoundryInfoEndpointWebExtension(new InfoEndpoint(contributors));
}
@@ -111,51 +106,45 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
@Bean
public CloudFoundryWebFluxEndpointHandlerMapping cloudFoundryWebFluxEndpointHandlerMapping(
ParameterValueMapper parameterMapper, EndpointMediaTypes endpointMediaTypes,
- WebClient.Builder webClientBuilder,
- ControllerEndpointsSupplier controllerEndpointsSupplier,
+ WebClient.Builder webClientBuilder, ControllerEndpointsSupplier controllerEndpointsSupplier,
ApplicationContext applicationContext) {
- CloudFoundryWebEndpointDiscoverer endpointDiscoverer = new CloudFoundryWebEndpointDiscoverer(
- applicationContext, parameterMapper, endpointMediaTypes, null,
- Collections.emptyList(), Collections.emptyList());
- CloudFoundrySecurityInterceptor securityInterceptor = getSecurityInterceptor(
- webClientBuilder, applicationContext.getEnvironment());
+ CloudFoundryWebEndpointDiscoverer endpointDiscoverer = new CloudFoundryWebEndpointDiscoverer(applicationContext,
+ parameterMapper, endpointMediaTypes, null, Collections.emptyList(), Collections.emptyList());
+ CloudFoundrySecurityInterceptor securityInterceptor = getSecurityInterceptor(webClientBuilder,
+ applicationContext.getEnvironment());
Collection webEndpoints = endpointDiscoverer.getEndpoints();
List> allEndpoints = new ArrayList<>();
allEndpoints.addAll(webEndpoints);
allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
- return new CloudFoundryWebFluxEndpointHandlerMapping(
- new EndpointMapping("/cloudfoundryapplication"), webEndpoints,
- endpointMediaTypes, getCorsConfiguration(), securityInterceptor,
+ return new CloudFoundryWebFluxEndpointHandlerMapping(new EndpointMapping("/cloudfoundryapplication"),
+ webEndpoints, endpointMediaTypes, getCorsConfiguration(), securityInterceptor,
new EndpointLinksResolver(allEndpoints));
}
- private CloudFoundrySecurityInterceptor getSecurityInterceptor(
- WebClient.Builder webClientBuilder, Environment environment) {
+ private CloudFoundrySecurityInterceptor getSecurityInterceptor(WebClient.Builder webClientBuilder,
+ Environment environment) {
ReactiveCloudFoundrySecurityService cloudfoundrySecurityService = getCloudFoundrySecurityService(
webClientBuilder, environment);
- ReactiveTokenValidator tokenValidator = new ReactiveTokenValidator(
- cloudfoundrySecurityService);
- return new CloudFoundrySecurityInterceptor(tokenValidator,
- cloudfoundrySecurityService,
+ ReactiveTokenValidator tokenValidator = new ReactiveTokenValidator(cloudfoundrySecurityService);
+ return new CloudFoundrySecurityInterceptor(tokenValidator, cloudfoundrySecurityService,
environment.getProperty("vcap.application.application_id"));
}
- private ReactiveCloudFoundrySecurityService getCloudFoundrySecurityService(
- WebClient.Builder webClientBuilder, Environment environment) {
+ private ReactiveCloudFoundrySecurityService getCloudFoundrySecurityService(WebClient.Builder webClientBuilder,
+ Environment environment) {
String cloudControllerUrl = environment.getProperty("vcap.application.cf_api");
- boolean skipSslValidation = environment.getProperty(
- "management.cloudfoundry.skip-ssl-validation", Boolean.class, false);
- return (cloudControllerUrl != null) ? new ReactiveCloudFoundrySecurityService(
- webClientBuilder, cloudControllerUrl, skipSslValidation) : null;
+ boolean skipSslValidation = environment.getProperty("management.cloudfoundry.skip-ssl-validation",
+ Boolean.class, false);
+ return (cloudControllerUrl != null)
+ ? new ReactiveCloudFoundrySecurityService(webClientBuilder, cloudControllerUrl, skipSslValidation)
+ : null;
}
private CorsConfiguration getCorsConfiguration() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin(CorsConfiguration.ALL);
- corsConfiguration.setAllowedMethods(
- Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name()));
- corsConfiguration.setAllowedHeaders(
- Arrays.asList("Authorization", "X-Cf-App-Instance", "Content-Type"));
+ corsConfiguration.setAllowedMethods(Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name()));
+ corsConfiguration.setAllowedHeaders(Arrays.asList("Authorization", "X-Cf-App-Instance", "Content-Type"));
return corsConfiguration;
}
@@ -173,8 +162,7 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
private static class WebFilterChainPostProcessor implements BeanPostProcessor {
@Override
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof WebFilterChainProxy) {
return postProcess((WebFilterChainProxy) bean);
}
@@ -188,10 +176,8 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration {
MatcherSecurityWebFilterChain ignoredRequestFilterChain = new MatcherSecurityWebFilterChain(
cloudFoundryRequestMatcher, Collections.singletonList(noOpFilter));
MatcherSecurityWebFilterChain allRequestsFilterChain = new MatcherSecurityWebFilterChain(
- ServerWebExchangeMatchers.anyExchange(),
- Collections.singletonList(existing));
- return new WebFilterChainProxy(ignoredRequestFilterChain,
- allRequestsFilterChain);
+ ServerWebExchangeMatchers.anyExchange(), Collections.singletonList(existing));
+ return new WebFilterChainProxy(ignoredRequestFilterChain, allRequestsFilterChain);
}
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityService.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityService.java
index cecefdb5331..808cee0c086 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityService.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2018 the original author or authors.
+ * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,8 +54,8 @@ class ReactiveCloudFoundrySecurityService {
private Mono uaaUrl;
- ReactiveCloudFoundrySecurityService(WebClient.Builder webClientBuilder,
- String cloudControllerUrl, boolean skipSslValidation) {
+ ReactiveCloudFoundrySecurityService(WebClient.Builder webClientBuilder, String cloudControllerUrl,
+ boolean skipSslValidation) {
Assert.notNull(webClientBuilder, "Webclient must not be null");
Assert.notNull(cloudControllerUrl, "CloudControllerUrl must not be null");
if (skipSslValidation) {
@@ -66,8 +66,8 @@ class ReactiveCloudFoundrySecurityService {
}
protected ReactorClientHttpConnector buildTrustAllSslConnector() {
- HttpClient client = HttpClient.create().secure(
- (sslContextSpec) -> sslContextSpec.sslContext(createSslContext()));
+ HttpClient client = HttpClient.create()
+ .secure((sslContextSpec) -> sslContextSpec.sslContext(createSslContext()));
return new ReactorClientHttpConnector(client);
}
@@ -86,26 +86,21 @@ class ReactiveCloudFoundrySecurityService {
public Mono getAccessLevel(String token, String applicationId)
throws CloudFoundryAuthorizationException {
String uri = getPermissionsUri(applicationId);
- return this.webClient.get().uri(uri).header("Authorization", "bearer " + token)
- .retrieve().bodyToMono(Map.class).map(this::getAccessLevel)
- .onErrorMap(this::mapError);
+ return this.webClient.get().uri(uri).header("Authorization", "bearer " + token).retrieve().bodyToMono(Map.class)
+ .map(this::getAccessLevel).onErrorMap(this::mapError);
}
private Throwable mapError(Throwable throwable) {
if (throwable instanceof WebClientResponseException) {
- HttpStatus statusCode = ((WebClientResponseException) throwable)
- .getStatusCode();
+ HttpStatus statusCode = ((WebClientResponseException) throwable).getStatusCode();
if (statusCode.equals(HttpStatus.FORBIDDEN)) {
- return new CloudFoundryAuthorizationException(Reason.ACCESS_DENIED,
- "Access denied");
+ return new CloudFoundryAuthorizationException(Reason.ACCESS_DENIED, "Access denied");
}
if (statusCode.is4xxClientError()) {
- return new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN,
- "Invalid token", throwable);
+ return new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN, "Invalid token", throwable);
}
}
- return new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
- "Cloud controller not reachable");
+ return new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE, "Cloud controller not reachable");
}
private AccessLevel getAccessLevel(Map, ?> body) {
@@ -129,9 +124,8 @@ class ReactiveCloudFoundrySecurityService {
private Mono extends Map> fetchTokenKeys(String url) {
RequestHeadersSpec> uri = this.webClient.get().uri(url + "/token_keys");
- return uri.retrieve().bodyToMono(STRING_OBJECT_MAP).map(this::extractTokenKeys)
- .onErrorMap(((ex) -> new CloudFoundryAuthorizationException(
- Reason.SERVICE_UNAVAILABLE, ex.getMessage())));
+ return uri.retrieve().bodyToMono(STRING_OBJECT_MAP).map(this::extractTokenKeys).onErrorMap(
+ ((ex) -> new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE, ex.getMessage())));
}
private Map extractTokenKeys(Map response) {
@@ -148,11 +142,9 @@ class ReactiveCloudFoundrySecurityService {
* @return the UAA url Mono
*/
public Mono getUaaUrl() {
- this.uaaUrl = this.webClient.get().uri(this.cloudControllerUrl + "/info")
- .retrieve().bodyToMono(Map.class)
+ this.uaaUrl = this.webClient.get().uri(this.cloudControllerUrl + "/info").retrieve().bodyToMono(Map.class)
.map((response) -> (String) response.get("token_endpoint")).cache()
- .onErrorMap((ex) -> new CloudFoundryAuthorizationException(
- Reason.SERVICE_UNAVAILABLE,
+ .onErrorMap((ex) -> new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
"Unable to fetch token keys from UAA."));
return this.uaaUrl;
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidator.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidator.java
index 80ffdabff0a..4f3c5b11c37 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidator.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,20 +51,18 @@ class ReactiveTokenValidator {
}
public Mono validate(Token token) {
- return validateAlgorithm(token).then(validateKeyIdAndSignature(token))
- .then(validateExpiry(token)).then(validateIssuer(token))
- .then(validateAudience(token));
+ return validateAlgorithm(token).then(validateKeyIdAndSignature(token)).then(validateExpiry(token))
+ .then(validateIssuer(token)).then(validateAudience(token));
}
private Mono validateAlgorithm(Token token) {
String algorithm = token.getSignatureAlgorithm();
if (algorithm == null) {
- return Mono.error(new CloudFoundryAuthorizationException(
- Reason.INVALID_SIGNATURE, "Signing algorithm cannot be null"));
+ return Mono.error(new CloudFoundryAuthorizationException(Reason.INVALID_SIGNATURE,
+ "Signing algorithm cannot be null"));
}
if (!algorithm.equals("RS256")) {
- return Mono.error(new CloudFoundryAuthorizationException(
- Reason.UNSUPPORTED_TOKEN_SIGNING_ALGORITHM,
+ return Mono.error(new CloudFoundryAuthorizationException(Reason.UNSUPPORTED_TOKEN_SIGNING_ALGORITHM,
"Signing algorithm " + algorithm + " not supported"));
}
return Mono.empty();
@@ -72,8 +70,8 @@ class ReactiveTokenValidator {
private Mono validateKeyIdAndSignature(Token token) {
return getTokenKey(token).filter((tokenKey) -> hasValidSignature(token, tokenKey))
- .switchIfEmpty(Mono.error(new CloudFoundryAuthorizationException(
- Reason.INVALID_SIGNATURE, "RSA Signature did not match content")))
+ .switchIfEmpty(Mono.error(new CloudFoundryAuthorizationException(Reason.INVALID_SIGNATURE,
+ "RSA Signature did not match content")))
.then();
}
@@ -84,11 +82,9 @@ class ReactiveTokenValidator {
return Mono.just(cached);
}
return this.securityService.fetchTokenKeys().doOnSuccess(this::cacheTokenKeys)
- .filter((tokenKeys) -> tokenKeys.containsKey(keyId))
- .map((tokenKeys) -> tokenKeys.get(keyId))
- .switchIfEmpty(Mono.error(
- new CloudFoundryAuthorizationException(Reason.INVALID_KEY_ID,
- "Key Id present in token header does not match")));
+ .filter((tokenKeys) -> tokenKeys.containsKey(keyId)).map((tokenKeys) -> tokenKeys.get(keyId))
+ .switchIfEmpty(Mono.error(new CloudFoundryAuthorizationException(Reason.INVALID_KEY_ID,
+ "Key Id present in token header does not match")));
}
private void cacheTokenKeys(Map tokenKeys) {
@@ -108,8 +104,7 @@ class ReactiveTokenValidator {
}
}
- private PublicKey getPublicKey(String key)
- throws NoSuchAlgorithmException, InvalidKeySpecException {
+ private PublicKey getPublicKey(String key) throws NoSuchAlgorithmException, InvalidKeySpecException {
key = key.replace("-----BEGIN PUBLIC KEY-----\n", "");
key = key.replace("-----END PUBLIC KEY-----", "");
key = key.trim().replace("\n", "");
@@ -121,25 +116,23 @@ class ReactiveTokenValidator {
private Mono validateExpiry(Token token) {
long currentTime = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
if (currentTime > token.getExpiry()) {
- return Mono.error(new CloudFoundryAuthorizationException(Reason.TOKEN_EXPIRED,
- "Token expired"));
+ return Mono.error(new CloudFoundryAuthorizationException(Reason.TOKEN_EXPIRED, "Token expired"));
}
return Mono.empty();
}
private Mono validateIssuer(Token token) {
- return this.securityService.getUaaUrl()
- .map((uaaUrl) -> String.format("%s/oauth/token", uaaUrl))
+ return this.securityService.getUaaUrl().map((uaaUrl) -> String.format("%s/oauth/token", uaaUrl))
.filter((issuerUri) -> issuerUri.equals(token.getIssuer()))
- .switchIfEmpty(Mono.error(new CloudFoundryAuthorizationException(
- Reason.INVALID_ISSUER, "Token issuer does not match")))
+ .switchIfEmpty(Mono.error(
+ new CloudFoundryAuthorizationException(Reason.INVALID_ISSUER, "Token issuer does not match")))
.then();
}
private Mono validateAudience(Token token) {
if (!token.getScope().contains("actuator.read")) {
- return Mono.error(new CloudFoundryAuthorizationException(
- Reason.INVALID_AUDIENCE, "Token does not have audience actuator"));
+ return Mono.error(new CloudFoundryAuthorizationException(Reason.INVALID_AUDIENCE,
+ "Token does not have audience actuator"));
}
return Mono.empty();
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java
index 9d65fbf131c..aad22111d45 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java
@@ -75,10 +75,9 @@ import org.springframework.web.servlet.DispatcherServlet;
* @since 2.0.0
*/
@Configuration(proxyBeanMethods = false)
-@ConditionalOnProperty(prefix = "management.cloudfoundry", name = "enabled",
- matchIfMissing = true)
-@AutoConfigureAfter({ ServletManagementContextAutoConfiguration.class,
- HealthEndpointAutoConfiguration.class, InfoEndpointAutoConfiguration.class })
+@ConditionalOnProperty(prefix = "management.cloudfoundry", name = "enabled", matchIfMissing = true)
+@AutoConfigureAfter({ ServletManagementContextAutoConfiguration.class, HealthEndpointAutoConfiguration.class,
+ InfoEndpointAutoConfiguration.class })
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@ConditionalOnClass(DispatcherServlet.class)
@ConditionalOnBean(DispatcherServlet.class)
@@ -98,13 +97,11 @@ public class CloudFoundryActuatorAutoConfiguration {
@ConditionalOnMissingBean
@ConditionalOnAvailableEndpoint
@ConditionalOnBean({ InfoEndpoint.class, GitProperties.class })
- public CloudFoundryInfoEndpointWebExtension cloudFoundryInfoEndpointWebExtension(
- GitProperties properties, ObjectProvider infoContributors) {
+ public CloudFoundryInfoEndpointWebExtension cloudFoundryInfoEndpointWebExtension(GitProperties properties,
+ ObjectProvider infoContributors) {
List contributors = infoContributors.orderedStream()
.map((infoContributor) -> (infoContributor instanceof GitInfoContributor)
- ? new GitInfoContributor(properties,
- InfoPropertiesInfoContributor.Mode.FULL)
- : infoContributor)
+ ? new GitInfoContributor(properties, InfoPropertiesInfoContributor.Mode.FULL) : infoContributor)
.collect(Collectors.toList());
return new CloudFoundryInfoEndpointWebExtension(new InfoEndpoint(contributors));
}
@@ -112,52 +109,45 @@ public class CloudFoundryActuatorAutoConfiguration {
@Bean
public CloudFoundryWebEndpointServletHandlerMapping cloudFoundryWebEndpointServletHandlerMapping(
ParameterValueMapper parameterMapper, EndpointMediaTypes endpointMediaTypes,
- RestTemplateBuilder restTemplateBuilder,
- ServletEndpointsSupplier servletEndpointsSupplier,
- ControllerEndpointsSupplier controllerEndpointsSupplier,
- ApplicationContext applicationContext) {
- CloudFoundryWebEndpointDiscoverer discoverer = new CloudFoundryWebEndpointDiscoverer(
- applicationContext, parameterMapper, endpointMediaTypes, null,
- Collections.emptyList(), Collections.emptyList());
- CloudFoundrySecurityInterceptor securityInterceptor = getSecurityInterceptor(
- restTemplateBuilder, applicationContext.getEnvironment());
+ RestTemplateBuilder restTemplateBuilder, ServletEndpointsSupplier servletEndpointsSupplier,
+ ControllerEndpointsSupplier controllerEndpointsSupplier, ApplicationContext applicationContext) {
+ CloudFoundryWebEndpointDiscoverer discoverer = new CloudFoundryWebEndpointDiscoverer(applicationContext,
+ parameterMapper, endpointMediaTypes, null, Collections.emptyList(), Collections.emptyList());
+ CloudFoundrySecurityInterceptor securityInterceptor = getSecurityInterceptor(restTemplateBuilder,
+ applicationContext.getEnvironment());
Collection webEndpoints = discoverer.getEndpoints();
List> allEndpoints = new ArrayList<>();
allEndpoints.addAll(webEndpoints);
allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
- return new CloudFoundryWebEndpointServletHandlerMapping(
- new EndpointMapping("/cloudfoundryapplication"), webEndpoints,
- endpointMediaTypes, getCorsConfiguration(), securityInterceptor,
+ return new CloudFoundryWebEndpointServletHandlerMapping(new EndpointMapping("/cloudfoundryapplication"),
+ webEndpoints, endpointMediaTypes, getCorsConfiguration(), securityInterceptor,
new EndpointLinksResolver(allEndpoints));
}
- private CloudFoundrySecurityInterceptor getSecurityInterceptor(
- RestTemplateBuilder restTemplateBuilder, Environment environment) {
- CloudFoundrySecurityService cloudfoundrySecurityService = getCloudFoundrySecurityService(
- restTemplateBuilder, environment);
+ private CloudFoundrySecurityInterceptor getSecurityInterceptor(RestTemplateBuilder restTemplateBuilder,
+ Environment environment) {
+ CloudFoundrySecurityService cloudfoundrySecurityService = getCloudFoundrySecurityService(restTemplateBuilder,
+ environment);
TokenValidator tokenValidator = new TokenValidator(cloudfoundrySecurityService);
- return new CloudFoundrySecurityInterceptor(tokenValidator,
- cloudfoundrySecurityService,
+ return new CloudFoundrySecurityInterceptor(tokenValidator, cloudfoundrySecurityService,
environment.getProperty("vcap.application.application_id"));
}
- private CloudFoundrySecurityService getCloudFoundrySecurityService(
- RestTemplateBuilder restTemplateBuilder, Environment environment) {
+ private CloudFoundrySecurityService getCloudFoundrySecurityService(RestTemplateBuilder restTemplateBuilder,
+ Environment environment) {
String cloudControllerUrl = environment.getProperty("vcap.application.cf_api");
- boolean skipSslValidation = environment.getProperty(
- "management.cloudfoundry.skip-ssl-validation", Boolean.class, false);
- return (cloudControllerUrl != null) ? new CloudFoundrySecurityService(
- restTemplateBuilder, cloudControllerUrl, skipSslValidation) : null;
+ boolean skipSslValidation = environment.getProperty("management.cloudfoundry.skip-ssl-validation",
+ Boolean.class, false);
+ return (cloudControllerUrl != null)
+ ? new CloudFoundrySecurityService(restTemplateBuilder, cloudControllerUrl, skipSslValidation) : null;
}
private CorsConfiguration getCorsConfiguration() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin(CorsConfiguration.ALL);
- corsConfiguration.setAllowedMethods(
- Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name()));
- corsConfiguration.setAllowedHeaders(
- Arrays.asList("Authorization", "X-Cf-App-Instance", "Content-Type"));
+ corsConfiguration.setAllowedMethods(Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name()));
+ corsConfiguration.setAllowedHeaders(Arrays.asList("Authorization", "X-Cf-App-Instance", "Content-Type"));
return corsConfiguration;
}
@@ -169,13 +159,11 @@ public class CloudFoundryActuatorAutoConfiguration {
@ConditionalOnClass(WebSecurity.class)
@Order(SecurityProperties.IGNORED_ORDER)
@Configuration(proxyBeanMethods = false)
- public static class IgnoredPathsWebSecurityConfigurer
- implements WebSecurityConfigurer {
+ public static class IgnoredPathsWebSecurityConfigurer implements WebSecurityConfigurer {
@Override
public void init(WebSecurity builder) throws Exception {
- builder.ignoring().requestMatchers(
- new AntPathRequestMatcher("/cloudfoundryapplication/**"));
+ builder.ignoring().requestMatchers(new AntPathRequestMatcher("/cloudfoundryapplication/**"));
}
@Override
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptor.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptor.java
index 7a273219508..5b612dd6bd0 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptor.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityInterceptor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2018 the original author or authors.
+ * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,8 +41,7 @@ import org.springframework.web.cors.CorsUtils;
*/
class CloudFoundrySecurityInterceptor {
- private static final Log logger = LogFactory
- .getLog(CloudFoundrySecurityInterceptor.class);
+ private static final Log logger = LogFactory.getLog(CloudFoundrySecurityInterceptor.class);
private final TokenValidator tokenValidator;
@@ -53,8 +52,7 @@ class CloudFoundrySecurityInterceptor {
private static final SecurityResponse SUCCESS = SecurityResponse.success();
CloudFoundrySecurityInterceptor(TokenValidator tokenValidator,
- CloudFoundrySecurityService cloudFoundrySecurityService,
- String applicationId) {
+ CloudFoundrySecurityService cloudFoundrySecurityService, String applicationId) {
this.tokenValidator = tokenValidator;
this.cloudFoundrySecurityService = cloudFoundrySecurityService;
this.applicationId = applicationId;
@@ -85,22 +83,17 @@ class CloudFoundrySecurityInterceptor {
return new SecurityResponse(cfException.getStatusCode(),
"{\"security_error\":\"" + cfException.getMessage() + "\"}");
}
- return new SecurityResponse(HttpStatus.INTERNAL_SERVER_ERROR,
- ex.getMessage());
+ return new SecurityResponse(HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
}
return SecurityResponse.success();
}
- private void check(HttpServletRequest request, EndpointId endpointId)
- throws Exception {
+ private void check(HttpServletRequest request, EndpointId endpointId) throws Exception {
Token token = getToken(request);
this.tokenValidator.validate(token);
- AccessLevel accessLevel = this.cloudFoundrySecurityService
- .getAccessLevel(token.toString(), this.applicationId);
- if (!accessLevel.isAccessAllowed(
- (endpointId != null) ? endpointId.toLowerCaseString() : "")) {
- throw new CloudFoundryAuthorizationException(Reason.ACCESS_DENIED,
- "Access denied");
+ AccessLevel accessLevel = this.cloudFoundrySecurityService.getAccessLevel(token.toString(), this.applicationId);
+ if (!accessLevel.isAccessAllowed((endpointId != null) ? endpointId.toLowerCaseString() : "")) {
+ throw new CloudFoundryAuthorizationException(Reason.ACCESS_DENIED, "Access denied");
}
request.setAttribute(AccessLevel.REQUEST_ATTRIBUTE, accessLevel);
}
@@ -108,8 +101,7 @@ class CloudFoundrySecurityInterceptor {
private Token getToken(HttpServletRequest request) {
String authorization = request.getHeader("Authorization");
String bearerPrefix = "bearer ";
- if (authorization == null
- || !authorization.toLowerCase(Locale.ENGLISH).startsWith(bearerPrefix)) {
+ if (authorization == null || !authorization.toLowerCase(Locale.ENGLISH).startsWith(bearerPrefix)) {
throw new CloudFoundryAuthorizationException(Reason.MISSING_AUTHORIZATION,
"Authorization header is missing or invalid");
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityService.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityService.java
index 02cd3f470f4..d06cadbd2b8 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityService.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,13 +47,12 @@ class CloudFoundrySecurityService {
private String uaaUrl;
- CloudFoundrySecurityService(RestTemplateBuilder restTemplateBuilder,
- String cloudControllerUrl, boolean skipSslValidation) {
+ CloudFoundrySecurityService(RestTemplateBuilder restTemplateBuilder, String cloudControllerUrl,
+ boolean skipSslValidation) {
Assert.notNull(restTemplateBuilder, "RestTemplateBuilder must not be null");
Assert.notNull(cloudControllerUrl, "CloudControllerUrl must not be null");
if (skipSslValidation) {
- restTemplateBuilder = restTemplateBuilder
- .requestFactory(SkipSslVerificationHttpRequestFactory.class);
+ restTemplateBuilder = restTemplateBuilder.requestFactory(SkipSslVerificationHttpRequestFactory.class);
}
this.restTemplate = restTemplateBuilder.build();
this.cloudControllerUrl = cloudControllerUrl;
@@ -66,12 +65,10 @@ class CloudFoundrySecurityService {
* @return the access level that should be granted
* @throws CloudFoundryAuthorizationException if the token is not authorized
*/
- public AccessLevel getAccessLevel(String token, String applicationId)
- throws CloudFoundryAuthorizationException {
+ public AccessLevel getAccessLevel(String token, String applicationId) throws CloudFoundryAuthorizationException {
try {
URI uri = getPermissionsUri(applicationId);
- RequestEntity> request = RequestEntity.get(uri)
- .header("Authorization", "bearer " + token).build();
+ RequestEntity> request = RequestEntity.get(uri).header("Authorization", "bearer " + token).build();
Map, ?> body = this.restTemplate.exchange(request, Map.class).getBody();
if (Boolean.TRUE.equals(body.get("read_sensitive_data"))) {
return AccessLevel.FULL;
@@ -80,22 +77,18 @@ class CloudFoundrySecurityService {
}
catch (HttpClientErrorException ex) {
if (ex.getStatusCode().equals(HttpStatus.FORBIDDEN)) {
- throw new CloudFoundryAuthorizationException(Reason.ACCESS_DENIED,
- "Access denied");
+ throw new CloudFoundryAuthorizationException(Reason.ACCESS_DENIED, "Access denied");
}
- throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN,
- "Invalid token", ex);
+ throw new CloudFoundryAuthorizationException(Reason.INVALID_TOKEN, "Invalid token", ex);
}
catch (HttpServerErrorException ex) {
- throw new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
- "Cloud controller not reachable");
+ throw new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE, "Cloud controller not reachable");
}
}
private URI getPermissionsUri(String applicationId) {
try {
- return new URI(this.cloudControllerUrl + "/v2/apps/" + applicationId
- + "/permissions");
+ return new URI(this.cloudControllerUrl + "/v2/apps/" + applicationId + "/permissions");
}
catch (URISyntaxException ex) {
throw new IllegalStateException(ex);
@@ -108,12 +101,10 @@ class CloudFoundrySecurityService {
*/
public Map fetchTokenKeys() {
try {
- return extractTokenKeys(this.restTemplate
- .getForObject(getUaaUrl() + "/token_keys", Map.class));
+ return extractTokenKeys(this.restTemplate.getForObject(getUaaUrl() + "/token_keys", Map.class));
}
catch (HttpStatusCodeException ex) {
- throw new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
- "UAA not reachable");
+ throw new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE, "UAA not reachable");
}
}
@@ -133,8 +124,7 @@ class CloudFoundrySecurityService {
public String getUaaUrl() {
if (this.uaaUrl == null) {
try {
- Map, ?> response = this.restTemplate
- .getForObject(this.cloudControllerUrl + "/info", Map.class);
+ Map, ?> response = this.restTemplate.getForObject(this.cloudControllerUrl + "/info", Map.class);
this.uaaUrl = (String) response.get("token_endpoint");
}
catch (HttpStatusCodeException ex) {
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryWebEndpointServletHandlerMapping.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryWebEndpointServletHandlerMapping.java
index c8792976b9a..4f692456ed2 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryWebEndpointServletHandlerMapping.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryWebEndpointServletHandlerMapping.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2018 the original author or authors.
+ * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,17 +49,15 @@ import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMappi
* @author Phillip Webb
* @author Brian Clozel
*/
-class CloudFoundryWebEndpointServletHandlerMapping
- extends AbstractWebMvcEndpointHandlerMapping {
+class CloudFoundryWebEndpointServletHandlerMapping extends AbstractWebMvcEndpointHandlerMapping {
private final CloudFoundrySecurityInterceptor securityInterceptor;
private final EndpointLinksResolver linksResolver;
CloudFoundryWebEndpointServletHandlerMapping(EndpointMapping endpointMapping,
- Collection endpoints,
- EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration,
- CloudFoundrySecurityInterceptor securityInterceptor,
+ Collection endpoints, EndpointMediaTypes endpointMediaTypes,
+ CorsConfiguration corsConfiguration, CloudFoundrySecurityInterceptor securityInterceptor,
EndpointLinksResolver linksResolver) {
super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration);
this.securityInterceptor = securityInterceptor;
@@ -67,10 +65,9 @@ class CloudFoundryWebEndpointServletHandlerMapping
}
@Override
- protected ServletWebOperation wrapServletWebOperation(ExposableWebEndpoint endpoint,
- WebOperation operation, ServletWebOperation servletWebOperation) {
- return new SecureServletWebOperation(servletWebOperation,
- this.securityInterceptor, endpoint.getEndpointId());
+ protected ServletWebOperation wrapServletWebOperation(ExposableWebEndpoint endpoint, WebOperation operation,
+ ServletWebOperation servletWebOperation) {
+ return new SecureServletWebOperation(servletWebOperation, this.securityInterceptor, endpoint.getEndpointId());
}
@Override
@@ -82,15 +79,13 @@ class CloudFoundryWebEndpointServletHandlerMapping
@Override
@ResponseBody
- public Map> links(HttpServletRequest request,
- HttpServletResponse response) {
+ public Map> links(HttpServletRequest request, HttpServletResponse response) {
SecurityResponse securityResponse = CloudFoundryWebEndpointServletHandlerMapping.this.securityInterceptor
.preHandle(request, null);
if (!securityResponse.getStatus().equals(HttpStatus.OK)) {
sendFailureResponse(response, securityResponse);
}
- AccessLevel accessLevel = (AccessLevel) request
- .getAttribute(AccessLevel.REQUEST_ATTRIBUTE);
+ AccessLevel accessLevel = (AccessLevel) request.getAttribute(AccessLevel.REQUEST_ATTRIBUTE);
Map filteredLinks = new LinkedHashMap<>();
if (accessLevel == null) {
return Collections.singletonMap("_links", filteredLinks);
@@ -98,8 +93,7 @@ class CloudFoundryWebEndpointServletHandlerMapping
Map links = CloudFoundryWebEndpointServletHandlerMapping.this.linksResolver
.resolveLinks(request.getRequestURL().toString());
filteredLinks = links.entrySet().stream()
- .filter((e) -> e.getKey().equals("self")
- || accessLevel.isAccessAllowed(e.getKey()))
+ .filter((e) -> e.getKey().equals("self") || accessLevel.isAccessAllowed(e.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
return Collections.singletonMap("_links", filteredLinks);
}
@@ -109,11 +103,9 @@ class CloudFoundryWebEndpointServletHandlerMapping
return "Actuator root web endpoint";
}
- private void sendFailureResponse(HttpServletResponse response,
- SecurityResponse securityResponse) {
+ private void sendFailureResponse(HttpServletResponse response, SecurityResponse securityResponse) {
try {
- response.sendError(securityResponse.getStatus().value(),
- securityResponse.getMessage());
+ response.sendError(securityResponse.getStatus().value(), securityResponse.getMessage());
}
catch (Exception ex) {
logger.debug("Failed to send error response", ex);
@@ -133,8 +125,7 @@ class CloudFoundryWebEndpointServletHandlerMapping
private final EndpointId endpointId;
- SecureServletWebOperation(ServletWebOperation delegate,
- CloudFoundrySecurityInterceptor securityInterceptor,
+ SecureServletWebOperation(ServletWebOperation delegate, CloudFoundrySecurityInterceptor securityInterceptor,
EndpointId endpointId) {
this.delegate = delegate;
this.securityInterceptor = securityInterceptor;
@@ -143,11 +134,9 @@ class CloudFoundryWebEndpointServletHandlerMapping
@Override
public Object handle(HttpServletRequest request, Map body) {
- SecurityResponse securityResponse = this.securityInterceptor
- .preHandle(request, this.endpointId);
+ SecurityResponse securityResponse = this.securityInterceptor.preHandle(request, this.endpointId);
if (!securityResponse.getStatus().equals(HttpStatus.OK)) {
- return new ResponseEntity