All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.craftercms.security.utils.spring.SecurityEnabledAwareProcessor Maven / Gradle / Ivy

There is a newer version: 4.3.1
Show newest version
package org.craftercms.security.utils.spring;

import org.craftercms.security.utils.SecurityEnabledAware;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * {@link BeanPostProcessor} implementation that passes the {@code securityEnabled} property to beans that
 * implement the {@link SecurityEnabledAware} interface.
 *
 * @author Alfonso Vásquez
 */
public class SecurityEnabledAwareProcessor implements BeanPostProcessor {

    private boolean securityEnabled;

    public SecurityEnabledAwareProcessor(boolean securityEnabled) {
        this.securityEnabled = securityEnabled;
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof SecurityEnabledAware) {
            ((SecurityEnabledAware) bean).setSecurityEnabled(securityEnabled);
        }

        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy