Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Thanks to discussion with Raffaele and following my own investigation of the code, it seems that Play 2.0 does not allow you to encrypt DB passwords. </p> <p>If I missed something please let me know.</p> <p><strong>EDIT</strong>: One can work around the problem by using custom database driver in the following manner:</p> <pre><code>// Just redirect everything to the delegate class DelegatingDriver(delegate: Driver) extends Driver { def connect(url: String, info: Properties) = delegate.connect(url, info) def acceptsURL(url: String) = delegate.acceptsURL(url) def getPropertyInfo(url: String, info: Properties) = delegate.getPropertyInfo(url, info) def getMajorVersion = delegate.getMajorVersion def getMinorVersion = delegate.getMinorVersion def jdbcCompliant() = delegate.jdbcCompliant() } // Replace password in properties with the decrypted one class MyDecryptingDriver extends DelegatingDriver(Class.forName("&lt;my.original.Driver&gt;").newInstance().asInstanceOf[Driver]) { override def connect(url: String, info: Properties)= { // copy Properties val overriddenProperties= clone(info) // override password property with the decrypted value Option(info.getProperty("password")).foreach(value =&gt; overriddenProperties.setProperty("password", decryptPassword(value))) super.connect(url, overriddenProperties) } def clone(orig: Properties)= { val result= new Properties() orig.propertyNames().map(_.asInstanceOf[String]).foreach(pName =&gt; result.setProperty(pName, orig.getProperty(pName))) result } def decryptPassword(encrypted: String)= ... } </code></pre> <p>then you replace application.conf/db..driver by my.com.MyDecrypting driver. Not perfect but works for me...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload