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

crafter.security.security-context.xml Maven / Gradle / Ivy

There is a newer version: 4.3.1
Show newest version
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <!--
    Activates various annotations to be detected in bean classes: Spring's @Required and @Autowired, as well as JSR
    250's @PostConstruct, @PreDestroy and @Resource (if available), JAX-WS's @WebServiceRef (if available), EJB3's @EJB
    (if available), and JPA's @PersistenceContext and @PersistenceUnit (if available).
    -->
    <context:annotation-config/>

    <aop:aspectj-autoproxy/>

    <import resource="classpath:crafter/profile/client-context.xml"/>

    <!-- Default configuration properties -->

    <bean name="crafter.securityProperties"
          class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
        <property name="order" value="100"/>
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
        <property name="locations">
            <list>
                <value>classpath:crafter/security/security.properties</value>
            </list>
        </property>
    </bean>

    <bean id="crafter.securityEnabledAwareProcessor"
          class="org.craftercms.security.utils.spring.SecurityEnabledAwareProcessor">
        <constructor-arg value="${crafter.security.enabled}"/>
    </bean>

    <bean id="crafter.restResponseWriter" class="org.craftercms.commons.rest.HttpMessageConvertingResponseWriter">
        <constructor-arg>
            <bean class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
                <property name="defaultContentType" value="application/json" />
            </bean>
        </constructor-arg>
        <constructor-arg ref="crafter.profileMessageConverters"/>
    </bean>

    <!-- ////////////////////////////////// -->
    <!--								 	-->
    <!--			 Aspects				-->
    <!--									-->
    <!-- ////////////////////////////////// -->

    <bean id="crafter.runIfSecurityEnabledAspect" class="org.craftercms.security.aop.RunIfSecurityEnabledAspect" />

    <bean id="crafter.refreshCurrentAuthenticationOnProfileUpdateAspect"
          class="org.craftercms.security.utils.profile.RefreshCurrentAuthenticationOnProfileUpdateAspect">
        <property name="authenticationCache" ref="crafter.authenticationCache"/>
    </bean>

    <!-- ////////////////////////////////// -->
    <!--								 	-->
    <!--	        Encryption	            -->
    <!--									-->
    <!-- ////////////////////////////////// -->

    <bean id="crafter.textEncryptor" class="org.craftercms.commons.crypto.impl.NoOpTextEncryptor"/>

    <!-- ////////////////////////////////// -->
    <!--								 	-->
    <!--	          Tenant	            -->
    <!--									-->
    <!-- ////////////////////////////////// -->

    <bean id="crafter.defaultTenantResolver" class="org.craftercms.security.utils.tenant.DefaultTenantsResolver">
        <property name="defaultTenantNames" value="${crafter.security.tenant.default.names}"/>
    </bean>

    <bean id="crafter.paramTenantResolver" class="org.craftercms.security.utils.tenant.ParamTenantsResolver"/>

    <bean id="crafter.tenantsResolver" class="org.craftercms.security.utils.tenant.TenantsResolverChain">
        <property name="resolvers">
            <list>
                <ref bean="crafter.paramTenantResolver"/>
                <ref bean="crafter.defaultTenantResolver"/>
            </list>
        </property>
    </bean>

    <!-- ////////////////////////////////// -->
    <!--								 	-->
    <!--			 Filters				-->
    <!--									-->
    <!-- ////////////////////////////////// -->

    <!-- Order of the processors is important, so if you need to override this bean try to maintain a similar order -->
    <bean id="crafter.securityFilter" class="org.craftercms.security.servlet.filters.RequestSecurityFilter">
        <property name="securityProcessors" ref="crafter.securityProcessors"/>
        <property name="urlsToInclude" value="${crafter.security.urlsToInclude}"/>
        <property name="urlsToExclude" value="${crafter.security.urlsToExclude}"/>
    </bean>

    <util:list id="crafter.securityProcessors">
        <ref bean="crafter.addSecurityCookiesProcessor"/>
        <ref bean="crafter.currentAuthenticationResolvingProcessor"/>
        <ref bean="crafter.returnCurrentAuthenticationProcessor"/>
        <ref bean="crafter.loginProcessor"/>
        <ref bean="crafter.logoutProcessor"/>
        <ref bean="crafter.rememberMeAutoLoginProcessor"/>
        <ref bean="crafter.mellonAutoLoginProcessor"/>
        <ref bean="crafter.saveRequestAwareProcessor"/>
        <ref bean="crafter.securityExceptionProcessor"/>
        <ref bean="crafter.urlAccessRestrictionCheckingProcessor"/>
    </util:list>

    <!-- ////////////////////////////////// -->
    <!--								 	-->
    <!--	    Security Cookies			-->
    <!--									-->
    <!-- ////////////////////////////////// -->

    <bean id="crafter.ticketCookieManager" class="org.craftercms.commons.http.CookieManager">
        <property name="maxAge" value="${crafter.security.cookie.ticket.maxAge}"/>
        <property name="path" value="/"/>
        <property name="secure" value="${crafter.security.cookie.ticket.secure}"/>
        <property name="httpOnly" value="${crafter.security.cookie.ticket.httpOnly}"/>
    </bean>

    <bean id="crafter.profileLastModifiedCookieManager" class="org.craftercms.commons.http.CookieManager">
        <property name="maxAge" value="${crafter.security.cookie.profileLastModified.maxAge}"/>
        <property name="path" value="/"/>
        <property name="secure" value="${crafter.security.cookie.profileLastModified.secure}"/>
        <property name="httpOnly" value="${crafter.security.cookie.profileLastModified.httpOnly}"/>
    </bean>

    <bean id="crafter.rememberMeCookieManager" class="org.craftercms.commons.http.CookieManager">
        <property name="maxAge" value="${crafter.security.cookie.rememberMe.maxAge}"/>
        <property name="path" value="/"/>
        <property name="secure" value="${crafter.security.cookie.rememberMe.secure}"/>
        <property name="httpOnly" value="${crafter.security.cookie.rememberMe.httpOnly}"/>
    </bean>


    <!-- ////////////////////////////////// -->
    <!--								 	-->
    <!--		       Cache			    -->
    <!--									-->
    <!-- ////////////////////////////////// -->

    <bean id="crafter.authenticationCacheConfig" class="net.sf.ehcache.config.CacheConfiguration">
        <property name="name" value="authenticationCache"/>
        <property name="maxEntriesLocalHeap" value="${crafter.security.authentication.cache.maxElementsInMemory}"/>
        <property name="timeToIdleSeconds" value="${crafter.security.authentication.cache.timeToIdle}"/>
    </bean>

    <bean id="crafter.ehCacheAuthenticationCache" class="org.craftercms.commons.cache.EhCacheFactoryBean">
        <property name="configuration" ref="crafter.authenticationCacheConfig"/>
    </bean>

    <bean id="crafter.authenticationCache"
          class="org.craftercms.security.authentication.impl.EhCacheAuthenticationCache">
        <property name="cache" ref="crafter.ehCacheAuthenticationCache"/>
    </bean>

    <!-- ////////////////////////////////// -->
    <!--								 	-->
    <!--	    Security Processors			-->
    <!--									-->
    <!-- ////////////////////////////////// -->

    <bean id="crafter.addSecurityCookiesProcessor"
          class="org.craftercms.security.processors.impl.AddSecurityCookiesProcessor">
        <property name="ticketCookieManager" ref="crafter.ticketCookieManager"/>
        <property name="profileLastModifiedCookieManager" ref="crafter.profileLastModifiedCookieManager"/>
    </bean>

    <bean id="crafter.currentAuthenticationResolvingProcessor"
          class="org.craftercms.security.processors.impl.CurrentAuthenticationResolvingProcessor">
        <property name="authenticationManager" ref="crafter.authenticationManager"/>
    </bean>

    <bean id="crafter.returnCurrentAuthenticationProcessor"
          class="org.craftercms.security.processors.impl.ReturnCurrentAuthenticationProcessor">
        <property name="responseWriter" ref="crafter.restResponseWriter"/>
    </bean>

    <bean id="crafter.loginProcessor" class="org.craftercms.security.processors.impl.LoginProcessor">
        <property name="tenantsResolver" ref="crafter.tenantsResolver"/>
        <property name="authenticationManager" ref="crafter.authenticationManager"/>
        <property name="rememberMeManager" ref="crafter.rememberMeManager"/>
        <property name="loginSuccessHandler" ref="crafter.loginSuccessHandler"/>
        <property name="loginFailureHandler" ref="crafter.loginFailureHandler"/>
    </bean>

    <bean id="crafter.logoutProcessor" class="org.craftercms.security.processors.impl.LogoutProcessor">
        <property name="authenticationManager" ref="crafter.authenticationManager"/>
        <property name="logoutSuccessHandler" ref="crafter.logoutSuccessHandler"/>
        <property name="rememberMeManager" ref="crafter.rememberMeManager"/>
    </bean>

    <bean id="crafter.saveRequestAwareProcessor"
          class="org.craftercms.security.processors.impl.SavedRequestAwareProcessor"/>

    <bean id="crafter.securityExceptionProcessor"
          class="org.craftercms.security.processors.impl.SecurityExceptionProcessor">
        <property name="authenticationRequiredHandler" ref="crafter.authenticationRequiredHandler"/>
        <property name="accessDeniedHandler" ref="crafter.accessDeniedHandler"/>
    </bean>

    <bean id="crafter.urlAccessRestrictionCheckingProcessor"
          class="org.craftercms.security.processors.impl.UrlAccessRestrictionCheckingProcessor">
        <property name="urlRestrictions" ref="crafter.urlRestrictions"/>
    </bean>

    <bean id="crafter.rememberMeAutoLoginProcessor"
          class="org.craftercms.security.processors.impl.RememberMeAutoLoginProcessor">
        <property name="rememberMeManager" ref="crafter.rememberMeManager"/>
    </bean>

    <bean id="crafter.mellonAutoLoginProcessor"
          class="org.craftercms.security.processors.impl.MellonAutoLoginProcessor">
        <property name="tenantService" ref="crafter.tenantServiceRestClient"/>
        <property name="profileService" ref="crafter.profileServiceRestClient"/>
        <property name="tenantsResolver" ref="crafter.tenantsResolver"/>
        <property name="authenticationManager" ref="crafter.authenticationManager"/>
    </bean>

    <!-- ////////////////////////////////// -->
    <!--								 	-->
    <!--		   Authentication			-->
    <!--									-->
    <!-- ////////////////////////////////// -->

    <bean id="crafter.authenticationManager"
          class="org.craftercms.security.authentication.impl.AuthenticationManagerImpl">
        <property name="authenticationService" ref="crafter.authenticationServiceRestClient"/>
        <property name="authenticationCache" ref="crafter.authenticationCache"/>
        <property name="profileService" ref="crafter.profileServiceRestClient"/>
    </bean>

    <bean id="crafter.loginSuccessHandler" class="org.craftercms.security.authentication.impl.LoginSuccessHandlerImpl">
        <property name="defaultTargetUrl" value="${crafter.security.login.success.url}"/>
        <property name="alwaysUseDefaultTargetUrl" value="${crafter.security.login.success.alwaysUseDefaultUrl}"/>
    </bean>

    <bean id="crafter.loginFailureHandler" class="org.craftercms.security.authentication.impl.LoginFailureHandlerImpl">
        <property name="targetUrl" value="${crafter.security.login.failure.url}"/>
    </bean>

    <bean id="crafter.logoutSuccessHandler" class="org.craftercms.security.authentication.impl.LogoutSuccessHandlerImpl">
        <property name="targetUrl" value="${crafter.security.logout.success.url}"/>
    </bean>

    <bean id="crafter.authenticationRequiredHandler"
          class="org.craftercms.security.authentication.impl.AuthenticationRequiredHandlerImpl">
        <property name="loginFormUrl" value="${crafter.security.login.form.url}"/>
    </bean>

    <!-- ////////////////////////////////// -->
    <!--								 	-->
    <!--		     Remember Me		    -->
    <!--									-->
    <!-- ////////////////////////////////// -->

    <bean id="crafter.rememberMeManager" class="org.craftercms.security.authentication.impl.RememberMeManagerImpl">
        <property name="authenticationService" ref="crafter.authenticationServiceRestClient"/>
        <property name="authenticationManager" ref="crafter.authenticationManager"/>
        <property name="rememberMeCookieManager" ref="crafter.rememberMeCookieManager"/>
        <property name="profileService" ref="crafter.profileServiceRestClient"/>
        <property name="encryptor" ref="crafter.textEncryptor"/>
    </bean>

    <!-- ////////////////////////////////// -->
    <!--								 	-->
    <!--		   Authorization			-->
    <!--									-->
    <!-- ////////////////////////////////// -->

    <bean id="crafter.accessDeniedHandler" class="org.craftercms.security.authorization.impl.AccessDeniedHandlerImpl">
        <property name="errorPageUrl" value="${crafter.security.accessDenied.error.url}"/>
    </bean>

    <!-- ////////////////////////////////// -->
    <!--								 	-->
    <!--		  URL Restrictions			-->
    <!--									-->
    <!-- ////////////////////////////////// -->

    <util:map id="crafter.urlRestrictions">
    </util:map>

</beans>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy