dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31412
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15989: Integrated jasypt for encryption/decryption purposes. Added encryptedString hibernate user type. ...
------------------------------------------------------------
revno: 15989
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-07-07 08:44:19 +0200
message:
Integrated jasypt for encryption/decryption purposes. Added encryptedString hibernate user type. Using fixed salt for now to allow for hibernate queries for encrypted strings.
added:
dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/org/
dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/org/hisp/
dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/org/hisp/dhis/
dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/org/hisp/dhis/usertype/
dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/org/hisp/dhis/usertype/UserTypes.hbm.xml
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDomainUserType.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml
dhis-2/dhis-support/dhis-support-hibernate/pom.xml
dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/hibernate-default.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java
dhis-2/pom.xml
--
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-api/src/main/java/org/hisp/dhis/configuration/Configuration.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java 2014-07-07 06:44:19 +0000
@@ -52,7 +52,11 @@
private static final PeriodType DEFAULT_INFRASTRUCTURAL_PERIODTYPE = new YearlyPeriodType();
private int id;
-
+
+ // -------------------------------------------------------------------------
+ // Various
+ // -------------------------------------------------------------------------
+
private String systemId;
private UserGroup feedbackRecipients;
@@ -66,7 +70,21 @@
private UserAuthorityGroup selfRegistrationRole;
private OrganisationUnit selfRegistrationOrgUnit;
-
+
+ // -------------------------------------------------------------------------
+ // Remote synch
+ // -------------------------------------------------------------------------
+
+ private String remoteServerUrl;
+
+ private String remoteServerUsername;
+
+ private String remoteServerPassword;
+
+ // -------------------------------------------------------------------------
+ // Constructor
+ // -------------------------------------------------------------------------
+
public Configuration()
{
}
@@ -168,4 +186,37 @@
{
this.selfRegistrationOrgUnit = selfRegistrationOrgUnit;
}
+
+ public String getRemoteServerUrl()
+ {
+ return remoteServerUrl;
+ }
+
+ public void setRemoteServerUrl( String remoteServerUrl )
+ {
+ this.remoteServerUrl = remoteServerUrl;
+ }
+
+ public String getRemoteServerUsername()
+ {
+ return remoteServerUsername;
+ }
+
+ public void setRemoteServerUsername( String remoteServerUsername )
+ {
+ this.remoteServerUsername = remoteServerUsername;
+ }
+
+ /**
+ * Do not serialize.
+ */
+ public String getRemoteServerPassword()
+ {
+ return remoteServerPassword;
+ }
+
+ public void setRemoteServerPassword( String remoteServerPassword )
+ {
+ this.remoteServerPassword = remoteServerPassword;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDomainUserType.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDomainUserType.java 2014-06-15 13:20:39 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDomainUserType.java 2014-07-07 06:44:19 +0000
@@ -1,3 +1,5 @@
+package org.hisp.dhis.dataelement;
+
/*
* Copyright (c) 2004-2013, University of Oslo
* All rights reserved.
@@ -25,20 +27,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-package org.hisp.dhis.dataelement;
-
import org.hisp.dhis.hibernate.EnumUserType;
/**
* @author Chau Thu Tran
- *
- * @version $ DataElementDomainUserType.java Jun 15, 2014 2:18:38 PM $
*/
public class DataElementDomainUserType
extends EnumUserType<DataElementDomain>
{
- public DataElementDomainUserType()
+ public DataElementDomainUserType()
{
- super( DataElementDomain.class );
+ super( DataElementDomain.class );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml 2013-09-04 13:52:48 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml 2014-07-07 06:44:19 +0000
@@ -32,5 +32,11 @@
<many-to-one name="selfRegistrationOrgUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit"
column="selfRegistrationOrgUnit" foreign-key="fk_configuration_selfregistrationorgunit" />
+ <property name="remoteServerUrl" column="remoteserverurl" />
+
+ <property name="remoteServerUsername" column="remoteserverusername" />
+
+ <property name="remoteServerPassword" column="remoteServerPassword" type="encryptedString" />
+
</class>
</hibernate-mapping>
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/pom.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/pom.xml 2014-05-11 12:02:11 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/pom.xml 2014-07-07 06:44:19 +0000
@@ -56,7 +56,22 @@
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</dependency>
+
+ <!-- Jasypt -->
+ <dependency>
+ <groupId>org.jasypt</groupId>
+ <artifactId>jasypt</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jasypt</groupId>
+ <artifactId>jasypt-hibernate4</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jasypt</groupId>
+ <artifactId>jasypt-spring31</artifactId>
+ </dependency>
+
<!-- Database connectors -->
<dependency>
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml 2014-01-28 04:23:09 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml 2014-07-07 06:44:19 +0000
@@ -90,4 +90,28 @@
<property name="defaultValue" value="40" />
</bean>
+ <bean id="encryptionKey" class="org.hisp.dhis.hibernate.ConnectionPropertyFactoryBean">
+ <property name="hibernateConfigurationProvider" ref="hibernateConfigurationProvider" />
+ <property name="hibernateProperty" value="encryption.key" />
+ <property name="defaultValue" value="J7GhAs287hsSQlKd9g5" />
+ </bean>
+
+ <!-- Encryption -->
+
+ <bean id="hibernateStringEncryptor" class="org.jasypt.hibernate4.encryptor.HibernatePBEStringEncryptor">
+ <property name="registeredName" value="strongHibernateStringEncryptor" />
+ <property name="encryptor" ref="stringEncryptor" />
+ </bean>
+
+ <bean id="stringEncryptor" class="org.jasypt.encryption.pbe.PooledPBEStringEncryptor">
+ <property name="algorithm" value="PBEWithSHA1AndDESede" />
+ <property name="password" ref="encryptionKey" />
+ <property name="saltGenerator" ref="fixedSaltGenerator" />
+ <property name="poolSize" value="4" />
+ </bean>
+
+ <bean id="fixedSaltGenerator" class="org.jasypt.salt.StringFixedSaltGenerator">
+ <constructor-arg><value>H7g0oLkEw3wf52fs52g3hbG</value></constructor-arg>
+ </bean>
+
</beans>
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/hibernate-default.properties'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/hibernate-default.properties 2014-05-11 11:32:18 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/hibernate-default.properties 2014-07-07 06:44:19 +0000
@@ -14,7 +14,7 @@
hibernate.connection.driver_class = org.h2.Driver
hibernate.connection.url = jdbc:h2:mem:dhis2;DB_CLOSE_DELAY=-1;MVCC=TRUE;ALIAS_COLUMN_NAME=TRUE;DB_CLOSE_ON_EXIT=FALSE
hibernate.connection.username = sa
-hibernate.connection.password =
+hibernate.connection.password = sa
hibernate.hbm2ddl.auto = create-drop
# See c3p0-config.xml
=== added directory 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/org'
=== added directory 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/org/hisp'
=== added directory 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/org/hisp/dhis'
=== added directory 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/org/hisp/dhis/usertype'
=== added file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/org/hisp/dhis/usertype/UserTypes.hbm.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/org/hisp/dhis/usertype/UserTypes.hbm.xml 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/org/hisp/dhis/usertype/UserTypes.hbm.xml 2014-07-07 06:44:19 +0000
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping>
+ <typedef name="encryptedString" class="org.jasypt.hibernate4.type.EncryptedStringType">
+ <param name="encryptorRegisteredName">strongHibernateStringEncryptor</param>
+ </typedef>
+</hibernate-mapping>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java 2014-05-13 11:15:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java 2014-07-07 06:44:19 +0000
@@ -173,8 +173,6 @@
if ( offlineOrganisationUnitLevel == null )
{
- // default to highest level
- // TODO what if the org unit level hierarchy hasn't been created yet?
int size = organisationUnitService.getOrganisationUnitLevels().size();
offlineOrganisationUnitLevel = organisationUnitService.getOrganisationUnitLevelByLevel( size );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java 2014-05-04 13:16:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java 2014-07-07 06:44:19 +0000
@@ -245,7 +245,8 @@
configuration.setInfrastructuralPeriodType( periodService.getPeriodTypeByClass( PeriodType
.getPeriodTypeByName( infrastructuralPeriodType ).getClass() ) );
}
-
+
+ configuration.setRemoteServerPassword( "abc" );
configurationService.setConfiguration( configuration );
message = i18n.getString( "settings_updated" );
=== modified file 'dhis-2/pom.xml'
--- dhis-2/pom.xml 2014-07-06 17:12:17 +0000
+++ dhis-2/pom.xml 2014-07-07 06:44:19 +0000
@@ -484,13 +484,28 @@
<artifactId>spring-security-openid</artifactId>
<version>${spring.security.version}</version>
</dependency>
-
<!-- Spring Mobile -->
<dependency>
<groupId>org.springframework.mobile</groupId>
<artifactId>spring-mobile-device</artifactId>
<version>1.0.2.RELEASE</version>
</dependency>
+ <!-- Jasypt -->
+ <dependency>
+ <groupId>org.jasypt</groupId>
+ <artifactId>jasypt</artifactId>
+ <version>1.9.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jasypt</groupId>
+ <artifactId>jasypt-hibernate4</artifactId>
+ <version>1.9.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jasypt</groupId>
+ <artifactId>jasypt-spring31</artifactId>
+ <version>1.9.2</version>
+ </dependency>
<!-- Other -->
<!-- Javassist from hibernate-core -->