BAEL-89 - reformatting source - adding packaging to pom to parent spring-session module

This commit is contained in:
slavisa-baeldung 2016-11-06 22:28:05 +01:00
parent 9bf8fee210
commit ef09007932
7 changed files with 56 additions and 55 deletions

View File

@ -8,17 +8,17 @@ import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class JettyWebApplication {
public static void main(String[] args) {
SpringApplication.run(JettyWebApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(JettyWebApplication.class, args);
}
@RequestMapping
public String helloJetty() {
return "hello Jetty";
}
@RequestMapping
public String helloJetty() {
return "hello Jetty";
}
@RequestMapping("/test")
public String lksjdf() {
return "";
}
@RequestMapping("/test")
public String lksjdf() {
return "";
}
}

View File

@ -10,12 +10,12 @@ import org.springframework.security.config.http.SessionCreationPolicy;
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.NEVER)
.and()
.authorizeRequests().anyRequest().hasRole("ADMIN");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.NEVER)
.and()
.authorizeRequests().anyRequest().hasRole("ADMIN");
}
}

View File

@ -10,8 +10,8 @@ import org.springframework.session.web.http.HttpSessionStrategy;
@Configuration
@EnableRedisHttpSession
public class SessionConfig extends AbstractHttpSessionApplicationInitializer {
@Bean
public HttpSessionStrategy httpSessionStrategy() {
return new HeaderHttpSessionStrategy();
}
@Bean
public HttpSessionStrategy httpSessionStrategy() {
return new HeaderHttpSessionStrategy();
}
}

View File

@ -1,4 +1,3 @@
server.port=8081
spring.redis.host=localhost
spring.redis.port=6379

View File

@ -4,6 +4,7 @@
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>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
@ -12,6 +13,7 @@
<artifactId>spring-session</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>jetty-session-demo</module>

View File

@ -11,21 +11,21 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("ADMIN");
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("ADMIN");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.httpBasic().and()
.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/tomcat").hasRole("USER")
.antMatchers("/tomcat/admin").hasRole("ADMIN")
.anyRequest().authenticated();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.httpBasic().and()
.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/tomcat").hasRole("USER")
.antMatchers("/tomcat/admin").hasRole("ADMIN")
.anyRequest().authenticated();
}
}

View File

@ -8,22 +8,22 @@ import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class TomcatWebApplication {
public static void main(String[] args) {
SpringApplication.run(TomcatWebApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(TomcatWebApplication.class, args);
}
@RequestMapping
public String helloDefault() {
return "hello default";
}
@RequestMapping
public String helloDefault() {
return "hello default";
}
@RequestMapping("/tomcat")
public String helloTomcat() {
return "hello tomcat";
}
@RequestMapping("/tomcat")
public String helloTomcat() {
return "hello tomcat";
}
@RequestMapping("/tomcat/admin")
public String helloTomcatAdmin() {
return "hello tomcat admin";
}
@RequestMapping("/tomcat/admin")
public String helloTomcatAdmin() {
return "hello tomcat admin";
}
}