// Path: cas-security-spring-boot-autoconfigure/src/main/java/com/kakawait/spring/boot/security/cas/autoconfigure/SpringBoot1CasHttpSecurityConfigurerAdapter.java
// static final String SECURITY_PROPERTIES_HEADERS_CLASS =
//         "org.springframework.boot.autoconfigure.security.SecurityProperties$Headers";


import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.cas.web.CasAuthenticationFilter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Method;
import java.util.List;
import static com.kakawait.spring.boot.security.cas.autoconfigure.SpringBoot1CasHttpSecurityConfigurerAdapter.SpringBoot1SecurityProperties.SECURITY_PROPERTIES_HEADERS_CLASS;
package com.kakawait.spring.boot.security.cas.autoconfigure;




/**
 * @author Thibaud Leprêtre
 */
@Order(CasSecurityProperties.CAS_AUTH_ORDER - 10)
class SpringBoot1CasHttpSecurityConfigurerAdapter extends CasSecurityConfigurerAdapter {

    private static final String SPRING_BOOT_WEB_SECURITY_CONFIGURATION_CLASS =
            "org.springframework.boot.autoconfigure.security.SpringBootWebSecurityConfiguration";

    private final SpringBoot1SecurityProperties securityProperties;

    SpringBoot1CasHttpSecurityConfigurerAdapter(SpringBoot1SecurityProperties securityProperties) {
        this.securityProperties = securityProperties;
    }

    @Override
    public void configure(HttpSecurity http) throws Exception {
        if (securityProperties.isRequireSsl()) {
            http.requiresChannel().anyRequest().requiresSecure();
        }
        if (!securityProperties.isEnableCsrf()) {
            http.csrf().disable();
        }
        configureHeaders(http);
        if (securityProperties.getBasic().isEnabled()) {
            BasicAuthenticationFilter basicAuthFilter = new BasicAuthenticationFilter(
                    http.getSharedObject(ApplicationContext.class).getBean(AuthenticationManager.class));
            http.addFilterBefore(basicAuthFilter, CasAuthenticationFilter.class);
        }
    }

    @SuppressWarnings("ConstantConditions")
    private void configureHeaders(HttpSecurity http) throws Exception {
        Method method = ReflectionUtils.findMethod(Class.forName(SPRING_BOOT_WEB_SECURITY_CONFIGURATION_CLASS),
// Path: cas-security-spring-boot-autoconfigure/src/main/java/com/kakawait/spring/boot/security/cas/autoconfigure/SpringBoot1CasHttpSecurityConfigurerAdapter.java
// static final String SECURITY_PROPERTIES_HEADERS_CLASS =
//         "org.springframework.boot.autoconfigure.security.SecurityProperties$Headers";


// Path: cas-security-spring-boot-autoconfigure/src/main/java/com/kakawait/spring/boot/security/cas/autoconfigure/SpringBoot1CasHttpSecurityConfigurerAdapter.java
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.cas.web.CasAuthenticationFilter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Method;
import java.util.List;
import static com.kakawait.spring.boot.security.cas.autoconfigure.SpringBoot1CasHttpSecurityConfigurerAdapter.SpringBoot1SecurityProperties.SECURITY_PROPERTIES_HEADERS_CLASS;

package com.kakawait.spring.boot.security.cas.autoconfigure;




/**
 * @author Thibaud Leprêtre
 */
@Order(CasSecurityProperties.CAS_AUTH_ORDER - 10)
class SpringBoot1CasHttpSecurityConfigurerAdapter extends CasSecurityConfigurerAdapter {

    private static final String SPRING_BOOT_WEB_SECURITY_CONFIGURATION_CLASS =
            "org.springframework.boot.autoconfigure.security.SpringBootWebSecurityConfiguration";

    private final SpringBoot1SecurityProperties securityProperties;

    SpringBoot1CasHttpSecurityConfigurerAdapter(SpringBoot1SecurityProperties securityProperties) {
        this.securityProperties = securityProperties;
    }

    @Override
    public void configure(HttpSecurity http) throws Exception {
        if (securityProperties.isRequireSsl()) {
            http.requiresChannel().anyRequest().requiresSecure();
        }
        if (!securityProperties.isEnableCsrf()) {
            http.csrf().disable();
        }
        configureHeaders(http);
        if (securityProperties.getBasic().isEnabled()) {
            BasicAuthenticationFilter basicAuthFilter = new BasicAuthenticationFilter(
                    http.getSharedObject(ApplicationContext.class).getBean(AuthenticationManager.class));
            http.addFilterBefore(basicAuthFilter, CasAuthenticationFilter.class);
        }
    }

    @SuppressWarnings("ConstantConditions")
    private void configureHeaders(HttpSecurity http) throws Exception {
        Method method = ReflectionUtils.findMethod(Class.forName(SPRING_BOOT_WEB_SECURITY_CONFIGURATION_CLASS),
                "configureHeaders", HeadersConfigurer.class, Class.forName(SECURITY_PROPERTIES_HEADERS_CLASS));