Skip to content

Commit 88deec0

Browse files
lor6Eugen
authored andcommitted
rename project (eugenp#1144)
1 parent 84ecb92 commit 88deec0

46 files changed

Lines changed: 2276 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎spring-security-mvc-boot/README.MD‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
###The Course
2+
The "REST With Spring" Classes: http://github.learnspringsecurity.com
3+
4+
###Relevant Articles:
5+
- [A Custom Security Expression with Spring Security](http://www.baeldung.com/spring-security-create-new-custom-security-expression)
6+
- [Custom AccessDecisionVoters in Spring Security](http://www.baeldung.com/spring-security-custom-voter)
7+
- [Spring Security: Authentication with a Database-backed UserDetailsService](http://www.baeldung.com/spring-security-authentication-with-a-database)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Class-Path:
3+

‎spring-security-mvc-boot/pom.xml‎

Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
<?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/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.baeldung</groupId>
7+
<artifactId>spring-security-mvc-boot</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<packaging>war</packaging>
10+
11+
<name>spring-security-mvc-boot</name>
12+
<description>Spring Security MVC Boot</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>1.4.2.RELEASE</version>
18+
</parent>
19+
20+
<dependencies>
21+
<dependency>
22+
<groupId>org.springframework.boot</groupId>
23+
<artifactId>spring-boot-starter-security</artifactId>
24+
</dependency>
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter-web</artifactId>
28+
</dependency>
29+
30+
<dependency>
31+
<groupId>org.springframework.boot</groupId>
32+
<artifactId>spring-boot-starter-tomcat</artifactId>
33+
<scope>provided</scope>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
39+
</dependency>
40+
41+
<dependency>
42+
<groupId>org.thymeleaf.extras</groupId>
43+
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
44+
</dependency>
45+
46+
<!-- -->
47+
48+
<dependency>
49+
<groupId>org.springframework.boot</groupId>
50+
<artifactId>spring-boot-starter-data-jpa</artifactId>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>com.h2database</groupId>
55+
<artifactId>h2</artifactId>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>org.springframework.boot</groupId>
60+
<artifactId>spring-boot-starter-test</artifactId>
61+
<scope>test</scope>
62+
</dependency>
63+
64+
<dependency>
65+
<groupId>junit</groupId>
66+
<artifactId>junit</artifactId>
67+
<scope>test</scope>
68+
</dependency>
69+
70+
<dependency>
71+
<groupId>org.hamcrest</groupId>
72+
<artifactId>hamcrest-core</artifactId>
73+
<scope>test</scope>
74+
</dependency>
75+
76+
<dependency>
77+
<groupId>org.hamcrest</groupId>
78+
<artifactId>hamcrest-library</artifactId>
79+
<scope>test</scope>
80+
</dependency>
81+
82+
<dependency>
83+
<groupId>com.jayway.restassured</groupId>
84+
<artifactId>rest-assured</artifactId>
85+
<version>${rest-assured.version}</version>
86+
<scope>test</scope>
87+
<exclusions>
88+
<exclusion>
89+
<artifactId>commons-logging</artifactId>
90+
<groupId>commons-logging</groupId>
91+
</exclusion>
92+
</exclusions>
93+
</dependency>
94+
95+
<dependency>
96+
<groupId>org.springframework</groupId>
97+
<artifactId>spring-test</artifactId>
98+
<scope>test</scope>
99+
</dependency>
100+
101+
<dependency>
102+
<groupId>org.apache.derby</groupId>
103+
<artifactId>derby</artifactId>
104+
<version>${derby.version}</version>
105+
</dependency>
106+
<dependency>
107+
<groupId>org.apache.derby</groupId>
108+
<artifactId>derbyclient</artifactId>
109+
<version>${derby.version}</version>
110+
</dependency>
111+
<dependency>
112+
<groupId>org.apache.derby</groupId>
113+
<artifactId>derbynet</artifactId>
114+
<version>${derby.version}</version>
115+
</dependency>
116+
<dependency>
117+
<groupId>org.apache.derby</groupId>
118+
<artifactId>derbytools</artifactId>
119+
<version>${derby.version}</version>
120+
</dependency>
121+
<dependency>
122+
<groupId>taglibs</groupId>
123+
<artifactId>standard</artifactId>
124+
<version>${taglibs-standard.version}</version>
125+
</dependency>
126+
<dependency>
127+
<groupId>org.springframework.security</groupId>
128+
<artifactId>spring-security-taglibs</artifactId>
129+
<version>${spring-security-taglibs.version}</version>
130+
</dependency>
131+
132+
<dependency>
133+
<groupId>org.springframework.security</groupId>
134+
<artifactId>spring-security-core</artifactId>
135+
<version>${spring-security-core.version}</version>
136+
</dependency>
137+
138+
<dependency>
139+
<groupId>javax.servlet.jsp.jstl</groupId>
140+
<artifactId>jstl-api</artifactId>
141+
<version>${jstl.version}</version>
142+
</dependency>
143+
144+
</dependencies>
145+
146+
<build>
147+
<plugins>
148+
<plugin>
149+
<groupId>org.springframework.boot</groupId>
150+
<artifactId>spring-boot-maven-plugin</artifactId>
151+
</plugin>
152+
153+
154+
<plugin>
155+
<groupId>org.apache.maven.plugins</groupId>
156+
<artifactId>maven-surefire-plugin</artifactId>
157+
<configuration>
158+
<excludes>
159+
<exclude>**/*IntegrationTest.java</exclude>
160+
<exclude>**/*LiveTest.java</exclude>
161+
</excludes>
162+
<systemPropertyVariables>
163+
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
164+
</systemPropertyVariables>
165+
</configuration>
166+
</plugin>
167+
168+
<plugin>
169+
<groupId>org.codehaus.cargo</groupId>
170+
<artifactId>cargo-maven2-plugin</artifactId>
171+
<version>${cargo-maven2-plugin.version}</version>
172+
<configuration>
173+
<wait>true</wait>
174+
<container>
175+
<containerId>tomcat8x</containerId>
176+
<type>embedded</type>
177+
<systemProperties>
178+
<!-- <provPersistenceTarget>cargo</provPersistenceTarget> -->
179+
</systemProperties>
180+
</container>
181+
<configuration>
182+
<properties>
183+
<cargo.servlet.port>8082</cargo.servlet.port>
184+
</properties>
185+
</configuration>
186+
</configuration>
187+
</plugin>
188+
189+
</plugins>
190+
191+
</build>
192+
193+
<profiles>
194+
<profile>
195+
<id>integration</id>
196+
<build>
197+
198+
<plugins>
199+
200+
<plugin>
201+
<groupId>org.apache.maven.plugins</groupId>
202+
<artifactId>maven-surefire-plugin</artifactId>
203+
<executions>
204+
<execution>
205+
<phase>integration-test</phase>
206+
<goals>
207+
<goal>test</goal>
208+
</goals>
209+
<configuration>
210+
<excludes>
211+
<exclude>**/*LiveTest.java</exclude>
212+
</excludes>
213+
<includes>
214+
<include>**/*IntegrationTest.java</include>
215+
</includes>
216+
</configuration>
217+
</execution>
218+
</executions>
219+
<configuration>
220+
<systemPropertyVariables>
221+
<test.mime>json</test.mime>
222+
</systemPropertyVariables>
223+
</configuration>
224+
</plugin>
225+
</plugins>
226+
227+
</build>
228+
</profile>
229+
230+
<profile>
231+
<id>live</id>
232+
<build>
233+
<plugins>
234+
<plugin>
235+
<groupId>org.codehaus.cargo</groupId>
236+
<artifactId>cargo-maven2-plugin</artifactId>
237+
<executions>
238+
<execution>
239+
<id>start-server</id>
240+
<phase>pre-integration-test</phase>
241+
<goals>
242+
<goal>start</goal>
243+
</goals>
244+
</execution>
245+
<execution>
246+
<id>stop-server</id>
247+
<phase>post-integration-test</phase>
248+
<goals>
249+
<goal>stop</goal>
250+
</goals>
251+
</execution>
252+
</executions>
253+
</plugin>
254+
255+
<plugin>
256+
<groupId>org.apache.maven.plugins</groupId>
257+
<artifactId>maven-surefire-plugin</artifactId>
258+
<executions>
259+
<execution>
260+
<phase>integration-test</phase>
261+
<goals>
262+
<goal>test</goal>
263+
</goals>
264+
<configuration>
265+
<excludes>
266+
<exclude>none</exclude>
267+
</excludes>
268+
<includes>
269+
<include>**/*LiveTest.java</include>
270+
</includes>
271+
<systemPropertyVariables>
272+
<webTarget>cargo</webTarget>
273+
</systemPropertyVariables>
274+
</configuration>
275+
</execution>
276+
</executions>
277+
</plugin>
278+
279+
</plugins>
280+
</build>
281+
</profile>
282+
</profiles>
283+
284+
285+
<properties>
286+
<start-class>org.baeldung.Application</start-class>
287+
<!--If you want to run the example with the voters comment the tag above and uncomment the one below-->
288+
<!--<start-class>org.baeldung.voter.VoterApplication</start-class>-->
289+
<!--If you want to run the example with the multiple logins, comment the tag above and uncomment the one below-->
290+
<!--<start-class>org.baeldung.multiplelogin.MultipleLoginApplication</start-class>-->
291+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
292+
<java.version>1.8</java.version>
293+
<derby.version>10.13.1.1</derby.version>
294+
<taglibs-standard.version>1.1.2</taglibs-standard.version>
295+
<spring-security-taglibs.version>4.2.0.RELEASE</spring-security-taglibs.version>
296+
<spring-security-core.version>4.2.0.RELEASE</spring-security-core.version>
297+
298+
<jstl.version>1.2</jstl.version>
299+
<rest-assured.version>2.4.0</rest-assured.version>
300+
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
301+
</properties>
302+
303+
</project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.baeldung;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
5+
import org.springframework.boot.context.web.SpringBootServletInitializer;
6+
import org.springframework.context.annotation.ComponentScan;
7+
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.context.annotation.FilterType;
9+
10+
@Configuration
11+
@EnableAutoConfiguration
12+
@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.baeldung.voter.*"), @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.baeldung.multiplelogin.*")})
13+
public class Application extends SpringBootServletInitializer {
14+
public static void main(String[] args) {
15+
SpringApplication.run(Application.class, args);
16+
}
17+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.baeldung.config;
2+
3+
import org.baeldung.security.CustomMethodSecurityExpressionHandler;
4+
import org.baeldung.security.CustomPermissionEvaluator;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
7+
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
8+
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
9+
10+
@Configuration
11+
@EnableGlobalMethodSecurity(prePostEnabled = true)
12+
public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration {
13+
14+
@Override
15+
protected MethodSecurityExpressionHandler createExpressionHandler() {
16+
// final DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
17+
final CustomMethodSecurityExpressionHandler expressionHandler = new CustomMethodSecurityExpressionHandler();
18+
expressionHandler.setPermissionEvaluator(new CustomPermissionEvaluator());
19+
return expressionHandler;
20+
}
21+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.baeldung.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
6+
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
7+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
8+
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
9+
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
10+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
11+
12+
@Configuration
13+
@EnableWebMvc
14+
public class MvcConfig extends WebMvcConfigurerAdapter {
15+
16+
public MvcConfig() {
17+
super();
18+
}
19+
20+
//
21+
@Bean
22+
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
23+
return new PropertySourcesPlaceholderConfigurer();
24+
}
25+
26+
@Override
27+
public void configureDefaultServletHandling(final DefaultServletHandlerConfigurer configurer) {
28+
configurer.enable();
29+
}
30+
31+
@Override
32+
public void addViewControllers(final ViewControllerRegistry registry) {
33+
super.addViewControllers(registry);
34+
registry.addViewController("/").setViewName("forward:/index");
35+
registry.addViewController("/index");
36+
}
37+
38+
@Override
39+
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
40+
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
41+
}
42+
}

0 commit comments

Comments
 (0)