From 12c41c3531c5a00123040825a1e0ee798947b801 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Tue, 9 Oct 2018 20:40:58 +0530 Subject: [PATCH] BAEL-9148 Fix Java EE Annotations Project - Removed spring security related code from jee-7 project --- jee-7/README.md | 2 - .../springSecurity/ApplicationConfig.java | 13 ------ .../SecurityWebApplicationInitializer.java | 10 ---- .../springSecurity/SpringSecurityConfig.java | 46 ------------------- .../controller/HomeController.java | 28 ----------- .../controller/LoginController.java | 15 ------ .../main/webapp/WEB-INF/spring/security.xml | 23 ---------- jee-7/src/main/webapp/WEB-INF/views/admin.jsp | 12 ----- jee-7/src/main/webapp/WEB-INF/views/home.jsp | 26 ----------- jee-7/src/main/webapp/WEB-INF/views/login.jsp | 26 ----------- jee-7/src/main/webapp/WEB-INF/views/user.jsp | 12 ----- jee-7/src/main/webapp/WEB-INF/web.xml | 5 +- jee-7/src/main/webapp/index.jsp | 11 ----- jee-7/src/main/webapp/secure.jsp | 24 ---------- 14 files changed, 4 insertions(+), 249 deletions(-) delete mode 100755 jee-7/src/main/java/com/baeldung/springSecurity/ApplicationConfig.java delete mode 100644 jee-7/src/main/java/com/baeldung/springSecurity/SecurityWebApplicationInitializer.java delete mode 100644 jee-7/src/main/java/com/baeldung/springSecurity/SpringSecurityConfig.java delete mode 100644 jee-7/src/main/java/com/baeldung/springSecurity/controller/HomeController.java delete mode 100644 jee-7/src/main/java/com/baeldung/springSecurity/controller/LoginController.java delete mode 100644 jee-7/src/main/webapp/WEB-INF/spring/security.xml delete mode 100644 jee-7/src/main/webapp/WEB-INF/views/admin.jsp delete mode 100644 jee-7/src/main/webapp/WEB-INF/views/home.jsp delete mode 100644 jee-7/src/main/webapp/WEB-INF/views/login.jsp delete mode 100644 jee-7/src/main/webapp/WEB-INF/views/user.jsp delete mode 100644 jee-7/src/main/webapp/index.jsp delete mode 100644 jee-7/src/main/webapp/secure.jsp diff --git a/jee-7/README.md b/jee-7/README.md index f0bd65fdf2..a2493e561b 100644 --- a/jee-7/README.md +++ b/jee-7/README.md @@ -5,5 +5,3 @@ - [Introduction to JAX-WS](http://www.baeldung.com/jax-ws) - [A Guide to Java EE Web-Related Annotations](http://www.baeldung.com/javaee-web-annotations) - [Introduction to Testing with Arquillian](http://www.baeldung.com/arquillian) -- [Securing Java EE with Spring Security](http://www.baeldung.com/java-ee-spring-security) -- [A Guide to Java EE Web-Related Annotations](https://www.baeldung.com/javaee-web-annotations) \ No newline at end of file diff --git a/jee-7/src/main/java/com/baeldung/springSecurity/ApplicationConfig.java b/jee-7/src/main/java/com/baeldung/springSecurity/ApplicationConfig.java deleted file mode 100755 index f8e7982253..0000000000 --- a/jee-7/src/main/java/com/baeldung/springSecurity/ApplicationConfig.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.springSecurity; - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; - -/** - * Application class required by JAX-RS. If you don't want to have any - * prefix in the URL, you can set the application path to "/". - */ -@ApplicationPath("/") -public class ApplicationConfig extends Application { - -} diff --git a/jee-7/src/main/java/com/baeldung/springSecurity/SecurityWebApplicationInitializer.java b/jee-7/src/main/java/com/baeldung/springSecurity/SecurityWebApplicationInitializer.java deleted file mode 100644 index e6a05f7b71..0000000000 --- a/jee-7/src/main/java/com/baeldung/springSecurity/SecurityWebApplicationInitializer.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.springSecurity; - -import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; - -public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer { - - public SecurityWebApplicationInitializer() { - super(SpringSecurityConfig.class); - } -} diff --git a/jee-7/src/main/java/com/baeldung/springSecurity/SpringSecurityConfig.java b/jee-7/src/main/java/com/baeldung/springSecurity/SpringSecurityConfig.java deleted file mode 100644 index bda8930f36..0000000000 --- a/jee-7/src/main/java/com/baeldung/springSecurity/SpringSecurityConfig.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.baeldung.springSecurity; - -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - -@Configuration -@EnableWebSecurity -public class SpringSecurityConfig extends WebSecurityConfigurerAdapter { - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth - .inMemoryAuthentication() - .withUser("user1") - .password("user1Pass") - .roles("USER") - .and() - .withUser("admin") - .password("adminPass") - .roles("ADMIN"); - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - http - .csrf() - .disable() - .authorizeRequests() - .antMatchers("/auth/login*") - .anonymous() - .antMatchers("/home/admin*") - .hasRole("ADMIN") - .anyRequest() - .authenticated() - .and() - .formLogin() - .loginPage("/auth/login") - .defaultSuccessUrl("/home", true) - .failureUrl("/auth/login?error=true") - .and() - .logout() - .logoutSuccessUrl("/auth/login"); - } -} \ No newline at end of file diff --git a/jee-7/src/main/java/com/baeldung/springSecurity/controller/HomeController.java b/jee-7/src/main/java/com/baeldung/springSecurity/controller/HomeController.java deleted file mode 100644 index 53fd9f4b81..0000000000 --- a/jee-7/src/main/java/com/baeldung/springSecurity/controller/HomeController.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.springSecurity.controller; - -import javax.mvc.annotation.Controller; -import javax.ws.rs.GET; -import javax.ws.rs.Path; - -@Path("/home") -@Controller -public class HomeController { - - @GET - public String home() { - return "home.jsp"; - } - - @GET - @Path("/user") - public String admin() { - return "user.jsp"; - } - - @GET - @Path("/admin") - public String user() { - return "admin.jsp"; - } - -} diff --git a/jee-7/src/main/java/com/baeldung/springSecurity/controller/LoginController.java b/jee-7/src/main/java/com/baeldung/springSecurity/controller/LoginController.java deleted file mode 100644 index a7e7bb471d..0000000000 --- a/jee-7/src/main/java/com/baeldung/springSecurity/controller/LoginController.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.springSecurity.controller; - -import javax.mvc.annotation.Controller; -import javax.ws.rs.GET; -import javax.ws.rs.Path; - -@Path("/auth/login") -@Controller -public class LoginController { - - @GET - public String login() { - return "login.jsp"; - } -} diff --git a/jee-7/src/main/webapp/WEB-INF/spring/security.xml b/jee-7/src/main/webapp/WEB-INF/spring/security.xml deleted file mode 100644 index 777cd9461f..0000000000 --- a/jee-7/src/main/webapp/WEB-INF/spring/security.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jee-7/src/main/webapp/WEB-INF/views/admin.jsp b/jee-7/src/main/webapp/WEB-INF/views/admin.jsp deleted file mode 100644 index b83ea09f5b..0000000000 --- a/jee-7/src/main/webapp/WEB-INF/views/admin.jsp +++ /dev/null @@ -1,12 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> - - - - -

Welcome to the ADMIN page

- - ">Logout - - - \ No newline at end of file diff --git a/jee-7/src/main/webapp/WEB-INF/views/home.jsp b/jee-7/src/main/webapp/WEB-INF/views/home.jsp deleted file mode 100644 index c6e129c9ce..0000000000 --- a/jee-7/src/main/webapp/WEB-INF/views/home.jsp +++ /dev/null @@ -1,26 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> - - - - -

This is the body of the sample view

- - - This text is only visible to a user -

- ">Restricted Admin Page -

-
- - - This text is only visible to an admin -
- ">Admin Page -
-
- - ">Logout - - - \ No newline at end of file diff --git a/jee-7/src/main/webapp/WEB-INF/views/login.jsp b/jee-7/src/main/webapp/WEB-INF/views/login.jsp deleted file mode 100644 index d6f2e56f3a..0000000000 --- a/jee-7/src/main/webapp/WEB-INF/views/login.jsp +++ /dev/null @@ -1,26 +0,0 @@ - - - - -

Login

- -
- - - - - - - - - - - - - -
User:
Password:
- -
- - - \ No newline at end of file diff --git a/jee-7/src/main/webapp/WEB-INF/views/user.jsp b/jee-7/src/main/webapp/WEB-INF/views/user.jsp deleted file mode 100644 index 11b8155da7..0000000000 --- a/jee-7/src/main/webapp/WEB-INF/views/user.jsp +++ /dev/null @@ -1,12 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> - - - - -

Welcome to the Restricted Admin page

- - ">Logout - - - \ No newline at end of file diff --git a/jee-7/src/main/webapp/WEB-INF/web.xml b/jee-7/src/main/webapp/WEB-INF/web.xml index 1bcbb96e24..e656ffc5be 100644 --- a/jee-7/src/main/webapp/WEB-INF/web.xml +++ b/jee-7/src/main/webapp/WEB-INF/web.xml @@ -1,5 +1,8 @@ - +