<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="
        http://www.springframework.org/schema/security 
        http://www.springframework.org/schema/security/spring-security.xsd
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans.xsd"
>

    <beans:bean id="digestFilter" class="org.springframework.security.web.authentication.www.DigestAuthenticationFilter">
        <beans:property name="userDetailsService" ref="userService"/>
        <beans:property name="authenticationEntryPoint" ref="digestEntryPoint"/>
    </beans:bean>
    <beans:bean id="digestEntryPoint" class="org.springframework.security.web.authentication.www.DigestAuthenticationEntryPoint">
        <beans:property name="realmName" value="Custom Realm Name"/>
        <beans:property name="key" value="uniqueAndSecret"/>
    </beans:bean>

    <http use-expressions="true" create-session="stateless" entry-point-ref="digestEntryPoint">
        <custom-filter ref="digestFilter" after="BASIC_AUTH_FILTER"/>
    </http>

    <authentication-manager>
        <authentication-provider>
            <user-service id="userService">
                <user name="user1" password="user1Pass" authorities="ROLE_USER"/>
                <user name="admin1" password="admin1Pass" authorities="ROLE_ADMIN"/>
            </user-service>
        </authentication-provider>
    </authentication-manager>

    <global-method-security pre-post-annotations="enabled"/>

</beans:beans>