BAEL-89 - reformatting source - adding packaging to pom to parent spring-session module
This commit is contained in:
parent
9bf8fee210
commit
ef09007932
@ -8,17 +8,17 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@RestController
|
@RestController
|
||||||
public class JettyWebApplication {
|
public class JettyWebApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(JettyWebApplication.class, args);
|
SpringApplication.run(JettyWebApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping
|
@RequestMapping
|
||||||
public String helloJetty() {
|
public String helloJetty() {
|
||||||
return "hello Jetty";
|
return "hello Jetty";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/test")
|
@RequestMapping("/test")
|
||||||
public String lksjdf() {
|
public String lksjdf() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,12 @@ import org.springframework.security.config.http.SessionCreationPolicy;
|
|||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
http
|
http
|
||||||
.sessionManagement()
|
.sessionManagement()
|
||||||
.sessionCreationPolicy(SessionCreationPolicy.NEVER)
|
.sessionCreationPolicy(SessionCreationPolicy.NEVER)
|
||||||
.and()
|
.and()
|
||||||
.authorizeRequests().anyRequest().hasRole("ADMIN");
|
.authorizeRequests().anyRequest().hasRole("ADMIN");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ import org.springframework.session.web.http.HttpSessionStrategy;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@EnableRedisHttpSession
|
@EnableRedisHttpSession
|
||||||
public class SessionConfig extends AbstractHttpSessionApplicationInitializer {
|
public class SessionConfig extends AbstractHttpSessionApplicationInitializer {
|
||||||
@Bean
|
@Bean
|
||||||
public HttpSessionStrategy httpSessionStrategy() {
|
public HttpSessionStrategy httpSessionStrategy() {
|
||||||
return new HeaderHttpSessionStrategy();
|
return new HeaderHttpSessionStrategy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
server.port=8081
|
server.port=8081
|
||||||
|
|
||||||
spring.redis.host=localhost
|
spring.redis.host=localhost
|
||||||
spring.redis.port=6379
|
spring.redis.port=6379
|
@ -4,6 +4,7 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-modules</artifactId>
|
<artifactId>parent-modules</artifactId>
|
||||||
@ -12,6 +13,7 @@
|
|||||||
|
|
||||||
<artifactId>spring-session</artifactId>
|
<artifactId>spring-session</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>jetty-session-demo</module>
|
<module>jetty-session-demo</module>
|
||||||
|
@ -11,21 +11,21 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
|
|||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||||
auth.inMemoryAuthentication()
|
auth.inMemoryAuthentication()
|
||||||
.withUser("user").password("password").roles("USER").and()
|
.withUser("user").password("password").roles("USER").and()
|
||||||
.withUser("admin").password("password").roles("ADMIN");
|
.withUser("admin").password("password").roles("ADMIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
http
|
http
|
||||||
.httpBasic().and()
|
.httpBasic().and()
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
.antMatchers("/").permitAll()
|
.antMatchers("/").permitAll()
|
||||||
.antMatchers("/tomcat").hasRole("USER")
|
.antMatchers("/tomcat").hasRole("USER")
|
||||||
.antMatchers("/tomcat/admin").hasRole("ADMIN")
|
.antMatchers("/tomcat/admin").hasRole("ADMIN")
|
||||||
.anyRequest().authenticated();
|
.anyRequest().authenticated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,22 +8,22 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@RestController
|
@RestController
|
||||||
public class TomcatWebApplication {
|
public class TomcatWebApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(TomcatWebApplication.class, args);
|
SpringApplication.run(TomcatWebApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping
|
@RequestMapping
|
||||||
public String helloDefault() {
|
public String helloDefault() {
|
||||||
return "hello default";
|
return "hello default";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/tomcat")
|
@RequestMapping("/tomcat")
|
||||||
public String helloTomcat() {
|
public String helloTomcat() {
|
||||||
return "hello tomcat";
|
return "hello tomcat";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/tomcat/admin")
|
@RequestMapping("/tomcat/admin")
|
||||||
public String helloTomcatAdmin() {
|
public String helloTomcatAdmin() {
|
||||||
return "hello tomcat admin";
|
return "hello tomcat admin";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user