Skip to content

Commit b76aa27

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 8ac1381 + 5ba5027 commit b76aa27

24 files changed

Lines changed: 464 additions & 105 deletions

‎handling-spring-static-resources/.classpath‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
2020
</attributes>
2121
</classpathentry>
22-
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
23-
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
24-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
22+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
2523
<attributes>
26-
<attribute name="owner.project.facets" value="java"/>
24+
<attribute name="maven.pomderived" value="true"/>
2725
</attributes>
2826
</classpathentry>
2927
<classpathentry kind="output" path="target/classes"/>

‎handling-spring-static-resources/.project‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,18 @@
3131
</arguments>
3232
</buildCommand>
3333
<buildCommand>
34-
<name>org.eclipse.m2e.core.maven2Builder</name>
34+
<name>org.hibernate.eclipse.console.hibernateBuilder</name>
3535
<arguments>
3636
</arguments>
3737
</buildCommand>
3838
<buildCommand>
39-
<name>org.hibernate.eclipse.console.hibernateBuilder</name>
39+
<name>org.eclipse.m2e.core.maven2Builder</name>
4040
<arguments>
4141
</arguments>
4242
</buildCommand>
4343
</buildSpec>
4444
<natures>
45+
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
4546
<nature>org.springframework.ide.eclipse.core.springnature</nature>
4647
<nature>org.eclipse.jdt.core.javanature</nature>
4748
<nature>org.eclipse.m2e.core.maven2Nature</nature>
Lines changed: 128 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,91 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
43
<modelVersion>4.0.0</modelVersion>
54
<groupId>org.baeldung</groupId>
65
<artifactId>handling-spring-static-resources</artifactId>
76
<name>handling-spring-static-resources</name>
7+
<version>0.1-SNAPSHOT</version>
88
<packaging>war</packaging>
9-
<version>1.0.0-BUILD-SNAPSHOT</version>
10-
<properties>
11-
<java-version>1.7</java-version>
12-
<org.springframework-version>4.1.0.RELEASE</org.springframework-version>
13-
<org.springframework.security-version>3.2.0.RELEASE</org.springframework.security-version>
14-
<org.aspectj-version>1.8.1</org.aspectj-version>
15-
<org.slf4j-version>1.6.1</org.slf4j-version>
16-
<!-- javax jsp -->
17-
<javax.servlet.jsp-api.version>2.3.2-b01</javax.servlet.jsp-api.version>
18-
</properties>
9+
1910
<dependencies>
11+
<!-- Spring Security -->
12+
13+
<dependency>
14+
<groupId>org.springframework.security</groupId>
15+
<artifactId>spring-security-web</artifactId>
16+
<version>${org.springframework.security.version}</version>
17+
</dependency>
18+
<dependency>
19+
<groupId>org.springframework.security</groupId>
20+
<artifactId>spring-security-config</artifactId>
21+
<version>${org.springframework.security.version}</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.springframework.security</groupId>
25+
<artifactId>spring-security-taglibs</artifactId>
26+
<version>${org.springframework.security.version}</version>
27+
</dependency>
28+
2029
<!-- Spring -->
2130
<dependency>
2231
<groupId>org.springframework</groupId>
23-
<artifactId>spring-context</artifactId>
24-
<version>4.1.0.RELEASE</version>
32+
<artifactId>spring-core</artifactId>
33+
<version>${org.springframework.version}</version>
2534
<exclusions>
26-
<!-- Exclude Commons Logging in favor of SLF4j -->
2735
<exclusion>
28-
<groupId>commons-logging</groupId>
2936
<artifactId>commons-logging</artifactId>
37+
<groupId>commons-logging</groupId>
3038
</exclusion>
3139
</exclusions>
3240
</dependency>
3341
<dependency>
3442
<groupId>org.springframework</groupId>
35-
<artifactId>spring-webmvc</artifactId>
36-
<version>${org.springframework-version}</version>
43+
<artifactId>spring-context</artifactId>
44+
<version>${org.springframework.version}</version>
3745
</dependency>
3846
<dependency>
39-
<groupId>org.springframework.security</groupId>
40-
<artifactId>spring-security-config</artifactId>
41-
<version>3.2.5.RELEASE</version>
42-
<scope>runtime</scope>
47+
<groupId>org.springframework</groupId>
48+
<artifactId>spring-jdbc</artifactId>
49+
<version>${org.springframework.version}</version>
4350
</dependency>
4451
<dependency>
4552
<groupId>org.springframework</groupId>
46-
<artifactId>spring-context-support</artifactId>
47-
<version>4.1.0.RELEASE</version>
53+
<artifactId>spring-beans</artifactId>
54+
<version>${org.springframework.version}</version>
4855
</dependency>
49-
<!-- AspectJ -->
5056
<dependency>
51-
<groupId>org.aspectj</groupId>
52-
<artifactId>aspectjrt</artifactId>
53-
<version>${org.aspectj-version}</version>
57+
<groupId>org.springframework</groupId>
58+
<artifactId>spring-aop</artifactId>
59+
<version>${org.springframework.version}</version>
5460
</dependency>
55-
56-
<!-- Logging -->
5761
<dependency>
58-
<groupId>org.slf4j</groupId>
59-
<artifactId>slf4j-api</artifactId>
60-
<version>${org.slf4j-version}</version>
62+
<groupId>org.springframework</groupId>
63+
<artifactId>spring-tx</artifactId>
64+
<version>${org.springframework.version}</version>
6165
</dependency>
6266
<dependency>
63-
<groupId>org.slf4j</groupId>
64-
<artifactId>jcl-over-slf4j</artifactId>
65-
<version>${org.slf4j-version}</version>
66-
<scope>runtime</scope>
67+
<groupId>org.springframework</groupId>
68+
<artifactId>spring-expression</artifactId>
69+
<version>${org.springframework.version}</version>
6770
</dependency>
71+
6872
<dependency>
69-
<groupId>org.slf4j</groupId>
70-
<artifactId>slf4j-log4j12</artifactId>
71-
<version>${org.slf4j-version}</version>
72-
<scope>runtime</scope>
73+
<groupId>org.springframework</groupId>
74+
<artifactId>spring-web</artifactId>
75+
<version>${org.springframework.version}</version>
7376
</dependency>
7477
<dependency>
75-
<groupId>log4j</groupId>
76-
<artifactId>log4j</artifactId>
77-
<version>1.2.16</version>
78-
<scope>runtime</scope>
78+
<groupId>org.springframework</groupId>
79+
<artifactId>spring-webmvc</artifactId>
80+
<version>${org.springframework.version}</version>
7981
</dependency>
8082

