Add default user wssubcontracting/wssubcontracting

FEA: ItEr76S30PermissionsEnhancements
This commit is contained in:
Manuel Rego Casasnovas 2012-06-11 17:08:31 +02:00
parent 1a19400990
commit 8a10614cc0
9 changed files with 75 additions and 7 deletions

View file

@ -79,6 +79,8 @@ public class Configuration extends BaseEntity {
private Boolean changedDefaultWswriterPassword = false;
private Boolean changedDefaultWssubcontractingPassword = false;
private Boolean autocompleteLogin = true;
private ProgressType progressType = ProgressType.SPREAD_PROGRESS;
@ -350,6 +352,16 @@ public class Configuration extends BaseEntity {
: false;
}
public void setChangedDefaultWssubcontractingPassword(
Boolean changedDefaultWssubcontractingPassword) {
this.changedDefaultWssubcontractingPassword = changedDefaultWssubcontractingPassword;
}
public Boolean getChangedDefaultWssubcontractingPassword() {
return changedDefaultWssubcontractingPassword != null ? changedDefaultWssubcontractingPassword
: false;
}
public LDAPConfiguration getLdapConfiguration() {
return ldapConfiguration;
}

View file

@ -3,7 +3,7 @@
*
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
* Copyright (C) 2010-2011 Igalia, S.L.
* Copyright (C) 2010-2012 Igalia, S.L.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -27,12 +27,14 @@ import static org.libreplan.business.i18n.I18nHelper._;
* Available user roles.
*
* @author Fernando Bellas Permuy <fbellas@udc.es>
* @author Manuel Rego Casasnovas <rego@igalia.com>
*/
public enum UserRole {
ROLE_ADMINISTRATION(_("Administration")),
ROLE_WS_READER(_("Web service reader")),
ROLE_WS_WRITER(_("Web service writer")),
ROLE_WS_SUBCONTRACTING(_("Web service subcontracting")),
ROLE_READ_ALL_ORDERS(_("All projects read allowed")),
ROLE_EDIT_ALL_ORDERS(_("All projects edition allowed")),
ROLE_CREATE_ORDER(_("Project creation allowed")),

View file

@ -500,4 +500,22 @@
defaultNullValue="FALSE" columnDataType="BOOLEAN" />
</changeSet>
</databaseChangeLog>
<changeSet id="add-new-column-changed_default_wssubcontracting_password" author="mrego">
<comment>
Add new column changed_default_wssubcontracting_password with
default value FALSE to configuration table
</comment>
<addColumn tableName="configuration">
<column name="changed_default_wssubcontracting_password"
type="BOOLEAN" />
</addColumn>
<addDefaultValue tableName="configuration"
columnName="changed_default_wssubcontracting_password"
defaultValueBoolean="FALSE" />
<addNotNullConstraint tableName="configuration"
columnName="changed_default_wssubcontracting_password"
defaultNullValue="FALSE"
columnDataType="BOOLEAN" />
</changeSet>
</databaseChangeLog>

View file

@ -51,6 +51,8 @@
column="changed_default_wsreader_password" />
<property name="changedDefaultWswriterPassword" not-null="true"
column="changed_default_wswriter_password" />
<property name="changedDefaultWssubcontractingPassword" not-null="true"
column="changed_default_wssubcontracting_password" />
<property name="autocompleteLogin" not-null="true"
column="enabled_autocomplete_login" />
<property name="checkNewVersionEnabled" not-null="true"

View file

@ -147,6 +147,10 @@ public class TemplateController extends GenericForwardComposer {
return notChangedPasswordWarningDisplayPropertyFor(MandatoryUser.WSWRITER);
}
public String getDefaultPasswdWssubcontractingVisible() {
return notChangedPasswordWarningDisplayPropertyFor(MandatoryUser.WSSUBCONTRACTING);
}
private String notChangedPasswordWarningDisplayPropertyFor(
MandatoryUser mandatoryUser) {
return asDisplayProperty(templateModel
@ -179,6 +183,11 @@ public class TemplateController extends GenericForwardComposer {
return templateModel.getIdUser(MandatoryUser.WSWRITER.getLoginName());
}
public String getIdWssubcontractingUser() {
return templateModel.getIdUser(MandatoryUser.WSSUBCONTRACTING
.getLoginName());
}
public boolean isUserAdmin() {
return templateModel.isUserAdmin();
}

View file

@ -54,6 +54,12 @@ public class PasswordUtil {
checkIfChangeDefaultPasswd(MandatoryUser.WSWRITER, clearPassword);
return;
}
if (user.getLoginName().equalsIgnoreCase(
MandatoryUser.WSSUBCONTRACTING.getLoginName())) {
checkIfChangeDefaultPasswd(MandatoryUser.WSSUBCONTRACTING,
clearPassword);
return;
}
}
private static void checkIfChangeDefaultPasswd(MandatoryUser user,
@ -84,11 +90,15 @@ public class PasswordUtil {
.hasChangedDefaultPasswordOrDisabled();
boolean wswriterNotDefaultPassword = MandatoryUser.WSWRITER
.hasChangedDefaultPasswordOrDisabled();
boolean wssubcontractingNotDefaultPassword = MandatoryUser.WSSUBCONTRACTING
.hasChangedDefaultPasswordOrDisabled();
Clients.evalJavaScript("showOrHideDefaultPasswordWarnings("
+ adminNotDefaultPassword + ", " + userNotDefaultPassword
+ ", " + wsreaderNotDefaultPassword + ", "
+ wswriterNotDefaultPassword + ");");
+ adminNotDefaultPassword + ", "
+ userNotDefaultPassword + ", "
+ wsreaderNotDefaultPassword + ", "
+ wswriterNotDefaultPassword + ", "
+ wssubcontractingNotDefaultPassword + ");");
}
}

View file

@ -75,6 +75,14 @@ public enum MandatoryUser {
public boolean hasChangedDefaultPassword() {
return getConfiguration().getChangedDefaultWswriterPassword();
}
},
WSSUBCONTRACTING(Arrays.asList(UserRole.ROLE_WS_SUBCONTRACTING),
Configuration.isExampleUsersDisabled()) {
@Override
public boolean hasChangedDefaultPassword() {
return getConfiguration()
.getChangedDefaultWssubcontractingPassword();
}
};
public static boolean adminChangedAndSomeOtherNotChanged() {

View file

@ -39,6 +39,7 @@ signature="java.lang.Boolean isDefaultPasswordsControl()"?>
idUser = templateController.getIdUser();
idWsreader = templateController.getIdWsreaderUser();
idWswriter = templateController.getIdWswriterUser();
idWssubcontracting = templateController.getIdWssubcontractingUser();
]]>
</zscript>
@ -151,6 +152,9 @@ signature="java.lang.Boolean isDefaultPasswordsControl()"?>
<n:a href="${contextPath}/users/users.zul#edit%3D${idWswriter}"
id="warningDefaultPasswdwswriter"
style="display:${templateCtrl.defaultPasswdWswriterVisible}">[wswriter]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idWssubcontracting}"
id="warningDefaultPasswdwssubcontracting"
style="display:${templateCtrl.defaultPasswdWssubcontractingVisible}">[wssubcontracting]</n:a>
<n:span class="footer-messages-area">
${i18n:_('default password were not changed')}.
</n:span>

View file

@ -19,13 +19,14 @@
function showOrHideDefaultPasswordWarnings(adminNotDefaultPassword,
userNotDefaultPassword, wsreaderNotDefaultPassword,
wswriterNotDefaultPassword) {
wswriterNotDefaultPassword, wssubcontractingNotDefaultPassword) {
setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdadmin"),
adminNotDefaultPassword);
var otherDefaultPassword = adminNotDefaultPassword &&
(!userNotDefaultPassword || !wsreaderNotDefaultPassword || !wswriterNotDefaultPassword);
(!userNotDefaultPassword || !wsreaderNotDefaultPassword ||
!wswriterNotDefaultPassword || !wssubcontractingNotDefaultPassword);
setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdOthers"),
!otherDefaultPassword);
@ -36,6 +37,8 @@ function showOrHideDefaultPasswordWarnings(adminNotDefaultPassword,
wsreaderNotDefaultPassword);
setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdwswriter"),
wswriterNotDefaultPassword);
setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdwssubcontracting"),
wssubcontractingNotDefaultPassword);
}
}