// Path: examples/spring-security/src/main/java/com/coverity/security/pie/plugin/springsecurity/PieMethodSecurityConfig.java
// @Configuration
// @EnableGlobalMethodSecurity(securedEnabled = true, proxyTargetClass = true)
// public class PieMethodSecurityConfig extends GlobalMethodSecurityConfiguration {
//     
//     @Autowired
//     private ServletContext servletContext;
//     
//     @Override
//     protected AccessDecisionManager accessDecisionManager() {
//         final SpringSecurityPolicyEnforcer policyEnforcer = (SpringSecurityPolicyEnforcer)servletContext.getAttribute(SpringSecurityPolicyEnforcer.SPRING_SECURITY_POLICY_ATTRIBUTE);
//         if (policyEnforcer == null) {
//             throw new IllegalStateException("Spring policy enforcer wasn't initialized.");
//         }
//         
//         return new PieAccessDecisionManager(policyEnforcer);
//     }
// }


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.servlet.DispatcherServlet;
import com.coverity.security.pie.plugin.springsecurity.PieMethodSecurityConfig;
package com.coverity.security.pie.example.config;




public class WebAppInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
// Path: examples/spring-security/src/main/java/com/coverity/security/pie/plugin/springsecurity/PieMethodSecurityConfig.java
// @Configuration
// @EnableGlobalMethodSecurity(securedEnabled = true, proxyTargetClass = true)
// public class PieMethodSecurityConfig extends GlobalMethodSecurityConfiguration {
//     
//     @Autowired
//     private ServletContext servletContext;
//     
//     @Override
//     protected AccessDecisionManager accessDecisionManager() {
//         final SpringSecurityPolicyEnforcer policyEnforcer = (SpringSecurityPolicyEnforcer)servletContext.getAttribute(SpringSecurityPolicyEnforcer.SPRING_SECURITY_POLICY_ATTRIBUTE);
//         if (policyEnforcer == null) {
//             throw new IllegalStateException("Spring policy enforcer wasn't initialized.");
//         }
//         
//         return new PieAccessDecisionManager(policyEnforcer);
//     }
// }


// Path: examples/spring-security/src/main/java/com/coverity/security/pie/example/config/WebAppInitializer.java
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.servlet.DispatcherServlet;
import com.coverity.security.pie.plugin.springsecurity.PieMethodSecurityConfig;

package com.coverity.security.pie.example.config;




public class WebAppInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
        applicationContext.register(AppConfig.class, SecurityConfig.class, PieMethodSecurityConfig.class);