File tree Expand file tree Collapse file tree
spring-security-custom-permission
spring-security-custom-voter
test/java/org/baeldung/web Expand file tree Collapse file tree Original file line number Diff line number Diff line change 128128 <artifactId >spring-security-taglibs</artifactId >
129129 <version >4.1.3.RELEASE</version >
130130 </dependency >
131+
131132 <dependency >
132133 <groupId >javax.servlet.jsp.jstl</groupId >
133134 <artifactId >jstl-api</artifactId >
239240
240241
241242 <properties >
243+ <start-class >org.baeldung.Application</start-class >
244+ <!-- If you want to run the example with the voters comment the tag above and uncomment the one below-->
245+ <!-- <start-class>org.baeldung.voter.VoterApplication</start-class>-->
242246 <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
243247 <java .version>1.8</java .version>
244248 <rest-assured .version>2.4.0</rest-assured .version>
Original file line number Diff line number Diff line change 11package org .baeldung ;
22
33import org .springframework .boot .SpringApplication ;
4- import org .springframework .boot .autoconfigure .SpringBootApplication ;
4+ import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
55import org .springframework .boot .context .web .SpringBootServletInitializer ;
6+ import org .springframework .context .annotation .ComponentScan ;
7+ import org .springframework .context .annotation .Configuration ;
8+ import org .springframework .context .annotation .FilterType ;
69
7- @ SpringBootApplication
10+ @ Configuration
11+ @ EnableAutoConfiguration
12+ @ ComponentScan (excludeFilters =
13+ @ ComponentScan .Filter (type = FilterType .REGEX , pattern = "org.baeldung.voter.*" ))
814public class Application extends SpringBootServletInitializer {
9-
1015 public static void main (String [] args ) {
1116 SpringApplication .run (Application .class , args );
1217 }
Original file line number Diff line number Diff line change 1- package org .baeldung .security ;
1+ package org .baeldung .voter ;
22
33import java .time .LocalDateTime ;
44import java .util .Collection ;
Original file line number Diff line number Diff line change 1+ package org .baeldung .voter ;
2+
3+ import org .springframework .boot .SpringApplication ;
4+ import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
5+ import org .springframework .context .annotation .ComponentScan ;
6+ import org .springframework .context .annotation .Configuration ;
7+ import org .springframework .context .annotation .FilterType ;
8+
9+ @ Configuration
10+ @ EnableAutoConfiguration
11+ @ ComponentScan (basePackages = {"org.baeldung.voter" })
12+ public class VoterApplication {
13+
14+ public static void main (String [] args ) {
15+ SpringApplication .run (VoterApplication .class , args );
16+ }
17+ }
Original file line number Diff line number Diff line change 1- package org .baeldung .web ;
1+ package org .baeldung .voter ;
22
33import org .springframework .context .annotation .Configuration ;
44import org .springframework .security .config .annotation .web .configuration .EnableWebSecurity ;
1010 */
1111
1212@ Configuration
13- public class MvcConfig extends WebMvcConfigurerAdapter {
13+ public class VoterMvcConfig extends WebMvcConfigurerAdapter {
1414 @ Override
1515 public void addViewControllers (ViewControllerRegistry registry ) {
1616 registry .addViewController ("/" ).setViewName ("private" );
Original file line number Diff line number Diff line change 1- package org .baeldung .security ;
1+ package org .baeldung .voter ;
22
33import org .springframework .beans .factory .annotation .Autowired ;
44import org .springframework .context .annotation .Bean ;
1818import java .util .Arrays ;
1919import java .util .List ;
2020
21- @ Configuration
22- @ EnableWebSecurity
21+ // @Configuration
22+ // @EnableWebSecurity
2323public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
2424 @ Autowired
2525 public void configureGlobal (AuthenticationManagerBuilder auth ) throws Exception {
Original file line number Diff line number Diff line change 1- package org .baeldung .security ;
1+ package org .baeldung .voter ;
22
33import org .springframework .context .annotation .Configuration ;
44import org .springframework .context .annotation .ImportResource ;
77 * Created by ambrusadrianz on 09/10/2016.
88 */
99@ Configuration
10- // @ImportResource({"classpath:spring-security.xml"})
10+ @ ImportResource ({"classpath:spring-security.xml" })
1111public class XmlSecurityConfig {
1212 public XmlSecurityConfig () {
1313 super ();
Original file line number Diff line number Diff line change 44 xmlns : beans =" http://www.springframework.org/schema/beans"
55 xsi : schemaLocation ="
66 http://www.springframework.org/schema/security
7- http://www.springframework.org/schema/security/spring-security-4.1 .xsd
7+ http://www.springframework.org/schema/security/spring-security-4.0 .xsd
88 http://www.springframework.org/schema/beans
99 http://www.springframework.org/schema/beans/spring-beans.xsd" >
1010
2222 <beans : bean class =" org.springframework.security.web.access.expression.WebExpressionVoter" />
2323 <beans : bean class =" org.springframework.security.access.vote.AuthenticatedVoter" />
2424 <beans : bean class =" org.springframework.security.access.vote.RoleVoter" />
25- <beans : bean class =" com.example.security .MinuteBasedVoter" />
25+ <beans : bean class =" org.baeldung.voter .MinuteBasedVoter" />
2626 </beans : list >
2727 </beans : constructor-arg >
2828 </beans : bean >
2929
30- <beans : bean id =" minuteBasedVoter" class =" com.example.security .MinuteBasedVoter" />
30+ <beans : bean id =" minuteBasedVoter" class =" org.baeldung.voter .MinuteBasedVoter" />
3131
3232 <authentication-manager >
3333 <authentication-provider >
File renamed without changes.
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments