Remove default user with login user and password user

FEA: ItEr76S30PermissionsEnhancements
This commit is contained in:
Manuel Rego Casasnovas 2012-06-20 12:47:49 +02:00
parent 7907c12a91
commit c3b5232d16
9 changed files with 22 additions and 51 deletions

View file

@ -73,8 +73,6 @@ public class Configuration extends BaseEntity {
private Boolean changedDefaultAdminPassword = false;
private Boolean changedDefaultUserPassword = false;
private Boolean changedDefaultWsreaderPassword = false;
private Boolean changedDefaultWswriterPassword = false;
@ -323,15 +321,6 @@ public class Configuration extends BaseEntity {
: changedDefaultAdminPassword;
}
public void setChangedDefaultUserPassword(Boolean changedDefaultUserPassword) {
this.changedDefaultUserPassword = changedDefaultUserPassword;
}
public Boolean getChangedDefaultUserPassword() {
return changedDefaultUserPassword != null ? changedDefaultUserPassword
: false;
}
public void setChangedDefaultWsreaderPassword(
Boolean changedDefaultWsreaderPassword) {
this.changedDefaultWsreaderPassword = changedDefaultWsreaderPassword;

View file

@ -571,4 +571,11 @@
</update>
</changeSet>
<changeSet id="drop-column-changed_default_user_password-in-configuration"
author="mrego">
<comment>Drop column code in configuration table</comment>
<dropColumn tableName="configuration"
columnName="changed_default_user_password" />
</changeSet>
</databaseChangeLog>

View file

@ -45,8 +45,6 @@
column="monte_carlo_method_tab_visible" />
<property name="changedDefaultAdminPassword" not-null="true"
column="changed_default_admin_password" />
<property name="changedDefaultUserPassword" not-null="true"
column="changed_default_user_password" />
<property name="changedDefaultWsreaderPassword" not-null="true"
column="changed_default_wsreader_password" />
<property name="changedDefaultWswriterPassword" not-null="true"

View file

@ -135,10 +135,6 @@ public class TemplateController extends GenericForwardComposer {
return notChangedPasswordWarningDisplayPropertyFor(MandatoryUser.ADMIN);
}
public String getDefaultPasswdUserVisible() {
return notChangedPasswordWarningDisplayPropertyFor(MandatoryUser.USER);
}
public String getDefaultPasswdWsreaderVisible() {
return notChangedPasswordWarningDisplayPropertyFor(MandatoryUser.WSREADER);
}
@ -171,10 +167,6 @@ public class TemplateController extends GenericForwardComposer {
return templateModel.getIdUser(MandatoryUser.ADMIN.getLoginName());
}
public String getIdUser() {
return templateModel.getIdUser(MandatoryUser.USER.getLoginName());
}
public String getIdWsreaderUser() {
return templateModel.getIdUser(MandatoryUser.WSREADER.getLoginName());
}
@ -201,4 +193,8 @@ public class TemplateController extends GenericForwardComposer {
.isAllowToGatherUsageStatsEnabled());
}
public String getUsername() {
return SecurityUtils.getLoggedUser().getUsername();
}
}

View file

@ -30,7 +30,6 @@ import org.libreplan.business.common.Registry;
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
import org.libreplan.business.users.entities.OrderAuthorization;
import org.libreplan.business.users.entities.UserRole;
import org.libreplan.web.users.bootstrap.MandatoryUser;
import org.libreplan.web.users.services.CustomUser;
import org.springframework.security.Authentication;
import org.springframework.security.context.SecurityContextHolder;
@ -76,7 +75,7 @@ public final class SecurityUtils {
.getCurrent().getNativeRequest();
Principal principal = request.getUserPrincipal();
if (principal == null) {
return MandatoryUser.USER.getLoginName();
return null;
}
return principal.getName();
}
@ -119,12 +118,13 @@ public final class SecurityUtils {
@Override
public Boolean execute() {
try {
String username = getLoggedUser().getUsername();
return Registry
.getOrderAuthorizationDAO()
.userOrItsProfilesHaveAnyAuthorization(
Registry.getUserDAO()
.findByLoginName(
getSessionUserLoginName()));
username));
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}

View file

