title: Hibernate authentication without passwords stored in plain text
body: <p>My goal is to authenticate to the database using a JDBC/Hibernate in a secure manner, without storing passwords in plain text. Code examples appreciated. I'm already using waffle to authenticate the user so if there was some way to use the credentials that waffle obtained from the user, and forward those to the DB, that would be good.</p>
  
  <p>Two questions:</p>
  
  <ol>
  <li>What is the recommended way to do multi hop authentication (the client, web server, and database are all different machines) with tomcat/hibernate/spring on web server, a sql database, and obviously client browser? </li>
  <li>I would also settle for a way to use a single user account to do authentication, as long as that user account's information was not stored in plain text anywhere. The user account will need both read/write privileges on the DB.</li>
  </ol>
  
  <p>I found some useful information about connecting to SQL Server <a href="https://stackoverflow.com/questions/167464/can-i-connect-to-sql-server-using-windows-authentication-from-java-ee-webapp">in this thread</a>. However, I'm expecting that Tomcat will be running under the default account which is like, Local System or something. As far as I know, that account cannot be used to do windows authentication to the database.</p>
  
  <p><strong>My solution</strong>:</p>
  
  <p>I did end up using the approach mentioned in the above thread. Instead of running the Tomcat service as Local System it is now running as a user. That user has permission to access the database. My hibernate configuration file is configured as follows:</p>
  
  <pre><code>    &lt;property name="hibernate.connection.url"&gt;
  jdbc:sqlserver://system:port;databaseName=myDb;integratedSecurity=true;
  &lt;/property&gt;
  </code></pre>
  
  <p><strong>To those who provided responses</strong></p>
  
  <p>I appreciate everyone's help and I will try out some of the techniques mentioned in the thread. My issue with some of the responses is that they require symmetric encryption which requires a secret key. Keeping the key secret is almost the exact same problem as storing the password in plain text. </p>