81-
<!-- @Inject -->
83+
<!-- AOP -->
84+
<dependency>
85+
<groupId>org.aspectj</groupId>
86+
<artifactId>aspectjrt</artifactId>
87+
<version>${org.aspectj-version}</version>
88+
</dependency>
8289
<dependency>
8390
<groupId>javax.inject</groupId>
8491
<artifactId>javax.inject</artifactId>
@@ -101,31 +108,15 @@
101108
<artifactId>jstl</artifactId>
102109
<version>1.2</version>
103110
</dependency>
104-
<!-- Taglibs -->
105-
<dependency>
106-
<groupId>org.springframework.security</groupId>
107-
<artifactId>spring-security-taglibs</artifactId>
108-
<version>3.2.5.RELEASE</version>
109-
</dependency>
110-
<!-- Jackson JSON Processor -->
111111
<dependency>
112112
<groupId>com.fasterxml.jackson.core</groupId>
113113
<artifactId>jackson-databind</artifactId>
114-
<version>2.4.1</version>
115-
</dependency>
116-
117-
<!-- Rome Atom+RSS -->
118-
119-
<!-- JSR 303 with Hibernate Validator -->
120-
<dependency>
121-
<groupId>javax.validation</groupId>
122-
<artifactId>validation-api</artifactId>
123-
<version>1.0.0.GA</version>
114+
<version>${jackson.version}</version>
124115
</dependency>
125116
<dependency>
126117
<groupId>org.hibernate</groupId>
127118
<artifactId>hibernate-validator</artifactId>
128-
<version>4.1.0.Final</version>
119+
<version>${hibernate-validator.version}</version>
129120
</dependency>
130121

