Hello all,
as a follow up to the post
To encrypt the DB password in portal-ext properties file of the server, the Liferay source code that must be modified in order to rebuild portal-impl.jar and achieve this goal, has been relocated in the following class:
com.liferay.portal.dao.jdbc.DataSourceFactoryImplhere's the code fragment:
1
2public class DataSourceFactoryImpl implements DataSourceFactory {
3
4 //...
5
6 public DataSource initDataSource(Properties properties) throws Exception {
7 Properties defaultProperties = PropsUtil.getProperties(
8 "jdbc.default.", true);
9
10 /**
11 * Overriding code: begin
12 */
13
14 Enumeration<String> propEnum = (Enumeration<String>)defaultProperties.propertyNames();
15
16 while(propEnum.hasMoreElements())
17 {
18 String key = propEnum.nextElement();
19
20 if(key.equalsIgnoreCase("password"))
21 {
22 /*Property jdbc.default.encrypted.password enables one to define whether the provided password is encrypted or not*/
23 boolean isEncrypted = GetterUtil.getBoolean(defaultProperties.getProperty("encrypted.password"));
24
25 if(isEncrypted)
26 {
27 String value = defaultProperties.getProperty(key);
28 Base64 base64 = new Base64();
29 byte[] bytesArray = base64.decode(value.getBytes());
30 value = new String(bytesArray);
31 /*Set the password property in the property member field since it is the one to be taken into account*/
32 properties.setProperty(key, value);
33 }
34 }
35 }
36
37 /**
38 * Overriding code: end
39 */
40//rest of code...
Hope this helps...
P.S. Just as in the referenced post, no code is deleted (only added) and this is a simple password encoding from chars to base64
Please sign in to flag this as inappropriate.