dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41698
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21263: InitTableAlteror encryption fix
------------------------------------------------------------
revno: 21263
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-12-02 13:30:23 +0100
message:
InitTableAlteror encryption fix
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java 2015-12-01 17:19:15 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java 2015-12-02 12:30:23 +0000
@@ -29,6 +29,7 @@
*/
import org.amplecode.quick.StatementManager;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.jdbc.StatementBuilder;
@@ -54,10 +55,10 @@
private StatementBuilder statementBuilder;
@Resource( name = "stringEncryptor" )
- PBEStringEncryptor oldPBEStringEncryptor;
+ private PBEStringEncryptor oldPBEStringEncryptor;
@Resource( name = "strongStringEncryptor" )
- PBEStringEncryptor newPBEStringEncryptor;
+ private PBEStringEncryptor newPBEStringEncryptor;
// -------------------------------------------------------------------------
// Execute
@@ -104,15 +105,20 @@
{
try
{
- String smtpPassword = oldPBEStringEncryptor.decrypt( statementManager.getHolder().
- queryForString( "SELECT smptpassword FROM configuration" ) );
- String remoteServerPassword = oldPBEStringEncryptor.decrypt( statementManager.getHolder()
- .queryForString( "SELECT remoteserverpassword FROM configuration" ) );
+ String smtpPassword = statementManager.getHolder().queryForString( "SELECT smptpassword FROM configuration" );
+ String remoteServerPassword = statementManager.getHolder().queryForString( "SELECT remoteserverpassword FROM configuration" );
- executeSql( "UPDATE configuration SET smtppassword = '" + newPBEStringEncryptor.encrypt( smtpPassword ) + "'" );
- executeSql( "UPDATE configuration SET remotepassword = '" + newPBEStringEncryptor.encrypt( remoteServerPassword ) + "'" );
- executeSql( "ALTER TABLE configuration DROP COLUMN smptpassword" );
- executeSql( "ALTER TABLE configuration DROP COLUMN remoteserverpassword" );
+ if ( StringUtils.isNotBlank( smtpPassword ) )
+ {
+ executeSql( "UPDATE configuration SET smtppassword = '" + newPBEStringEncryptor.encrypt( oldPBEStringEncryptor.decrypt( smtpPassword ) ) + "'" );
+ executeSql( "ALTER TABLE configuration DROP COLUMN smptpassword" );
+ }
+
+ if ( StringUtils.isNotBlank( remoteServerPassword ) )
+ {
+ executeSql( "UPDATE configuration SET remotepassword = '" + newPBEStringEncryptor.encrypt( oldPBEStringEncryptor.decrypt( remoteServerPassword ) ) + "'" );
+ executeSql( "ALTER TABLE configuration DROP COLUMN remoteserverpassword" );
+ }
}
catch ( Exception ex )
{