title: How to avoid plain text LDAP password in spring security?
body: <p>I just managed to get my OpenLDAP + Spring Security work, all works fine except one small issue that in spring security xml, I have to put plain text password there:</p>
  
  <pre><code>&lt;beans:bean id="ldapContextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource"&gt;
      &lt;beans:constructor-arg value="ldap://153.65.x.y:389/dc=example,dc=com" /&gt;
      &lt;beans:property name="userDn" value="cn=Manager,dc=example,dc=com" /&gt;
      &lt;beans:property name="password" value="secret" /&gt;
  &lt;/beans:bean&gt; 
  </code></pre>
  
  <p>Is there any way to avoid this?</p>
  
  <hr>
  
  <p>When I set up my OpenLDAP, I could actually add digest instead of plain text password in <strong>slapd.conf</strong>:</p>
  
  <pre><code>rootpw {SSHA}ZMFfVNPAazmLcif1xC2l9y9SFdKd+x4
  </code></pre>
  
  <p>So I'm hoping that spring security can do the similar thing.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I just realized that it's unnecessary to put LDAP manager name and password here, just provide uri and it would be good enough for spring security to work:</p>
  
  <pre><code>&lt;beans:bean id="ldapContextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource"&gt;
      &lt;beans:constructor-arg value="ldap://153.65.x.y:389/dc=example,dc=com" /&gt;
  &lt;/beans:bean&gt; 
  </code></pre>
  
  <p>I had some misunderstanding here. 
  When I tried to wrote this sample, quite a few samples I got from google put manager name and password in the spring security xml.
  So I once thought that this was like connecting to database via JDBC and we had to provide the database user name and password. This is not true, the manager name and password are not required.</p>