diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/entities/Configuration.java b/libreplan-business/src/main/java/org/libreplan/business/common/entities/Configuration.java index c46b7cc90..0b3a9264f 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/common/entities/Configuration.java +++ b/libreplan-business/src/main/java/org/libreplan/business/common/entities/Configuration.java @@ -79,6 +79,14 @@ public class Configuration extends BaseEntity { private Boolean changedDefaultWssubcontractingPassword = false; + private Boolean changedDefaultManagerPassword = false; + + private Boolean changedDefaultHresourcesPassword = false; + + private Boolean changedDefaultOutsourcingPassword = false; + + private Boolean changedDefaultReportsPassword = false; + private Boolean autocompleteLogin = true; private ProgressType progressType = ProgressType.SPREAD_PROGRESS; @@ -351,6 +359,46 @@ public class Configuration extends BaseEntity { : false; } + public void setChangedDefaultManagerPassword( + Boolean changedDefaultManagerPassword) { + this.changedDefaultManagerPassword = changedDefaultManagerPassword; + } + + public Boolean getChangedDefaultManagerPassword() { + return changedDefaultManagerPassword != null ? changedDefaultManagerPassword + : false; + } + + public void setChangedDefaultHresourcesPassword( + Boolean changedDefaultHresourcesPassword) { + this.changedDefaultHresourcesPassword = changedDefaultHresourcesPassword; + } + + public Boolean getChangedDefaultHresourcesPassword() { + return changedDefaultHresourcesPassword != null ? changedDefaultHresourcesPassword + : false; + } + + public void setChangedDefaultOutsourcingPassword( + Boolean changedDefaultOutsourcingPassword) { + this.changedDefaultOutsourcingPassword = changedDefaultOutsourcingPassword; + } + + public Boolean getChangedDefaultOutsourcingPassword() { + return changedDefaultOutsourcingPassword != null ? changedDefaultOutsourcingPassword + : false; + } + + public void setChangedDefaultReportsPassword( + Boolean changedDefaultReportsPassword) { + this.changedDefaultReportsPassword = changedDefaultReportsPassword; + } + + public Boolean getChangedDefaultReportsPassword() { + return changedDefaultReportsPassword != null ? changedDefaultReportsPassword + : false; + } + public LDAPConfiguration getLdapConfiguration() { return ldapConfiguration; } diff --git a/libreplan-business/src/main/java/org/libreplan/business/users/bootstrap/PredefinedProfiles.java b/libreplan-business/src/main/java/org/libreplan/business/users/bootstrap/PredefinedProfiles.java index e537ed5b4..9e948186b 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/users/bootstrap/PredefinedProfiles.java +++ b/libreplan-business/src/main/java/org/libreplan/business/users/bootstrap/PredefinedProfiles.java @@ -60,6 +60,8 @@ import static org.libreplan.business.users.entities.UserRole.ROLE_WORK_REPORT_LI import java.util.Arrays; import java.util.HashSet; +import org.libreplan.business.common.Registry; +import org.libreplan.business.common.exceptions.InstanceNotFoundException; import org.libreplan.business.users.entities.Profile; import org.libreplan.business.users.entities.UserRole; @@ -126,4 +128,12 @@ public enum PredefinedProfiles { .create(name, new HashSet(Arrays.asList(roles))); } + public Profile getFromDB() { + try { + return Registry.getProfileDAO().findByProfileName(name); + } catch (InstanceNotFoundException e) { + return null; + } + } + } diff --git a/libreplan-business/src/main/java/org/libreplan/business/users/entities/User.java b/libreplan-business/src/main/java/org/libreplan/business/users/entities/User.java index 36a5efde7..075a0ab9f 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/users/entities/User.java +++ b/libreplan-business/src/main/java/org/libreplan/business/users/entities/User.java @@ -83,10 +83,12 @@ public class User extends BaseEntity implements IHumanIdentifiable{ public User() { } - private User(String loginName, String password, Set roles) { + private User(String loginName, String password, Set roles, + Set profiles) { this.loginName = loginName; this.password = password; this.roles = roles; + this.profiles = profiles; } private User(String loginName, String password, String email) { @@ -97,9 +99,12 @@ public class User extends BaseEntity implements IHumanIdentifiable{ public static User create(String loginName, String password, Set roles) { + return create(loginName, password, roles, new HashSet()); + } - return create(new User(loginName, password, roles)); - + public static User create(String loginName, String password, + Set roles, Set profiles) { + return create(new User(loginName, password, roles, profiles)); } public static User create() { diff --git a/libreplan-business/src/main/resources/db.changelog-1.2.xml b/libreplan-business/src/main/resources/db.changelog-1.2.xml index 2abb8a759..dcce1c4d8 100644 --- a/libreplan-business/src/main/resources/db.changelog-1.2.xml +++ b/libreplan-business/src/main/resources/db.changelog-1.2.xml @@ -578,4 +578,76 @@ columnName="changed_default_user_password" /> + + + Add new column changed_default_manager_password with + default value FALSE to configuration table + + + + + + + + + + + Add new column changed_default_hresources_password with + default value FALSE to configuration table + + + + + + + + + + + Add new column changed_default_outsourcing_password with + default value FALSE to configuration table + + + + + + + + + + + Add new column changed_default_reports_password with + default value FALSE to configuration table + + + + + + + + diff --git a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Configuration.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Configuration.hbm.xml index 4a97740ae..7da305270 100644 --- a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Configuration.hbm.xml +++ b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Configuration.hbm.xml @@ -51,6 +51,14 @@ column="changed_default_wswriter_password" /> + + + + initialRoles; + private Set initialRoles = new HashSet(); + + private Set initialProfiles = new HashSet(); private final boolean userDisabled; private MandatoryUser(Collection initialUserRoles, boolean userDisabled) { - this.initialRoles = new HashSet(initialUserRoles); + this(initialUserRoles, null, userDisabled); + } + + private MandatoryUser(Collection initialUserRoles, + Collection initialProfiles, boolean userDisabled) { + if (initialUserRoles != null) { + this.initialRoles = new HashSet(initialUserRoles); + } + if (initialProfiles != null) { + this.initialProfiles = new HashSet(initialProfiles); + } this.userDisabled = userDisabled; } @@ -130,6 +175,10 @@ public enum MandatoryUser { return initialRoles; } + public Set getInitialProfiles() { + return initialProfiles; + } + public static EnumSet allExcept(MandatoryUser mandatoryUser) { return EnumSet.complementOf(EnumSet.of(mandatoryUser)); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/bootstrap/UsersBootstrapInDB.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/bootstrap/UsersBootstrapInDB.java index e7c518384..cdbfce05d 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/bootstrap/UsersBootstrapInDB.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/bootstrap/UsersBootstrapInDB.java @@ -61,7 +61,7 @@ public class UsersBootstrapInDB implements IUsersBootstrapInDB { if (!userDAO.existsByLoginName(u.getLoginName())) { User user = User.create(u.getLoginName(), getEncodedPassword(u), - u.getInitialRoles()); + u.getInitialRoles(), u.getInitialProfiles()); user.setDisabled(u.isUserDisabled()); userDAO.save(user); diff --git a/libreplan-webapp/src/main/webapp/common/layout/template.zul b/libreplan-webapp/src/main/webapp/common/layout/template.zul index 848406ee4..768426d4a 100644 --- a/libreplan-webapp/src/main/webapp/common/layout/template.zul +++ b/libreplan-webapp/src/main/webapp/common/layout/template.zul @@ -39,6 +39,10 @@ signature="java.lang.Boolean isDefaultPasswordsControl()"?> idWsreader = templateController.getIdWsreaderUser(); idWswriter = templateController.getIdWswriterUser(); idWssubcontracting = templateController.getIdWssubcontractingUser(); + idManager = templateController.getIdManagerUser(); + idHresources = templateController.getIdHresourcesUser(); + idOutsourcing = templateController.getIdOutsourcingUser(); + idReports = templateController.getIdReportsUser(); ]]> @@ -143,14 +147,26 @@ signature="java.lang.Boolean isDefaultPasswordsControl()"?> style="display:${templateCtrl.defaultPasswdVisible}">
[wsreader] [wswriter] [wssubcontracting] + [manager] + [hresources] + [outsourcing] + [reports] ${i18n:_('default password were not changed')}. diff --git a/libreplan-webapp/src/main/webapp/js/defaultPasswordWarnings.js b/libreplan-webapp/src/main/webapp/js/defaultPasswordWarnings.js index 8d4d1866a..ca966c460 100644 --- a/libreplan-webapp/src/main/webapp/js/defaultPasswordWarnings.js +++ b/libreplan-webapp/src/main/webapp/js/defaultPasswordWarnings.js @@ -21,24 +21,41 @@ function showOrHideDefaultPasswordWarnings( adminNotDefaultPassword, wsreaderNotDefaultPassword, wswriterNotDefaultPassword, - wssubcontractingNotDefaultPassword) { + wssubcontractingNotDefaultPassword, + managerNotDefaultPassword, + hresourcesNotDefaultPassword, + outsourcingNotDefaultPassword, + reportsNotDefaultPassword) { setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdadmin"), adminNotDefaultPassword); - var otherDefaultPassword = adminNotDefaultPassword && - (!wsreaderNotDefaultPassword || - !wswriterNotDefaultPassword || !wssubcontractingNotDefaultPassword); + var otherDefaultPassword = adminNotDefaultPassword && ( + !wsreaderNotDefaultPassword || + !wswriterNotDefaultPassword || + !wssubcontractingNotDefaultPassword || + !managerNotDefaultPassword || + !hresourcesNotDefaultPassword || + !outsourcingNotDefaultPassword || + !reportsNotDefaultPassword); setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdOthers"), !otherDefaultPassword); if (otherDefaultPassword) { - setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdwsreader"), + setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdWsreader"), wsreaderNotDefaultPassword); - setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdwswriter"), + setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdWswriter"), wswriterNotDefaultPassword); - setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdwssubcontracting"), + setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdWssubcontracting"), wssubcontractingNotDefaultPassword); + setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdManager"), + managerNotDefaultPassword); + setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdHresources"), + hresourcesNotDefaultPassword); + setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdOutsourcing"), + outsourcingNotDefaultPassword); + setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdReports"), + reportsNotDefaultPassword); } }