131122
<!-- Joda Time Library -->
@@ -141,13 +132,31 @@
141132
<artifactId>handlebars</artifactId>
142133
<version>1.3.2</version>
143134
</dependency>
144-
<!-- Security (used for CSRF protection only) -->
135+
136+
<!-- logging -->
137+
138+
<dependency>
139+
<groupId>org.slf4j</groupId>
140+
<artifactId>slf4j-api</artifactId>
141+
<version>${org.slf4j.version}</version>
142+
</dependency>
145143
<dependency>
146-
<groupId>org.springframework.security</groupId>
147-
<artifactId>spring-security-web</artifactId>
148-
<version>${org.springframework.security-version}</version>
144+
<groupId>ch.qos.logback</groupId>
145+
<artifactId>logback-classic</artifactId>
146+
<version>${logback.version}</version>
147+
<!-- <scope>runtime</scope> -->
148+
</dependency>
149+
<dependency>
150+
<groupId>org.slf4j</groupId>
151+
<artifactId>jcl-over-slf4j</artifactId>
152+
<version>${org.slf4j.version}</version>
153+
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
154+
</dependency>
155+
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
156+
<groupId>org.slf4j</groupId>
157+
<artifactId>log4j-over-slf4j</artifactId>
158+
<version>${org.slf4j.version}</version>
149159
</dependency>
150-
151160

152161
</dependencies>
153162

@@ -160,4 +169,54 @@
160169
</resource>
161170
</resources>
162171
</build>
172+
173+
<properties>
174+
<java-version>1.7</java-version>
175+
<org.springframework-version>4.1.0.RELEASE</org.springframework-version>
176+
<org.springframework.security-version>3.2.0.RELEASE</org.springframework.security-version>
177+
<org.aspectj-version>1.8.1</org.aspectj-version>
178+
<org.slf4j-version>1.6.1</org.slf4j-version>
179+
<javax.servlet.jsp-api.version>2.3.2-b01</javax.servlet.jsp-api.version>
180+
181+
<!-- Spring -->
182+
<org.springframework.version>4.1.1.RELEASE</org.springframework.version>
183+
<org.springframework.security.version>3.2.5.RELEASE</org.springframework.security.version>
184+
185+
<!-- persistence -->
186+
<hibernate.version>4.3.7.Final</hibernate.version>
187+
<mysql-connector-java.version>5.1.32</mysql-connector-java.version>
188+
<spring-data-jpa.version>1.6.2.RELEASE</spring-data-jpa.version>
189+
190+
<!-- marshalling -->
191+
192+
<jackson.version>2.4.2</jackson.version>
193+
194+
<!-- logging -->
195+
<org.slf4j.version>1.7.7</org.slf4j.version>
196+
<logback.version>1.1.2</logback.version>
197+
198+
<!-- various -->
199+
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
200+
201+
<!-- util -->
202+
<guava.version>18.0</guava.version>
203+
<commons-lang3.version>3.3.2</commons-lang3.version>
204+
205+
<!-- testing -->
206+
<org.hamcrest.version>1.3</org.hamcrest.version>
207+
<junit.version>4.11</junit.version>
208+
<mockito.version>1.10.8</mockito.version>
209+
210+
<httpcore.version>4.3.3</httpcore.version>
211+
<httpclient.version>4.3.5</httpclient.version>
212+
213+
<rest-assured.version>2.3.4</rest-assured.version>
214+
215+
<!-- Maven plugins -->
216+
<maven-compiler-plugin.version>3.2</maven-compiler-plugin.version>
217+
<maven-war-plugin.version>2.5</maven-war-plugin.version>
218+
<maven-surefire-plugin.version>2.17</maven-surefire-plugin.version>
219+
<cargo-maven2-plugin.version>1.4.10</cargo-maven2-plugin.version>
220+
</properties>
221+
163222
</project>

