mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Merge branch '3.0.x' into 3.1.x
This commit is contained in:
commit
607ed86edb
@ -53,8 +53,6 @@ class ReactiveCloudFoundrySecurityService {
|
|||||||
|
|
||||||
private final String cloudControllerUrl;
|
private final String cloudControllerUrl;
|
||||||
|
|
||||||
private Mono<String> uaaUrl;
|
|
||||||
|
|
||||||
ReactiveCloudFoundrySecurityService(WebClient.Builder webClientBuilder, String cloudControllerUrl,
|
ReactiveCloudFoundrySecurityService(WebClient.Builder webClientBuilder, String cloudControllerUrl,
|
||||||
boolean skipSslValidation) {
|
boolean skipSslValidation) {
|
||||||
Assert.notNull(webClientBuilder, "WebClient must not be null");
|
Assert.notNull(webClientBuilder, "WebClient must not be null");
|
||||||
@ -149,7 +147,7 @@ class ReactiveCloudFoundrySecurityService {
|
|||||||
* @return the UAA url Mono
|
* @return the UAA url Mono
|
||||||
*/
|
*/
|
||||||
Mono<String> getUaaUrl() {
|
Mono<String> getUaaUrl() {
|
||||||
this.uaaUrl = this.webClient.get()
|
return this.webClient.get()
|
||||||
.uri(this.cloudControllerUrl + "/info")
|
.uri(this.cloudControllerUrl + "/info")
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.bodyToMono(Map.class)
|
.bodyToMono(Map.class)
|
||||||
@ -157,7 +155,6 @@ class ReactiveCloudFoundrySecurityService {
|
|||||||
.cache()
|
.cache()
|
||||||
.onErrorMap((ex) -> new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
|
.onErrorMap((ex) -> new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
|
||||||
"Unable to fetch token keys from UAA."));
|
"Unable to fetch token keys from UAA."));
|
||||||
return this.uaaUrl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,8 @@ import java.security.Signature;
|
|||||||
import java.security.spec.InvalidKeySpecException;
|
import java.security.spec.InvalidKeySpecException;
|
||||||
import java.security.spec.X509EncodedKeySpec;
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.ConcurrentMap;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
@ -44,7 +43,7 @@ class ReactiveTokenValidator {
|
|||||||
|
|
||||||
private final ReactiveCloudFoundrySecurityService securityService;
|
private final ReactiveCloudFoundrySecurityService securityService;
|
||||||
|
|
||||||
private volatile ConcurrentMap<String, String> cachedTokenKeys = new ConcurrentHashMap<>();
|
private volatile Map<String, String> cachedTokenKeys = Collections.emptyMap();
|
||||||
|
|
||||||
ReactiveTokenValidator(ReactiveCloudFoundrySecurityService securityService) {
|
ReactiveTokenValidator(ReactiveCloudFoundrySecurityService securityService) {
|
||||||
this.securityService = securityService;
|
this.securityService = securityService;
|
||||||
@ -92,7 +91,7 @@ class ReactiveTokenValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void cacheTokenKeys(Map<String, String> tokenKeys) {
|
private void cacheTokenKeys(Map<String, String> tokenKeys) {
|
||||||
this.cachedTokenKeys = new ConcurrentHashMap<>(tokenKeys);
|
this.cachedTokenKeys = Map.copyOf(tokenKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasValidSignature(Token token, String key) {
|
private boolean hasValidSignature(Token token, String key) {
|
||||||
|
@ -67,7 +67,6 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
|
|||||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||||
import org.springframework.security.web.util.matcher.OrRequestMatcher;
|
import org.springframework.security.web.util.matcher.OrRequestMatcher;
|
||||||
import org.springframework.security.web.util.matcher.RequestMatcher;
|
import org.springframework.security.web.util.matcher.RequestMatcher;
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
import org.springframework.web.servlet.DispatcherServlet;
|
import org.springframework.web.servlet.DispatcherServlet;
|
||||||
|
|
||||||
@ -125,8 +124,8 @@ public class CloudFoundryActuatorAutoConfiguration {
|
|||||||
allEndpoints.addAll(webEndpoints);
|
allEndpoints.addAll(webEndpoints);
|
||||||
allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
|
allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
|
||||||
allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
|
allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
|
||||||
return new CloudFoundryWebEndpointServletHandlerMapping(new EndpointMapping("/cloudfoundryapplication"),
|
return new CloudFoundryWebEndpointServletHandlerMapping(new EndpointMapping(BASE_PATH), webEndpoints,
|
||||||
webEndpoints, endpointMediaTypes, getCorsConfiguration(), securityInterceptor, allEndpoints);
|
endpointMediaTypes, getCorsConfiguration(), securityInterceptor, allEndpoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CloudFoundrySecurityInterceptor getSecurityInterceptor(RestTemplateBuilder restTemplateBuilder,
|
private CloudFoundrySecurityInterceptor getSecurityInterceptor(RestTemplateBuilder restTemplateBuilder,
|
||||||
@ -189,10 +188,8 @@ public class CloudFoundryActuatorAutoConfiguration {
|
|||||||
.forEach((path) -> requestMatchers.add(new AntPathRequestMatcher(path + "/**")));
|
.forEach((path) -> requestMatchers.add(new AntPathRequestMatcher(path + "/**")));
|
||||||
requestMatchers.add(new AntPathRequestMatcher(BASE_PATH));
|
requestMatchers.add(new AntPathRequestMatcher(BASE_PATH));
|
||||||
requestMatchers.add(new AntPathRequestMatcher(BASE_PATH + "/"));
|
requestMatchers.add(new AntPathRequestMatcher(BASE_PATH + "/"));
|
||||||
if (!CollectionUtils.isEmpty(requestMatchers)) {
|
|
||||||
web.ignoring().requestMatchers(new OrRequestMatcher(requestMatchers));
|
web.ignoring().requestMatchers(new OrRequestMatcher(requestMatchers));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class CompositePropagationFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
static class CompostePropagationTests {
|
class CompositePropagationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void keys() {
|
void keys() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2022 the original author or authors.
|
* Copyright 2012-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -152,12 +152,12 @@ class DevToolsR2dbcAutoConfigurationTests {
|
|||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@ClassPathExclusions("r2dbc-pool*.jar")
|
@ClassPathExclusions("r2dbc-pool*.jar")
|
||||||
static class Embedded extends Common {
|
class Embedded extends Common {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
static class Pooled extends Common {
|
class Pooled extends Common {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ import org.springframework.core.Ordered;
|
|||||||
import org.springframework.test.util.ReflectionTestUtils;
|
import org.springframework.test.util.ReflectionTestUtils;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,7 +116,7 @@ class RestartApplicationListenerTests {
|
|||||||
SpringApplication application = new SpringApplication();
|
SpringApplication application = new SpringApplication();
|
||||||
ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
|
ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
|
||||||
listener.onApplicationEvent(new ApplicationStartingEvent(bootstrapContext, application, ARGS));
|
listener.onApplicationEvent(new ApplicationStartingEvent(bootstrapContext, application, ARGS));
|
||||||
assertThat(Restarter.getInstance()).isNotEqualTo(nullValue());
|
assertThat(Restarter.getInstance()).isNotNull();
|
||||||
assertThat(Restarter.getInstance().isFinished()).isFalse();
|
assertThat(Restarter.getInstance().isFinished()).isFalse();
|
||||||
listener.onApplicationEvent(new ApplicationPreparedEvent(application, ARGS, context));
|
listener.onApplicationEvent(new ApplicationPreparedEvent(application, ARGS, context));
|
||||||
if (failed) {
|
if (failed) {
|
||||||
|
@ -253,7 +253,7 @@ public class SpringBootMockMvcBuilderCustomizer implements MockMvcBuilderCustomi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
this.lines.get().clear();
|
this.lines.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -64,7 +64,7 @@ public class JsonStream {
|
|||||||
*/
|
*/
|
||||||
public <T> void get(InputStream content, Class<T> type, Consumer<T> consumer) throws IOException {
|
public <T> void get(InputStream content, Class<T> type, Consumer<T> consumer) throws IOException {
|
||||||
JsonFactory jsonFactory = this.objectMapper.getFactory();
|
JsonFactory jsonFactory = this.objectMapper.getFactory();
|
||||||
JsonParser parser = jsonFactory.createParser(content);
|
try (JsonParser parser = jsonFactory.createParser(content)) {
|
||||||
while (!parser.isClosed()) {
|
while (!parser.isClosed()) {
|
||||||
JsonToken token = parser.nextToken();
|
JsonToken token = parser.nextToken();
|
||||||
if (token != null && token != JsonToken.END_OBJECT) {
|
if (token != null && token != JsonToken.END_OBJECT) {
|
||||||
@ -75,6 +75,7 @@ public class JsonStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T> T read(JsonParser parser, Class<T> type) throws IOException {
|
private <T> T read(JsonParser parser, Class<T> type) throws IOException {
|
||||||
|
@ -265,7 +265,7 @@ class BeanDefinitionLoader {
|
|||||||
.getResources(ClassUtils.convertClassNameToResourcePath(source.toString()) + "/*.class");
|
.getResources(ClassUtils.convertClassNameToResourcePath(source.toString()) + "/*.class");
|
||||||
for (Resource resource : resources) {
|
for (Resource resource : resources) {
|
||||||
String className = StringUtils.stripFilenameExtension(resource.getFilename());
|
String className = StringUtils.stripFilenameExtension(resource.getFilename());
|
||||||
load(Class.forName(source.toString() + "." + className));
|
load(Class.forName(source + "." + className));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ public class StandardConfigDataResource extends ConfigDataResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSameFile(File ours, File other) {
|
private boolean isSameFile(File ours, File other) {
|
||||||
return (ours != null) && (other != null) && ours.equals(other);
|
return (ours != null) && ours.equals(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -119,9 +119,10 @@ public class StandardConfigDataResource extends ConfigDataResource {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
if (this.resource instanceof FileSystemResource || this.resource instanceof FileUrlResource) {
|
if (this.resource instanceof FileSystemResource || this.resource instanceof FileUrlResource) {
|
||||||
try {
|
try {
|
||||||
return "file [" + this.resource.getFile().toString() + "]";
|
return "file [" + this.resource.getFile() + "]";
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
|
// Ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.resource.toString();
|
return this.resource.toString();
|
||||||
@ -131,11 +132,11 @@ public class StandardConfigDataResource extends ConfigDataResource {
|
|||||||
try {
|
try {
|
||||||
if (resource instanceof ClassPathResource || resource instanceof FileSystemResource
|
if (resource instanceof ClassPathResource || resource instanceof FileSystemResource
|
||||||
|| resource instanceof FileUrlResource) {
|
|| resource instanceof FileUrlResource) {
|
||||||
File file = resource.getFile();
|
return resource.getFile().getAbsoluteFile();
|
||||||
return (file != null) ? file.getAbsoluteFile() : null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
|
// Ignore
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user