rename package, add java init
This commit is contained in:
parent
d83eb69567
commit
da1a2cb359
|
@ -0,0 +1,33 @@
|
|||
package com.baeldung;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRegistration;
|
||||
|
||||
import org.springframework.web.WebApplicationInitializer;
|
||||
import org.springframework.web.context.ContextLoaderListener;
|
||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||
import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
import org.springframework.web.filter.DelegatingFilterProxy;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
|
||||
public class AppInitializer implements WebApplicationInitializer {
|
||||
|
||||
@Override
|
||||
public void onStartup(final ServletContext sc) throws ServletException {
|
||||
|
||||
AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
|
||||
|
||||
root.scan("com.baeldung");
|
||||
sc.addListener(new ContextLoaderListener(root));
|
||||
|
||||
ServletRegistration.Dynamic appServlet = sc.addServlet("mvc", new DispatcherServlet(new GenericWebApplicationContext()));
|
||||
appServlet.setLoadOnStartup(1);
|
||||
appServlet.addMapping("/");
|
||||
|
||||
sc.addFilter("securityFilter", new DelegatingFilterProxy("springSecurityFilterChain"))
|
||||
.addMappingForUrlPatterns(null, false, "/*");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.controller;
|
||||
package com.baeldung.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.security;
|
||||
package com.baeldung.security;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.security;
|
||||
package com.baeldung.security;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.core.AuthenticationException;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.security;
|
||||
package com.baeldung.security;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.security;
|
||||
package com.baeldung.security;
|
||||
|
||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
|
|
@ -1,6 +1,5 @@
|
|||
package org.baeldung.spring;
|
||||
package com.baeldung.spring;
|
||||
|
||||
import org.baeldung.security.CustomLogoutSuccessHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
@ -10,6 +9,8 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe
|
|||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
|
||||
|
||||
import com.baeldung.security.CustomLogoutSuccessHandler;
|
||||
|
||||
@Configuration
|
||||
// @ImportResource({ "classpath:channelWebSecurityConfig.xml" })
|
||||
@EnableWebSecurity
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.spring;
|
||||
package com.baeldung.spring;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.spring;
|
||||
package com.baeldung.spring;
|
||||
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
@ -1,8 +1,5 @@
|
|||
package org.baeldung.spring;
|
||||
package com.baeldung.spring;
|
||||
|
||||
import org.baeldung.security.CustomAccessDeniedHandler;
|
||||
import org.baeldung.security.CustomAuthenticationFailureHandler;
|
||||
import org.baeldung.security.CustomLogoutSuccessHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
@ -16,6 +13,10 @@ import org.springframework.security.web.access.AccessDeniedHandler;
|
|||
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
||||
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
|
||||
|
||||
import com.baeldung.security.CustomAccessDeniedHandler;
|
||||
import com.baeldung.security.CustomAuthenticationFailureHandler;
|
||||
import com.baeldung.security.CustomLogoutSuccessHandler;
|
||||
|
||||
@Configuration
|
||||
// @ImportResource({ "classpath:webSecurityConfig.xml" })
|
||||
@EnableWebSecurity
|
|
@ -15,7 +15,7 @@
|
|||
</context-param>
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>org.baeldung.spring</param-value>
|
||||
<param-value>com.baeldung.spring</param-value>
|
||||
</context-param>
|
||||
|
||||
<listener>
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung;
|
||||
package com.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
|
@ -1,6 +1,5 @@
|
|||
package org.baeldung.security;
|
||||
package com.baeldung.security;
|
||||
|
||||
import org.baeldung.spring.SecSecurityConfig;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -13,6 +12,8 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import com.baeldung.spring.SecSecurityConfig;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.security;
|
||||
package com.baeldung.security;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
Loading…
Reference in New Issue