<commit_before>package edu.northwestern.bioinformatics.studycalendar.security.plugin;

import edu.northwestern.bioinformatics.studycalendar.StudyCalendarUserException;
import edu.northwestern.bioinformatics.studycalendar.StudyCalendarValidationException;
import gov.nih.nci.cabig.ctms.tools.configuration.Configuration;
import gov.nih.nci.cabig.ctms.tools.configuration.ConfigurationProperty;
import org.acegisecurity.AuthenticationManager;
import org.acegisecurity.ui.AuthenticationEntryPoint;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;

import javax.servlet.Filter;
import java.util.Collection;

/**
 * Template base class for implementors of {@link AuthenticationSystem}.
 *
 * @author <NAME>
 */
public abstract class AbstractAuthenticationSystem implements AuthenticationSystem {
    private final Logger log = LoggerFactory.getLogger(getClass());

    private ApplicationContext applicationContext;
    private Configuration configuration;

    private AuthenticationManager authenticationManager;
    private AuthenticationEntryPoint entryPoint;
    private Filter filter, logoutFilter;

    protected ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    protected Configuration getConfiguration() {
        return configuration;
    }

    public String name() {
        return getClass().getSimpleName().replaceAll("AuthenticationSystem", "");
    }

    public final void initialize(
        ApplicationContext parent, Configuration config
    ) throws AuthenticationSystemInitializationFailure, StudyCalendarValidationException {
        try {
            this.applicationContext = parent;
            this.configuration = config;
            validateRequiredConfigurationProperties();
            initBeforeCreate();
            this.authenticationManager = createAuthenticationManager();
            this.entryPoint = createEntryPoint();
            this.filter = createFilter();
            this.logoutFilter = createLogoutFilter();
            initAfterCreate();
        } catch (StudyCalendarUserException scue) {
            throw scue; // don't wrap properly typed exceptions
        } catch (RuntimeException re) {
            log.info("Initialization failed with runtime exception", re);
            throw new AuthenticationSystemInitializationFailure(re.getMessage(), re);
        }
        AuthenticationSystemValidator.validateRequiredElementsCreated(this);
    }
<commit_msg>Make AbstractAuthenticationSystem#initialize non-final so that it may be proxied by CGLIB.  #597.<commit_after>package edu.northwestern.bioinformatics.studycalendar.security.plugin;

import edu.northwestern.bioinformatics.studycalendar.StudyCalendarUserException;
import edu.northwestern.bioinformatics.studycalendar.StudyCalendarValidationException;
import gov.nih.nci.cabig.ctms.tools.configuration.Configuration;
import gov.nih.nci.cabig.ctms.tools.configuration.ConfigurationProperty;
import org.acegisecurity.AuthenticationManager;
import org.acegisecurity.ui.AuthenticationEntryPoint;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;

import javax.servlet.Filter;
import java.util.Collection;

/**
 * Template base class for implementors of {@link AuthenticationSystem}.
 *
 * @author <NAME>
 */
public abstract class AbstractAuthenticationSystem implements AuthenticationSystem {
    private final Logger log = LoggerFactory.getLogger(getClass());

    private ApplicationContext applicationContext;
    private Configuration configuration;

    private AuthenticationManager authenticationManager;
    private AuthenticationEntryPoint entryPoint;
    private Filter filter, logoutFilter;

    protected ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    protected Configuration getConfiguration() {
        return configuration;
    }

    public String name() {
        return getClass().getSimpleName().replaceAll("AuthenticationSystem", "");
    }

    /**
     * Initializes this authentication system using the values provided by the template methods.
     * <p>
     * When using this base class, you should generally <em>not</em> override this method, but
     * rather the individual template methods.
     *
     * @param parent the system application context
     * @param config
     * @throws AuthenticationSystemInitializationFailure
     * @throws StudyCalendarValidationException
     */
    public void initialize(
        ApplicationContext parent, Configuration config
    ) throws AuthenticationSystemInitializationFailure, StudyCalendarValidationException {
        try {
            this.applicationContext = parent;
            this.configuration = config;
            validateRequiredConfigurationProperties();
            initBeforeCreate();
            this.authenticationManager = createAuthenticationManager();
            this.entryPoint = createEntryPoint();
            this.filter = createFilter();
            this.logoutFilter = createLogoutFilter();
            initAfterCreate();
        } catch (StudyCalendarUserException scue) {
            throw scue; // don't wrap properly typed exceptions
        } catch (RuntimeException re) {
            log.info("Initialization failed with runtime exception", re);
            throw new AuthenticationSystemInitializationFailure(re.getMessage(), re);
        }
        AuthenticationSystemValidator.validateRequiredElementsCreated(this);
    }

{'fraction_non_alphanumeric': 0.07461360810090602, 'fraction_numerical': 0.0012435601350151003, 'mean_word_length': 3.8871527777777777, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '837217', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1267, 'n_words': 311}