Skip to content

Commit c45f4d3

Browse files
SpringBootInMemoSecurityExample
1 parent af0cf5d commit c45f4d3

Some content is hidden

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

49 files changed

+14300
-0
lines changed
+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
8+
<parent>
9+
<groupId>org.springframework.boot</groupId>
10+
<artifactId>spring-boot-starter-parent</artifactId>
11+
<version>1.3.3.RELEASE</version>
12+
</parent>
13+
14+
<groupId>SpringBootInMemoSecurityExample</groupId>
15+
<artifactId>SpringBootInMemoSecurityExample</artifactId>
16+
<version>1.0-SNAPSHOT</version>
17+
18+
<organization>
19+
<name>ESpark</name>
20+
<url>http://adarshkumarsingh83.blogspot.in/</url>
21+
</organization>
22+
<licenses>
23+
<license>
24+
<name>ESpark</name>
25+
<url>http://adarshkumarsingh83.blogspot.in/licenses/LICENSE-2.0.txt</url>
26+
<distribution>repo</distribution>
27+
</license>
28+
</licenses>
29+
<developers>
30+
<developer>
31+
<id>adarshkumarsingh83</id>
32+
<name>Adarsh Kumar</name>
33+
<email>adarshkumarsingh83@gmail.com</email>
34+
<roles>
35+
<role>project architect</role>
36+
</roles>
37+
</developer>
38+
</developers>
39+
40+
<repositories>
41+
<repository>
42+
<id>spring-releases</id>
43+
<name>Spring Releases</name>
44+
<url>https://repo.spring.io/libs-release</url>
45+
</repository>
46+
</repositories>
47+
48+
<pluginRepositories>
49+
<pluginRepository>
50+
<id>spring-releases</id>
51+
<name>Spring Releases</name>
52+
<url>https://repo.spring.io/libs-release</url>
53+
</pluginRepository>
54+
</pluginRepositories>
55+
56+
<properties>
57+
<project.name>SpringBootInMemoSecurityExample</project.name>
58+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
59+
<java.version>1.7</java.version>
60+
<junit.version>4.11</junit.version>
61+
</properties>
62+
63+
64+
<dependencies>
65+
66+
<dependency>
67+
<groupId>org.springframework.boot</groupId>
68+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
69+
</dependency>
70+
71+
<dependency>
72+
<groupId>org.springframework.boot</groupId>
73+
<artifactId>spring-boot-starter-security</artifactId>
74+
</dependency>
75+
76+
<dependency>
77+
<groupId>log4j</groupId>
78+
<artifactId>log4j</artifactId>
79+
<version>1.2.17</version>
80+
</dependency>
81+
</dependencies>
82+
83+
84+
<build>
85+
<finalName>${project.name}</finalName>
86+
<resources>
87+
<resource>
88+
<directory>src/main/resources</directory>
89+
<filtering>true</filtering>
90+
</resource>
91+
</resources>
92+
<plugins>
93+
<plugin>
94+
<artifactId>maven-compiler-plugin</artifactId>
95+
<configuration>
96+
<source>${java.version}</source>
97+
<target>${java.version}</target>
98+
<encoding>${project.build.sourceEncoding}</encoding>
99+
</configuration>
100+
</plugin>
101+
<plugin>
102+
<groupId>org.springframework.boot</groupId>
103+
<artifactId>spring-boot-maven-plugin</artifactId>
104+
</plugin>
105+
</plugins>
106+
</build>
107+
108+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
>mvn clean install
2+
>mvn clean package
3+
>mvn spring-boot:run
4+
5+
url=localhost:8080/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2015 Espark And ©Adarsh Development Services @copyright All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* - Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* - Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
*
15+
* - Neither the name of Espark nor the names of its
16+
* contributors may be used to endorse or promote products derived
17+
* from this software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20+
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
package com.espark.adarsh;
32+
33+
import org.springframework.boot.SpringApplication;
34+
import org.springframework.boot.autoconfigure.SpringBootApplication;
35+
36+
37+
38+
39+
/**
40+
* @author Adarsh Kumar
41+
* @author $LastChangedBy: Adarsh Kumar$
42+
* @version $Revision: 0001 $, $Date:: 1/1/10 0:00 AM#$
43+
* @Espark @copyright all right reserve
44+
*/
45+
@SpringBootApplication
46+
public class Application {
47+
48+
public static void main(String[] args) throws Throwable {
49+
SpringApplication.run(Application.class, args);
50+
}
51+
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2015 Espark And ©Adarsh Development Services @copyright All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* - Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* - Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
*
15+
* - Neither the name of Espark nor the names of its
16+
* contributors may be used to endorse or promote products derived
17+
* from this software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20+
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
package com.espark.adarsh.configuration;
32+
33+
import org.springframework.context.annotation.Configuration;
34+
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
35+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
36+
37+
/**
38+
* @author Adarsh Kumar
39+
* @author $LastChangedBy: Adarsh Kumar$
40+
* @version $Revision: 0001 $, $Date:: 1/1/10 0:00 AM#$
41+
* @Espark @copyright all right reserve
42+
*/
43+
@Configuration
44+
public class WbMvcConfiguration extends WebMvcConfigurerAdapter {
45+
46+
@Override
47+
public void addViewControllers(ViewControllerRegistry registry) {
48+
registry.addViewController("/").setViewName("esparkHome");
49+
registry.addViewController("/esparkHome").setViewName("esparkHome");
50+
registry.addViewController("/esparkUserPage").setViewName("esparkUserPage");
51+
registry.addViewController("/esparkLoginPage").setViewName("esparkLoginPage");
52+
}
53+
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright (c) 2015 Espark And ©Adarsh Development Services @copyright All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* - Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* - Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
*
15+
* - Neither the name of Espark nor the names of its
16+
* contributors may be used to endorse or promote products derived
17+
* from this software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20+
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
package com.espark.adarsh.configuration;
32+
33+
import org.springframework.beans.factory.annotation.Autowired;
34+
import org.springframework.context.annotation.Configuration;
35+
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
36+
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
37+
import org.springframework.security.config.annotation.web.builders.WebSecurity;
38+
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
39+
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
40+
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
41+
42+
/**
43+
* @author Adarsh Kumar
44+
* @author $LastChangedBy: Adarsh Kumar$
45+
* @version $Revision: 0001 $, $Date:: 1/1/10 0:00 AM#$
46+
* @Espark @copyright all right reserve
47+
*/
48+
@Configuration
49+
@EnableWebSecurity
50+
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
51+
52+
@Override
53+
public void configure(WebSecurity webSecurity) throws Exception {
54+
webSecurity.ignoring()
55+
.antMatchers("/css/**")
56+
.antMatchers("/js/**")
57+
.antMatchers("/font/**");
58+
}
59+
60+
@Override
61+
protected void configure(HttpSecurity httpSecurity) throws Exception {
62+
httpSecurity
63+
.authorizeRequests()
64+
.antMatchers("/", "/esparkHome").permitAll()
65+
.anyRequest().authenticated()
66+
.and()
67+
.formLogin()
68+
.loginPage("/esparkLoginPage")
69+
.defaultSuccessUrl("/esparkUserPage")
70+
.permitAll()
71+
.and()
72+
.csrf().disable()
73+
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
74+
.logoutSuccessUrl("/esparkHome")
75+
.permitAll();
76+
77+
}
78+
79+
@Autowired
80+
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
81+
auth.inMemoryAuthentication()
82+
.withUser("user").password("user").roles("USER")
83+
.and()
84+
.withUser("admin").password("admin").roles("ADMIN");
85+
}
86+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
message=welcome to the Spring Boot Aop
2+
3+
# Log levels severity mapping.
4+
logging.file=application.log
5+
logging.path=\\log
6+
logging.level.*= ALL
7+
logging.level.org.springframework=ALL
8+
9+
spring.application.index=esparkHome.html
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3+
<log4j:configuration debug="true"
4+
xmlns:log4j='http://jakarta.apache.org/log4j/'>
5+
6+
<appender name="console" class="org.apache.log4j.ConsoleAppender">
7+
<layout class="org.apache.log4j.PatternLayout">
8+
<param name="ConversionPattern"
9+
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
10+
</layout>
11+
</appender>
12+
13+
<appender name="file" class="org.apache.log4j.RollingFileAppender">
14+
<param name="append" value="false" />
15+
<param name="maxFileSize" value="10MB" />
16+
<param name="maxBackupIndex" value="10" />
17+
<param name="file" value="/application.log" />
18+
<layout class="org.apache.log4j.PatternLayout">
19+
<param name="ConversionPattern"
20+
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
21+
</layout>
22+
</appender>
23+
24+
<root>
25+
<level value="ALL" />
26+
<appender-ref ref="console" />
27+
<appender-ref ref="file" />
28+
</root>
29+
30+
</log4j:configuration>

0 commit comments

Comments
 (0)