@ -39,11 +39,6 @@ public class PasswordUtil {
checkIfChangeDefaultPasswd(MandatoryUser.ADMIN, clearPassword);
return;
}
if (user.getLoginName().equalsIgnoreCase(
MandatoryUser.USER.getLoginName())) {
checkIfChangeDefaultPasswd(MandatoryUser.USER, clearPassword);
return;
}
if (user.getLoginName().equalsIgnoreCase(
MandatoryUser.WSREADER.getLoginName())) {
checkIfChangeDefaultPasswd(MandatoryUser.WSREADER, clearPassword);
@ -84,8 +79,6 @@ public class PasswordUtil {
public static void showOrHideDefaultPasswordWarnings() {
boolean adminNotDefaultPassword = MandatoryUser.ADMIN
.hasChangedDefaultPasswordOrDisabled();
boolean userNotDefaultPassword = MandatoryUser.USER
.hasChangedDefaultPasswordOrDisabled();
boolean wsreaderNotDefaultPassword = MandatoryUser.WSREADER
.hasChangedDefaultPasswordOrDisabled();
boolean wswriterNotDefaultPassword = MandatoryUser.WSWRITER
@ -95,7 +88,6 @@ public class PasswordUtil {
Clients.evalJavaScript("showOrHideDefaultPasswordWarnings("
+ adminNotDefaultPassword + ", "
+ userNotDefaultPassword + ", "
+ wsreaderNotDefaultPassword + ", "
+ wswriterNotDefaultPassword + ", "
+ wssubcontractingNotDefaultPassword + ");");

View file

@ -21,7 +21,6 @@
package org.libreplan.web.users.bootstrap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
@ -46,12 +45,6 @@ import org.libreplan.business.users.entities.UserRole;
*/
public enum MandatoryUser {
USER(new ArrayList<UserRole>(), Configuration.isExampleUsersDisabled()) {
@Override
public boolean hasChangedDefaultPassword() {
return getConfiguration().getChangedDefaultUserPassword();
}
},
ADMIN(Arrays.asList(UserRole.ROLE_SUPERUSER,
UserRole.ROLE_READ_ALL_PROJECTS,
UserRole.ROLE_EDIT_ALL_PROJECTS,

View file

@ -36,7 +36,6 @@ signature="java.lang.Boolean isDefaultPasswordsControl()"?>
contextPath = Executions.getCurrent().getContextPath();
templateCtrl = templateController;
idAdminUser = templateController.getIdAdminUser();
idUser = templateController.getIdUser();
idWsreader = templateController.getIdWsreaderUser();
idWswriter = templateController.getIdWswriterUser();
idWssubcontracting = templateController.getIdWssubcontractingUser();
@ -102,7 +101,7 @@ signature="java.lang.Boolean isDefaultPasswordsControl()"?>
</window>
</div>
</n:td>
<n:td class="usuario">${i18n:_('user')}: ${desktop.execution.userPrincipal.name}</n:td>
<n:td class="usuario">${i18n:_('user')}: ${templateController.username}</n:td>
<n:td><n:a href="${contextPath}/j_spring_security_logout" class="cerrar_sesion">[${i18n:_('Log out')}]</n:a></n:td>
</n:tr>
</n:table>
@ -143,9 +142,6 @@ signature="java.lang.Boolean isDefaultPasswordsControl()"?>
class="footer-messages-area"
style="display:${templateCtrl.defaultPasswdVisible}">
<div>
<n:a href="${contextPath}/users/users.zul#edit%3D${idUser}"
id="warningDefaultPasswduser"
style="display:${templateCtrl.defaultPasswdUserVisible}">[user]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idWsreader}"
id="warningDefaultPasswdwsreader"
style="display:${templateCtrl.defaultPasswdWsreaderVisible}">[wsreader]</n:a>

View file

@ -1,7 +1,7 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2011 Igalia, S.L.
* Copyright (C) 2011-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
@ -17,22 +17,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function showOrHideDefaultPasswordWarnings(adminNotDefaultPassword,
userNotDefaultPassword, wsreaderNotDefaultPassword,
wswriterNotDefaultPassword, wssubcontractingNotDefaultPassword) {
function showOrHideDefaultPasswordWarnings(
adminNotDefaultPassword,
wsreaderNotDefaultPassword,
wswriterNotDefaultPassword,
wssubcontractingNotDefaultPassword) {
setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdadmin"),
adminNotDefaultPassword);
var otherDefaultPassword = adminNotDefaultPassword &&
(!userNotDefaultPassword || !wsreaderNotDefaultPassword ||
(!wsreaderNotDefaultPassword ||
!wswriterNotDefaultPassword || !wssubcontractingNotDefaultPassword);
setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdOthers"),
!otherDefaultPassword);
if (otherDefaultPassword) {
setDisplayNoneOrInline(document.getElementById("warningDefaultPasswduser"),
userNotDefaultPassword);
setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdwsreader"),
wsreaderNotDefaultPassword);
setDisplayNoneOrInline(document.getElementById("warningDefaultPasswdwswriter"),