Complete example
Download an example applicationContext.xml
Namespaces
The namespaces can be defined in the beans tag. In the example below the default namespace is the “bean”-namespace and additional namespaces are the security and the ldap namespace.
<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:security="http://www.springframework.org/schema/security"
xmlns:ldap="http://www.springframework.org/schema/ldap"
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/security
http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/ldap
http://www.springframework.org/schema/ldap/spring-ldap.xsd">
</beans>
Beans (Most important for delegate binding)
Beans are defined like the following example. The id is the name of the bean spring is searching for. Usually its the name of the related Interface/field (lowercase start letter).
If you define the field like this private final MaterDataDelegate masterDataDelegate
, spring is searching for an id matching the field name ( in this case masterDataDelegate).
<bean id="masterDataDelegate" class="com.nextlevel.portal.masterdata.delegate.DummyMasterDataDelegateImpl"></bean>
Security
For the beans related to the authentication you need to define one or more authenticationProvider-Beans. Then you have to define a authenticationManager and define all authenticationProvider you want to register. Usually you will only have the DBAuthenticationProvider, to authenticate the user with our default DB implementation.
<bean id="mbseAuthenticationProvider" class="com.nextlevel.portal.portalSecurity.MBSEAuthenticationProvider"></bean>
<bean id="dbAuthenticationProvider" class="com.nextlevel.portal.portalSecurity.DBAuthenticationProvider"></bean>
<security:authentication-manager alias="authenticationManager">
<security:authentication-provider ref="mbseAuthenticationProvider"/>
<security:authentication-provider ref="dbAuthenticationProvider"/>
</security:authentication-manager>
LDAP-Settings
To use LDAP ypu need to set the contextSource and the LDAP-Template. The contextSource contains the connection settings. In the LDAP-Template you need to specify the ContextSource. If the contextSource has the id “contextSource”, the Template will use this as a default
<ldap:context-source id="contextSource"
password="password"
url="ldap://ldap.forumsys.com:389"
username="cn=read-only-admin,dc=example,dc=com"
base="dc=example,dc=com" />
<ldap:ldap-template />
<!--the same like <ldap:ldap-template id="ldapTemplate" context-source-ref="contextSource"/>-->