‎handling-spring-static-resources/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSu
1717

1818
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
1919

20-
@Override
21-
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
20+
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
2221
handle(request, response, authentication);
2322
HttpSession session = request.getSession(false);
2423
if (session != null) {
@@ -39,9 +38,9 @@ protected void handle(HttpServletRequest request, HttpServletResponse response,
3938
}
4039

4140
protected String determineTargetUrl(Authentication authentication) {
42-
43-
return "/home.html";
44-
41+
42+
return "/home.html";
43+
4544
}
4645

4746
protected void clearAuthenticationAttributes(HttpServletRequest request) {

‎handling-spring-static-resources/src/main/java/org/baeldung/spring/MvcConfig.java‎

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package org.baeldung.spring;
22

3-
43
import java.util.Locale;
54

6-
75
import org.springframework.beans.factory.annotation.Autowired;
86
import org.springframework.context.MessageSource;
97
import org.springframework.context.annotation.Bean;
@@ -42,9 +40,9 @@ public MvcConfig() {
4240
@Override
4341
public void addViewControllers(final ViewControllerRegistry registry) {
4442
super.addViewControllers(registry);
45-
registry.addViewController("/login.html");
43+
registry.addViewController("/login.html");
4644
registry.addViewController("/home.html");
47-
45+
4846
}
4947

5048
@Bean
@@ -55,23 +53,21 @@ public ViewResolver viewResolver() {
5553
bean.setSuffix(".jsp");
5654
return bean;
5755
}
58-
56+
5957
@Override
60-
public void addResourceHandlers(ResourceHandlerRegistry registry) {
61-
//For examples using Spring 4.1.0
62-
if((env.getProperty("resource.handler.conf")).equals("4.1.0")){
58+
public void addResourceHandlers(ResourceHandlerRegistry registry) {
59+
// For examples using Spring 4.1.0
60+
if ((env.getProperty("resource.handler.conf")).equals("4.1.0")) {
6361
registry.addResourceHandler("/js/**").addResourceLocations("/js/").setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver()).addResolver(new PathResourceResolver());
6462
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/", "classpath:/other-resources/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver());
6563
registry.addResourceHandler("/files/**").addResourceLocations("file:/Users/Elena/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver());
66-
registry.addResourceHandler("/other-files/**").addResourceLocations("file:/Users/Elena/").
67-
setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver());
68-
}
69-
//For examples using Spring 4.0.7
70-
else if ((env.getProperty("resource.handler.conf")).equals("4.0.7")){
64+
registry.addResourceHandler("/other-files/**").addResourceLocations("file:/Users/Elena/").setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver());
65+
}
66+
// For examples using Spring 4.0.7
67+
else if ((env.getProperty("resource.handler.conf")).equals("4.0.7")) {
7168
registry.addResourceHandler("/resources/**").addResourceLocations("/", "/resources/", "classpath:/other-resources/");
72-
registry.addResourceHandler("/files/**")
73-
.addResourceLocations("file:/Users/Elena/");
74-
69+
registry.addResourceHandler("/files/**").addResourceLocations("file:/Users/Elena/");
70+
7571
}
7672
}
7773

‎handling-spring-static-resources/src/main/java/org/baeldung/spring/SecSecurityConfig.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@ImportResource({ "classpath:webSecurityConfig.xml" })
88
public class SecSecurityConfig {
99

10-
public SecSecurityConfig() {
10+
public SecSecurityConfig() {
1111
super();
1212
}
1313

0 commit comments

Comments
 (0)