-1

I currently working with LDAP using Spring Security with XML Configuration. I need advice about how can i put attributes like URL, port, manager-dn and password in external file.

<ldap-server id="ldapServer"
        url="ldap://xxxxx:3268/dc=xxxxx,dc=com" port="3268"
        manager-dn="xxxxx@xxxxx.com" manager-password="xxxxxx" />

i mean, we need to put it externally because our other team (implementation team) need to change those properties values to go live without changing anything in war/binary file. Thank you

Jens
  • 67,715
  • 15
  • 98
  • 113
Ayu Widi
  • 1
  • 3
  • 1
    Does this answer your question? [Best ways to deal with properties values in XML file in Spring, Maven and Eclipses](https://stackoverflow.com/questions/13297157/best-ways-to-deal-with-properties-values-in-xml-file-in-spring-maven-and-eclips) – Jens Jan 21 '22 at 06:51

1 Answers1

0

Done, thanks to this post

Steps :

  1. create properties file and put it in the server

####### LDAP ##############
ldap.urls= ldap://xxxx:3268/dc=xxxxx,dc=com
ldap.manager-dn= xxxx@xxxxx.com
ldap.manager-password= xxxx
  1. create properyplaceholder bean

<beans:bean
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <beans:property name="location">
            <beans:value>file:///opt/xxxx/xxxxx/application.properties</beans:value>
        </beans:property>
    </beans:bean>
  1. access the properties from XML beans

<ldap-server id="ldapServer" url="${ldap.urls}" port="3268"
        manager-dn="${ldap.manager-dn}"
        manager-password="${ldap.manager-password}" />
Ayu Widi
  • 1
  • 3