Merge branch '5.1.x'
This commit is contained in:
commit
44df98c82d
|
|
@ -28,7 +28,7 @@ ext {
|
||||||
(it.name != "spring-build-src") && (it.name != "spring-framework-bom") && (it.name != "spring-core-coroutines")
|
(it.name != "spring-build-src") && (it.name != "spring-framework-bom") && (it.name != "spring-core-coroutines")
|
||||||
}
|
}
|
||||||
|
|
||||||
aspectjVersion = "1.9.2"
|
aspectjVersion = "1.9.3"
|
||||||
coroutinesVersion = "1.2.0-alpha-2"
|
coroutinesVersion = "1.2.0-alpha-2"
|
||||||
freemarkerVersion = "2.3.28"
|
freemarkerVersion = "2.3.28"
|
||||||
groovyVersion = "2.5.6"
|
groovyVersion = "2.5.6"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2019 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.
|
||||||
|
|
@ -20,12 +20,14 @@ import javax.servlet.http.Cookie;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of {@code Cookie} with extra attributes, as defined in
|
* Extension of {@code Cookie} with extra attributes, as defined in
|
||||||
* <a href="https://tools.ietf.org/html/rfc6265">RFC 6265</a>.
|
* <a href="https://tools.ietf.org/html/rfc6265">RFC 6265</a>.
|
||||||
*
|
*
|
||||||
* @author Vedran Pavic
|
* @author Vedran Pavic
|
||||||
|
* @author Juergen Hoeller
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public class MockCookie extends Cookie {
|
public class MockCookie extends Cookie {
|
||||||
|
|
@ -39,7 +41,7 @@ public class MockCookie extends Cookie {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with the cookie name and value.
|
* Constructor with the cookie name and value.
|
||||||
* @param name the name
|
* @param name the name
|
||||||
* @param value the value
|
* @param value the value
|
||||||
* @see Cookie#Cookie(String, String)
|
* @see Cookie#Cookie(String, String)
|
||||||
*/
|
*/
|
||||||
|
|
@ -86,22 +88,22 @@ public class MockCookie extends Cookie {
|
||||||
|
|
||||||
MockCookie cookie = new MockCookie(name, value);
|
MockCookie cookie = new MockCookie(name, value);
|
||||||
for (String attribute : attributes) {
|
for (String attribute : attributes) {
|
||||||
if (attribute.startsWith("Domain")) {
|
if (StringUtils.startsWithIgnoreCase(attribute, "Domain")) {
|
||||||
cookie.setDomain(extractAttributeValue(attribute, setCookieHeader));
|
cookie.setDomain(extractAttributeValue(attribute, setCookieHeader));
|
||||||
}
|
}
|
||||||
else if (attribute.startsWith("Max-Age")) {
|
else if (StringUtils.startsWithIgnoreCase(attribute, "Max-Age")) {
|
||||||
cookie.setMaxAge(Integer.parseInt(extractAttributeValue(attribute, setCookieHeader)));
|
cookie.setMaxAge(Integer.parseInt(extractAttributeValue(attribute, setCookieHeader)));
|
||||||
}
|
}
|
||||||
else if (attribute.startsWith("Path")) {
|
else if (StringUtils.startsWithIgnoreCase(attribute, "Path")) {
|
||||||
cookie.setPath(extractAttributeValue(attribute, setCookieHeader));
|
cookie.setPath(extractAttributeValue(attribute, setCookieHeader));
|
||||||
}
|
}
|
||||||
else if (attribute.startsWith("Secure")) {
|
else if (StringUtils.startsWithIgnoreCase(attribute, "Secure")) {
|
||||||
cookie.setSecure(true);
|
cookie.setSecure(true);
|
||||||
}
|
}
|
||||||
else if (attribute.startsWith("HttpOnly")) {
|
else if (StringUtils.startsWithIgnoreCase(attribute, "HttpOnly")) {
|
||||||
cookie.setHttpOnly(true);
|
cookie.setHttpOnly(true);
|
||||||
}
|
}
|
||||||
else if (attribute.startsWith("SameSite")) {
|
else if (StringUtils.startsWithIgnoreCase(attribute, "SameSite")) {
|
||||||
cookie.setSameSite(extractAttributeValue(attribute, setCookieHeader));
|
cookie.setSameSite(extractAttributeValue(attribute, setCookieHeader));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2019 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.
|
||||||
|
|
@ -34,6 +34,7 @@ public class MockCookieTests {
|
||||||
@Rule
|
@Rule
|
||||||
public final ExpectedException exception = ExpectedException.none();
|
public final ExpectedException exception = ExpectedException.none();
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void constructCookie() {
|
public void constructCookie() {
|
||||||
MockCookie cookie = new MockCookie("SESSION", "123");
|
MockCookie cookie = new MockCookie("SESSION", "123");
|
||||||
|
|
@ -57,9 +58,7 @@ public class MockCookieTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseHeaderWithoutAttributes() {
|
public void parseHeaderWithoutAttributes() {
|
||||||
MockCookie cookie;
|
MockCookie cookie = MockCookie.parse("SESSION=123");
|
||||||
|
|
||||||
cookie = MockCookie.parse("SESSION=123");
|
|
||||||
assertCookie(cookie, "SESSION", "123");
|
assertCookie(cookie, "SESSION", "123");
|
||||||
|
|
||||||
cookie = MockCookie.parse("SESSION=123;");
|
cookie = MockCookie.parse("SESSION=123;");
|
||||||
|
|
@ -80,6 +79,11 @@ public class MockCookieTests {
|
||||||
assertEquals("Lax", cookie.getSameSite());
|
assertEquals("Lax", cookie.getSameSite());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assertCookie(MockCookie cookie, String name, String value) {
|
||||||
|
assertEquals(name, cookie.getName());
|
||||||
|
assertEquals(value, cookie.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseNullHeader() {
|
public void parseNullHeader() {
|
||||||
exception.expect(IllegalArgumentException.class);
|
exception.expect(IllegalArgumentException.class);
|
||||||
|
|
@ -103,9 +107,18 @@ public class MockCookieTests {
|
||||||
MockCookie.parse(header);
|
MockCookie.parse(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertCookie(MockCookie cookie, String name, String value) {
|
@Test
|
||||||
assertEquals(name, cookie.getName());
|
public void parseHeaderWithAttributesCaseSensitivity() {
|
||||||
assertEquals(value, cookie.getValue());
|
MockCookie cookie = MockCookie.parse(
|
||||||
|
"SESSION=123; domain=example.com; max-age=60; path=/; secure; httponly; samesite=Lax");
|
||||||
|
|
||||||
|
assertCookie(cookie, "SESSION", "123");
|
||||||
|
assertEquals("example.com", cookie.getDomain());
|
||||||
|
assertEquals(60, cookie.getMaxAge());
|
||||||
|
assertEquals("/", cookie.getPath());
|
||||||
|
assertTrue(cookie.getSecure());
|
||||||
|
assertTrue(cookie.isHttpOnly());
|
||||||
|
assertEquals("Lax", cookie.getSameSite());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2019 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.
|
||||||
|
|
@ -20,12 +20,14 @@ import javax.servlet.http.Cookie;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of {@code Cookie} with extra attributes, as defined in
|
* Extension of {@code Cookie} with extra attributes, as defined in
|
||||||
* <a href="https://tools.ietf.org/html/rfc6265">RFC 6265</a>.
|
* <a href="https://tools.ietf.org/html/rfc6265">RFC 6265</a>.
|
||||||
*
|
*
|
||||||
* @author Vedran Pavic
|
* @author Vedran Pavic
|
||||||
|
* @author Juergen Hoeller
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public class MockCookie extends Cookie {
|
public class MockCookie extends Cookie {
|
||||||
|
|
@ -39,7 +41,7 @@ public class MockCookie extends Cookie {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with the cookie name and value.
|
* Constructor with the cookie name and value.
|
||||||
* @param name the name
|
* @param name the name
|
||||||
* @param value the value
|
* @param value the value
|
||||||
* @see Cookie#Cookie(String, String)
|
* @see Cookie#Cookie(String, String)
|
||||||
*/
|
*/
|
||||||
|
|
@ -86,22 +88,22 @@ public class MockCookie extends Cookie {
|
||||||
|
|
||||||
MockCookie cookie = new MockCookie(name, value);
|
MockCookie cookie = new MockCookie(name, value);
|
||||||
for (String attribute : attributes) {
|
for (String attribute : attributes) {
|
||||||
if (attribute.startsWith("Domain")) {
|
if (StringUtils.startsWithIgnoreCase(attribute, "Domain")) {
|
||||||
cookie.setDomain(extractAttributeValue(attribute, setCookieHeader));
|
cookie.setDomain(extractAttributeValue(attribute, setCookieHeader));
|
||||||
}
|
}
|
||||||
else if (attribute.startsWith("Max-Age")) {
|
else if (StringUtils.startsWithIgnoreCase(attribute, "Max-Age")) {
|
||||||
cookie.setMaxAge(Integer.parseInt(extractAttributeValue(attribute, setCookieHeader)));
|
cookie.setMaxAge(Integer.parseInt(extractAttributeValue(attribute, setCookieHeader)));
|
||||||
}
|
}
|
||||||
else if (attribute.startsWith("Path")) {
|
else if (StringUtils.startsWithIgnoreCase(attribute, "Path")) {
|
||||||
cookie.setPath(extractAttributeValue(attribute, setCookieHeader));
|
cookie.setPath(extractAttributeValue(attribute, setCookieHeader));
|
||||||
}
|
}
|
||||||
else if (attribute.startsWith("Secure")) {
|
else if (StringUtils.startsWithIgnoreCase(attribute, "Secure")) {
|
||||||
cookie.setSecure(true);
|
cookie.setSecure(true);
|
||||||
}
|
}
|
||||||
else if (attribute.startsWith("HttpOnly")) {
|
else if (StringUtils.startsWithIgnoreCase(attribute, "HttpOnly")) {
|
||||||
cookie.setHttpOnly(true);
|
cookie.setHttpOnly(true);
|
||||||
}
|
}
|
||||||
else if (attribute.startsWith("SameSite")) {
|
else if (StringUtils.startsWithIgnoreCase(attribute, "SameSite")) {
|
||||||
cookie.setSameSite(extractAttributeValue(attribute, setCookieHeader));
|
cookie.setSameSite(extractAttributeValue(attribute, setCookieHeader));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ dependencies {
|
||||||
optional("javax.xml.bind:jaxb-api:2.3.1")
|
optional("javax.xml.bind:jaxb-api:2.3.1")
|
||||||
optional("org.webjars:webjars-locator-core:0.37")
|
optional("org.webjars:webjars-locator-core:0.37")
|
||||||
optional("com.rometools:rome:1.12.0")
|
optional("com.rometools:rome:1.12.0")
|
||||||
optional("com.github.librepdf:openpdf:1.2.12")
|
optional("com.github.librepdf:openpdf:1.2.16")
|
||||||
optional("org.apache.poi:poi-ooxml:4.0.1")
|
optional("org.apache.poi:poi-ooxml:4.1.0")
|
||||||
optional("org.freemarker:freemarker:${freemarkerVersion}")
|
optional("org.freemarker:freemarker:${freemarkerVersion}")
|
||||||
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
|
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
|
||||||
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jackson2Version}")
|
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jackson2Version}")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2019 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.
|
||||||
|
|
@ -47,10 +47,6 @@ public class SimpleWebApplicationContext extends StaticWebApplicationContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refresh() throws BeansException {
|
public void refresh() throws BeansException {
|
||||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
|
||||||
pvs.add("commandClass", "org.springframework.tests.sample.beans.TestBean");
|
|
||||||
pvs.add("formView", "form");
|
|
||||||
|
|
||||||
registerSingleton("/locale.do", LocaleChecker.class);
|
registerSingleton("/locale.do", LocaleChecker.class);
|
||||||
|
|
||||||
addMessage("test", Locale.ENGLISH, "test message");
|
addMessage("test", Locale.ENGLISH, "test message");
|
||||||
|
|
@ -63,7 +59,7 @@ public class SimpleWebApplicationContext extends StaticWebApplicationContext {
|
||||||
registerSingleton("handlerMapping", BeanNameUrlHandlerMapping.class);
|
registerSingleton("handlerMapping", BeanNameUrlHandlerMapping.class);
|
||||||
registerSingleton("viewResolver", InternalResourceViewResolver.class);
|
registerSingleton("viewResolver", InternalResourceViewResolver.class);
|
||||||
|
|
||||||
pvs = new MutablePropertyValues();
|
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||||
pvs.add("location", "org/springframework/web/context/WEB-INF/sessionContext.xml");
|
pvs.add("location", "org/springframework/web/context/WEB-INF/sessionContext.xml");
|
||||||
registerSingleton("viewResolver2", XmlViewResolver.class, pvs);
|
registerSingleton("viewResolver2", XmlViewResolver.class, pvs);
|
||||||
|
|
||||||
|
|
@ -76,6 +72,7 @@ public class SimpleWebApplicationContext extends StaticWebApplicationContext {
|
||||||
@Override
|
@Override
|
||||||
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
|
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
|
|
||||||
if (!(RequestContextUtils.findWebApplicationContext(request) instanceof SimpleWebApplicationContext)) {
|
if (!(RequestContextUtils.findWebApplicationContext(request) instanceof SimpleWebApplicationContext)) {
|
||||||
throw new ServletException("Incorrect WebApplicationContext");
|
throw new ServletException("Incorrect WebApplicationContext");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue