head	1.48;
access;
symbols
	TIGRIS_1_1_0RC2:1.28.6.1
	TIGRIS_1_1_0RC1:1.28.6.1
	TIGRIS_1_1:1.28.6.1.0.2
	TIGRIS_1_0_8:1.28.6.1
	TIGRIS_1_0_8RC3:1.28.6.1
	TIGRIS_1_0_8RC2:1.28.6.1
	TIGRIS_1_0_8RC1:1.28.6.1
	TIGRIS_1_0_7:1.28.6.1
	TIGRIS_1_0_7RC3:1.28.6.1
	TIGRIS_1_0_7RC2:1.28.6.1
	TIGRIS_1_0_7RC1:1.28.6.1
	TIGRIS_1_0_6:1.28
	TIGRIS_1_0_6RC5:1.28
	TIGRIS_1_0_6RC4:1.28
	TIGRIS_1_0_6RC3:1.28
	TIGRIS_1_0_6RC2:1.28
	TIGRIS_1_0_6RC1:1.28
	TIGRIS_1_0_5:1.28
	TIGRIS_1_0_5RC6:1.28
	TIGRIS_1_0_5RC5:1.28
	TIGRIS_1_0_5RC4:1.28
	TIGRIS_1_0_5RC3:1.28
	TIGRIS_1_0_5RC2:1.28
	TIGRIS_1_0_5RC1:1.28
	TIGRIS_1_0_4:1.28
	TIGRIS_1_0_3:1.28
	TIGRIS_1_0_2:1.28
	TIGRIS_1_0_1:1.28
	TIGRIS_1_0:1.28.0.6
	TIGRIS_1_0_0:1.28
	TIGRIS_1_0_0_RC1:1.28.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.18
	TIGRIS_0_9_2_3:1.18
	HELM_PEER_PORT_BRANCH:1.1.1.2
	TURBINE_PEER:1.20
	TIGRIS_0_9_2_1:1.20
	TIGRIS_0_9_2:1.18.0.2
	TIGRIS_0_9_0:1.15.0.2
	TIGRIS_0_8_4:1.11.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.48
date	2001.08.28.17.45.17;	author leonardr;	state Exp;
branches;
next	1.47;

1.47
date	2001.08.28.17.13.33;	author leonardr;	state Exp;
branches;
next	1.46;

1.46
date	2001.08.11.09.08.01;	author dlr;	state Exp;
branches;
next	1.45;

1.45
date	2001.07.26.18.50.15;	author leonardr;	state Exp;
branches;
next	1.44;

1.44
date	2001.07.25.19.39.26;	author leonardr;	state Exp;
branches;
next	1.43;

1.43
date	2001.07.19.00.46.35;	author dlr;	state Exp;
branches;
next	1.42;

1.42
date	2001.07.18.10.05.12;	author dlr;	state Exp;
branches;
next	1.41;

1.41
date	2001.07.17.20.54.06;	author leonardr;	state Exp;
branches;
next	1.40;

1.40
date	2001.07.17.17.55.45;	author leonardr;	state Exp;
branches;
next	1.39;

1.39
date	2001.07.11.23.13.30;	author leonardr;	state Exp;
branches;
next	1.38;

1.38
date	2001.07.06.16.15.46;	author leonardr;	state Exp;
branches;
next	1.37;

1.37
date	2001.07.02.21.21.57;	author leonardr;	state Exp;
branches;
next	1.36;

1.36
date	2001.07.02.18.56.42;	author leonardr;	state Exp;
branches;
next	1.35;

1.35
date	2001.06.21.01.05.16;	author dlr;	state Exp;
branches;
next	1.34;

1.34
date	2001.06.18.22.12.20;	author leonardr;	state Exp;
branches;
next	1.33;

1.33
date	2001.06.06.16.42.44;	author edk;	state Exp;
branches;
next	1.32;

1.32
date	2001.06.06.16.13.37;	author edk;	state Exp;
branches;
next	1.31;

1.31
date	2001.05.23.01.50.10;	author dlr;	state Exp;
branches;
next	1.30;

1.30
date	2001.05.11.19.38.55;	author leonardr;	state Exp;
branches;
next	1.29;

1.29
date	2001.04.26.16.16.43;	author leonardr;	state Exp;
branches;
next	1.28;

1.28
date	2001.03.24.00.44.13;	author leonardr;	state Exp;
branches
	1.28.6.1;
next	1.27;

1.27
date	2001.03.23.23.09.34;	author leonardr;	state Exp;
branches;
next	1.26;

1.26
date	2001.03.07.01.53.20;	author lucas;	state Exp;
branches;
next	1.25;

1.25
date	2001.02.27.23.20.06;	author leonardr;	state Exp;
branches;
next	1.24;

1.24
date	2001.02.27.22.47.50;	author leonardr;	state Exp;
branches;
next	1.23;

1.23
date	2001.02.27.22.15.12;	author leonardr;	state Exp;
branches;
next	1.22;

1.22
date	2001.02.22.21.11.43;	author leonardr;	state Exp;
branches;
next	1.21;

1.21
date	2001.02.21.01.08.21;	author dlr;	state Exp;
branches;
next	1.20;

1.20
date	2001.01.26.18.29.02;	author edk;	state Exp;
branches
	1.20.2.1;
next	1.19;

1.19
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.18;

1.18
date	2001.01.12.22.25.27;	author leonardr;	state Exp;
branches;
next	1.17;

1.17
date	2001.01.08.23.25.02;	author dlr;	state Exp;
branches;
next	1.16;

1.16
date	2000.12.27.23.12.34;	author leonardr;	state Exp;
branches;
next	1.15;

1.15
date	2000.12.21.00.44.49;	author dlr;	state Exp;
branches;
next	1.14;

1.14
date	2000.12.15.04.37.45;	author leonardr;	state Exp;
branches;
next	1.13;

1.13
date	2000.12.12.21.46.40;	author leonardr;	state Exp;
branches;
next	1.12;

1.12
date	2000.12.05.22.09.41;	author leonardr;	state Exp;
branches;
next	1.11;

1.11
date	2000.12.02.00.47.54;	author elicia;	state Exp;
branches;
next	1.10;

1.10
date	2000.12.01.14.08.57;	author edk;	state Exp;
branches;
next	1.9;

1.9
date	2000.11.22.23.42.28;	author leonardr;	state Exp;
branches;
next	1.8;

1.8
date	2000.11.17.02.18.31;	author leonardr;	state Exp;
branches;
next	1.7;

1.7
date	2000.11.17.00.29.21;	author leonardr;	state Exp;
branches;
next	1.6;

1.6
date	2000.11.16.18.54.55;	author leonardr;	state Exp;
branches;
next	1.5;

1.5
date	2000.11.15.22.48.40;	author leonardr;	state Exp;
branches;
next	1.4;

1.4
date	2000.11.15.18.58.39;	author leonardr;	state Exp;
branches;
next	1.3;

1.3
date	2000.11.15.18.49.04;	author leonardr;	state Exp;
branches;
next	1.2;

1.2
date	2000.11.14.00.43.42;	author leonardr;	state Exp;
branches;
next	1.1;

1.1
date	2000.11.12.21.15.43;	author dlr;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2000.11.12.21.15.43;	author dlr;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2001.02.21.00.32.21;	author dlr;	state Exp;
branches;
next	;

1.20.2.1
date	2001.01.28.01.02.17;	author dlr;	state dead;
branches;
next	1.20.2.2;

1.20.2.2
date	2001.02.08.01.54.31;	author elicia;	state Exp;
branches;
next	1.20.2.3;

1.20.2.3
date	2001.02.08.18.13.45;	author leonardr;	state Exp;
branches;
next	1.20.2.4;

1.20.2.4
date	2001.02.15.20.50.35;	author leonardr;	state Exp;
branches;
next	1.20.2.5;

1.20.2.5
date	2001.02.16.03.27.05;	author dlr;	state Exp;
branches;
next	1.20.2.6;

1.20.2.6
date	2001.02.16.22.32.50;	author dlr;	state Exp;
branches;
next	;

1.28.6.1
date	2001.06.21.01.06.18;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.48
log
@More methods migrated to ContextAPI.
@
text
@/* ================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.collab.net/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */


package org.tigris.helm.domain;

import java.io.IOException;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;

import org.apache.turbine.util.Log;
import org.apache.commons.util.StringUtils;
import org.apache.commons.util.exception.NestableException;

import org.apache.velocity.context.Context;

import gnu.regexp.RE;
import gnu.regexp.REException;

import org.tigris.helm.DoesNotExist;
import org.tigris.helm.security.*;
import org.tigris.helm.tool.ContextAPI;
import org.tigris.helm.om.*;

/**
 * Displays the current settings for a Tigris user, and allows editing
 * of them.
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@version $Id: UserEdit.java,v 1.47 2001/08/28 17:13:33 leonardr Exp $
 */
public class UserEdit extends UserInfo
{
    /**
     * Whether to log debugging info.
     */
    private static final boolean DEBUG = true;

    /**
     * The user edit action.
     */
    private static final String EDIT_USER_ACTION = "Submit Changes";

    /**
     * The roles edit action.  Used to approve, defer, or delete roles.
     */
    private static final String EDIT_ROLES_ACTION = "Update Roles";

    /**
     * Prefix for roles to be left alone (not granted or revoked).
     */
    private static final String IGNORE_PREFIX = "Ignore ";

    /**
     * Prefix for roles to be granted.
     */
    private static final String GRANT_PREFIX = "Grant ";

    /**
     * The field name containing the user's email address
     */
    private static final String EMAIL_FIELD = "email";

    /**
     * The field name containing the user's real name
     */
    private static final String REAL_NAME_FIELD = "realName";

    /**
     * The field name containing the user's organization
     */
    private static final String ORGANIZATION_FIELD = "organization";

    /**
     * The field name containing the user's old password
     */
    private static final String OLD_PASSWORD_FIELD = "oldPassword";

    /**
     * The field name containing the user's password
     */
    private static final String PASSWORD_FIELD = "passwd";

    /**
     * The field name containing the confirmation of the user's password
     */
    private static final String PASSWORD_CONFIRM_FIELD = "passwdConfirm";   

    /**
     * Edit the user.
     */
    protected String processRequest(Context context)
        throws NestableException, RedirectException, ACLException
    {
        String templateName = super.processRequest(context);

        // This screen requires a user database key.
        User loginUser = getLoginUser(context);        
        User user = getCurrentUser(context);

        // Get all fields, defaulting them to their database values.
        String email, realName, organization;
        email = ContextAPI.processField
            (context, EMAIL_FIELD, user.getEmail());
        realName = ContextAPI.processField
            (context, REAL_NAME_FIELD, user.getRealName());
        organization = ContextAPI.processField
            (context, ORGANIZATION_FIELD, user.getOrganization());
        
        String passwd = ContextAPI.processFieldRaw(context, PASSWORD_FIELD);
        String passwdConfirm = ContextAPI.processFieldRaw
            (context, PASSWORD_CONFIRM_FIELD);

        // Process the desired action.
        String action = getAction(context);
        try
        {
            AccessControlList acl = loginUser.getACL();
            String oldPassword = null;
            Log.debug("Password: " + passwd);
            if (StringUtils.isValid(passwd))
            {
                ContextAPI.requireValue(context, passwdConfirm, 
                                        "New password confirmation");
                if (!acl.hasPermission("User - Edit", user.getDomain()))
                {
                    oldPassword = ContextAPI.processRequiredFieldRaw
                        (context, OLD_PASSWORD_FIELD, "Old password");
                }            
            }

            //Check permission for viewing this page at all.
            user.assertViewPermission(acl);

            boolean isEditingSelf = loginUser.getID().equals(user.getID());

            if (EDIT_USER_ACTION.equals(action))
            {
                updateUserInfo(acl, context, user, email, realName, 
                               organization, oldPassword, passwd, 
                               passwdConfirm);
                if (isEditingSelf)
                {
                    getSessionManager(context).getSession()
                        .putValue("refreshLoginUser", Boolean.TRUE);
                }
            }
            else if (EDIT_ROLES_ACTION.equals(action))
            {
                updateRoles(loginUser, context, user);
            }
        }
        catch (ACLException e)
        {
            setAsDetour(context);
            throw e;
        }
        catch (RedirectException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            Log.error("Exception in UserEdit: ", e);
            throw new NestableException(e);
        }

        // Provide site policy information to the template when needed
        Boolean userEditSelfAllowsEditOrg =
            new Boolean(User.userEditSelfAllowsEditOrganization());
        context.put("userEditSelfAllowsEditOrg", userEditSelfAllowsEditOrg);

        return templateName;
    }

    /**
     * Updates the user's basic information (i.e. not roles, etc.).
     */
    protected void updateUserInfo (AccessControlList acl, 
                                   Context context, User user, 
                                   String email, String realName, 
                                   String organization,
                                   String oldPassword, 
                                   String passwd, String passwdConfirm)
        throws ACLException, DoesNotExist, Exception
    {
        validate(context, email, realName, passwd, passwdConfirm);

        AccessControlList userACL = user.getACL();
        if (StringUtils.isValid(passwd)
            && StringUtils.isValid(oldPassword)
            && !userACL.hasPermission("User - Edit", user.getDomain())
            && !user.validPassword(oldPassword))
        {
            ContextAPI.addValidationError
                (context, "The current password you specified is incorrect");
        }

        if (ContextAPI.isValidUserInput(context))
        {
            // Update the user info.
            user.update(acl, email, realName, 
                        organization, oldPassword, passwd, passwdConfirm);

            //Grant roles they didn't have before.
            String roleID;
            Domain domain = getCurrentDomain(context);
            Host host = getHost(context);
            List domainRoles = domain.getRoles();
            List hostRoles = host.getRoles();
            for (Iterator i = hostRoles.iterator(); i.hasNext();)
            {
                Role role = (Role)i.next();

                String ignoreField = ContextAPI.getParameter
                    (context, IGNORE_PREFIX + role.getID());
                String grantField = ContextAPI.getParameter
                    (context, GRANT_PREFIX + role.getID());
                if (ignoreField == null)
                {
                    if (grantField != null)
                    {
                        if (!userACL.hasRole(role))
                        {
                            user.grantHostRole(acl, role);
                        }
                    } 
                    else 
                    {
                        if (userACL.hasRole(role)) 
                        {
                            user.revokeHostRole(acl, role);
                        }                    
                    }
                }
            }

            for (Iterator i = domainRoles.iterator(); i.hasNext();)
            {
                Role role = (Role)i.next();
                String ignoreField = ContextAPI.getParameter
                    (context, IGNORE_PREFIX + role.getID());
                String grantField = ContextAPI.getParameter
                    (context, GRANT_PREFIX + role.getID());

                if (ignoreField == null)
                {
                    if (grantField != null)
                    {                                                
                        if (!userACL.hasRole(role, domain))
                        {
                            Log.debug("Granting role " + role.getName());
                            user.grantRole(acl, role, domain);
                        }
                    } 
                    else 
                    {
                        if (userACL.hasRole(role, domain))
                        {
                            Log.debug("Revoking role " + role.getName());
                            user.revokeRole(acl, role, domain);
                        }                    
                    }
                }
            }

            final String UPDATE_SUCCESSFUL_KEY = "updateSuccessful";
            // what we put into the context doesn't matter ... so 
            // long as this key is true to WM
            context.put(UPDATE_SUCCESSFUL_KEY, UPDATE_SUCCESSFUL_KEY);
        }
    }

    /**
     * Updates the user's roles.
     *
     * @@param acl  The ACL of the user viewing the page.
     * @@param context  The context of user interaction.
     * @@param user The user whose roles to update.
     */
    protected void updateRoles (User loginUser, Context context,
                                User user)
        throws ACLException, Exception
    {
        List projects = user.getProjectsForUser(), roles;

        // Iterate all roles for the user and perform the appropriate action.
        for (int i = 0; i < projects.size(); i++)
        {
            Project project = (Project)projects.get(i);

            roles = user.getRolesInProject(project);
            for (int j = 0; j < roles.size(); j++)
            {
                performRoleOp(loginUser, context, user, (Role)roles.get(j), project);
            }

            roles = user.getRequestedRolesInProject(project);
            for (int j = 0; j < roles.size(); j++)
            {
                performRoleOp(loginUser, context, user, (Role)roles.get(j), project);
            }
        }
    }

    /**
     * Determines and performs the appropriate operation on the provided role.
     */
    protected void performRoleOp (User performingUser, Context context, 
                                  User user, Role role, Project project)
        throws ACLException, DoesNotExist, Exception
    {
        AccessControlList acl = performingUser.getACL();
        String operation = ContextAPI.getParameter
            (context, project.getID() + '.' + role.getID());
        if (DEBUG) Log.debug("Performing role op for=" + operation);

        if (operation == null)
        {
            return;
        }

        if (operation.equals("delete"))
        {
            if (performingUser.canRevokeRole(user, project))
            {
                user.revokeRole(acl, role, project);
            } else {
                Log.debug("Not revoking role--insufficient permission.");
            }
        }
        else if (operation.equals("defer"))
        {
            // No op.
        }
        else if (operation.equals("approve"))
        {
            if (performingUser.hasRoleGrantPermission(project))
            {
                user.grantRole(acl, role, project);
            }
        }
        else
        {
            // Reported regardless of whether we are in debug mode.
            Log.warn("Unhandled role operation: " + operation);
        }
    }
}
@


1.47
log
@Completed migration of more methods to ContextAPI.
@
text
@d75 1
a75 1
 * @@version $Id: UserEdit.java,v 1.46 2001/08/11 09:08:01 dlr Exp $
d260 4
a263 4
                String ignoreField = getParameter(context, IGNORE_PREFIX
                                                  + role.getID());
                String grantField = 
                    getParameter(context, GRANT_PREFIX + role.getID());
d286 4
a289 4
                String ignoreField = getParameter(context, IGNORE_PREFIX 
                                                  + role.getID());
                String grantField = 
                    getParameter(context, GRANT_PREFIX + role.getID());
d359 2
a360 2
        String operation = getParameter(context, project.getID() + '.' +
                                        role.getID());
@


1.46
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@d75 1
a75 1
 * @@version $Id: UserEdit.java,v 1.45 2001/07/26 18:50:15 leonardr Exp $
a248 2

            HttpServletRequest request = getRequest(context);
@


1.45
log
@Don't give the same error in two different ways when they don't specify their existing password.
@
text
@d56 2
a57 2
import org.apache.turbine.util.StringUtils;
import org.apache.turbine.util.TurbineException;
d75 1
a75 1
 * @@version $Id: UserEdit.java,v 1.44 2001/07/25 19:39:26 leonardr Exp $
d138 1
a138 1
        throws TurbineException, RedirectException, ACLException
d210 1
a210 1
            throw new TurbineException(e);
@


1.44
log
@User deletes are now soft deletes which change the user type to 'deleted' (a minimal type of user which has user information but is not allowed associations with roles or user groups). Includes some other miscellaneous bug fixes.
@
text
@d75 1
a75 1
 * @@version $Id: UserEdit.java,v 1.43 2001/07/19 00:46:35 dlr Exp $
d181 1
a181 1
            
d236 1
@


1.43
log
@Removed Joist dependancies.
@
text
@d56 1
d75 1
a75 1
 * @@version $Id: UserEdit.java,v 1.42 2001/07/18 10:05:12 dlr Exp $
d155 3
a157 4
        String passwd = ContextAPI.processRequiredFieldRaw
            (context, PASSWORD_FIELD, "New password");
        String passwdConfirm = ContextAPI.processRequiredFieldRaw
            (context, PASSWORD_CONFIRM_FIELD, "New password confirmation");
d165 2
a166 2
            if (haveValue(passwd) && 
                !acl.hasPermission("User - Edit", user.getDomain()))
d168 8
a175 3
                oldPassword = ContextAPI.processRequiredFieldRaw
                    (context, OLD_PASSWORD_FIELD, "Old password");
            }            
d235 3
a237 2
        if (!userACL.hasPermission("User - Edit", user.getDomain())
            && !user.validPassword(oldPassword) && haveValue(passwd))
@


1.42
log
@Ported Joist Redirect*Exception to Helm.
@
text
@a49 3


import java.sql.*;
d51 1
a52 1
import java.util.*;
a62 5
import com.workingdogs.village.*;

import org.tigris.helm.security.RedirectException;
import org.joist.database.JoistDatabaseException;

d74 1
a74 1
 * @@version $Id: UserEdit.java,v 1.41 2001/07/17 20:54:06 leonardr Exp $
@


1.41
log
@Cleanup for port to new error handling system.
@
text
@d68 1
a68 1
import org.joist.security.RedirectException;
d82 1
a82 1
 * @@version $Id: UserEdit.java,v 1.40 2001/07/17 17:55:45 leonardr Exp $
@


1.40
log
@Porting of domain package to new error handling API.
@
text
@d82 1
a82 1
 * @@version $Id: UserEdit.java,v 1.39 2001/07/11 23:13:30 leonardr Exp $
d176 1
a176 1
                oldPassword = processRequiredField
@


1.39
log
@Trim leading and trailing spaces in form fields, except when obtaining passwords.
@
text
@a59 1
import org.apache.turbine.util.TurbineException;
d73 2
a75 1
import org.tigris.helm.om.*;
d82 1
a82 1
 * @@version $Id: UserEdit.java,v 1.38 2001/07/06 16:15:46 leonardr Exp $
a152 3
        List missingFields = new ArrayList();
        List validationErrors = new ArrayList();

d155 6
a160 6
        email = processField(context, EMAIL_FIELD, user.getEmail(),
                             "Email address", missingFields);
        realName = processField(context, REAL_NAME_FIELD, user.getRealName(),
                                "Real name", missingFields);        
        organization = processField(context, ORGANIZATION_FIELD,
                                    user.getOrganization());
d162 4
a165 5
        String passwd = processFieldRaw(context, PASSWORD_FIELD, 
                                        "New password", missingFields);
        String passwdConfirm = processFieldRaw(context, PASSWORD_CONFIRM_FIELD,
                                               "New password confirmation",
                                               missingFields);
d176 2
a177 3
                oldPassword = processField
                    (context, OLD_PASSWORD_FIELD, "Old password", 
                     missingFields);
a184 1

d235 1
a235 5
        List missingFields = new ArrayList();
        List validationErrors = new ArrayList();

        validate(missingFields, validationErrors, email, realName, passwd, 
                 passwdConfirm);
d241 2
a242 1
            validationErrors.add("The current password you specified is incorrect");
d245 1
a245 1
        if (isValidUserInput(missingFields, validationErrors))
d275 3
a277 1
                    } else {
a318 4
        }
        else
        {
            reportInvalidUserInput(context, missingFields, validationErrors);
@


1.38
log
@Users without User - Edit must provide old password in order to change password.
@
text
@d82 1
a82 1
 * @@version $Id: UserEdit.java,v 1.37 2001/07/02 21:21:57 leonardr Exp $
d165 5
a169 5
        String passwd = processField(context, PASSWORD_FIELD, 
                                     "New password", missingFields);
        String passwdConfirm = processField(context, PASSWORD_CONFIRM_FIELD,
                                            "New password confirmation",
                                            missingFields);
@


1.37
log
@Use currentDomain instead of User.getDomain() so that root will work.
@
text
@d82 1
a82 1
 * @@version $Id: UserEdit.java,v 1.36 2001/07/02 18:56:42 leonardr Exp $
d127 5
d153 3
d158 4
a161 2
        email = processField(context, EMAIL_FIELD, user.getEmail());
        realName = processField(context, REAL_NAME_FIELD, user.getRealName());
d164 6
a169 3

        String passwd = processField(context, PASSWORD_FIELD);
        String passwdConfirm = processField(context, PASSWORD_CONFIRM_FIELD);
d175 10
a185 1
            AccessControlList acl = loginUser.getACL();
d188 1
a188 2
            boolean isEditingSelf = 
                loginUser.getID().equals(user.getID());
d190 2
a191 1
            if (haveValue(action))
d193 4
a196 2
                // Perform desired action.
                if (action.equals(EDIT_USER_ACTION))
d198 2
a199 11
                    updateUserInfo(acl, context, user, email, realName, 
                                   organization, passwd, passwdConfirm);
                    if (isEditingSelf)
                    {
                        getSessionManager(context).getSession()
                            .putValue("refreshLoginUser", Boolean.TRUE);
                    }
                }
                else if (action.equals(EDIT_ROLES_ACTION))
                {
                    updateRoles(loginUser, context, user);
d201 4
d237 1
d247 7
d258 1
a258 1
                        organization, passwd, passwdConfirm);
a260 1
            AccessControlList userACL = user.getACL();
@


1.36
log
@Implemented project-scoped roles.
@
text
@d82 1
a82 1
 * @@version $Id: UserEdit.java,v 1.35 2001/06/21 01:05:16 dlr Exp $
d238 1
a238 1
            Domain domain = user.getDomain();
@


1.35
log
@This text was the cause of some confusion for certain users (we will
not divulge their names to protect their identities, lest they be
ridiculed for their stupidity  ;).

IZ #4608
@
text
@d82 1
a82 1
 * @@version $Id: UserEdit.java,v 1.34 2001/06/18 22:12:20 leonardr Exp $
d240 2
a241 2
            List domainRoles = host.getDomainRoles();
            List hostRoles = host.getHostRoles();
@


1.34
log
@Huge patch of the day: Got rid of redundant HELM_DOMAIN table. The project representation of the domain and the host is now the canonical one. Host and Domain now subclass ProjectGroup. The canonical representation of a project's membership in a domain group is now the corresponding mapping in HELM_PROJECT_PROJECTGROUP. Schema changes: No more HELM_DOMAIN table (obviously); no more DOMAIN_ID in HELM_PROJECT; HELM_USER and HELM_VC_VIEW now have foreign keys in HELM_PROJECT instead of HELM_DOMAIN.
@
text
@d82 1
a82 1
 * @@version $Id: UserEdit.java,v 1.33 2001/06/06 16:42:44 edk Exp $
d99 1
a99 1
    private static final String EDIT_ROLES_ACTION = "Edit Roles";
@


1.33
log
@change name internally from UserEditAllows.. to UserEditSelfAllows.. --
which is more accurate
@
text
@d82 1
a82 1
 * @@version $Id: UserEdit.java,v 1.32 2001/06/06 16:13:37 edk Exp $
d254 1
a254 1
                        if (!userACL.hasRoleInHost(role))
d259 1
a259 1
                        if (userACL.hasRoleInHost(role)) 
d279 1
a279 1
                        if (!userACL.hasRoleInDomain(role, domain))
d287 1
a287 1
                        if (userACL.hasRoleInDomain(role, domain))
@


1.32
log
@support for a new conf item (whose default is the current behavior)
to determine whether or not users can edit their own organizations
(if they don't have the User - Edit permission)
@
text
@d82 1
a82 1
 * @@version $Id: UserEdit.java,v 1.31 2001/05/23 01:50:10 dlr Exp $
d204 3
a206 3
        Boolean userEditAllowsEditOrg =
            new Boolean(User.userEditAllowsEditOrganization());
        context.put("userEditAllowsEditOrg", userEditAllowsEditOrg);
@


1.31
log
@Ported Helm from WebMacro to Velocity.
@
text
@d82 1
a82 1
 * @@version $Id: UserEdit.java,v 1.30 2001/05/11 19:38:55 leonardr Exp $
d202 5
@


1.30
log
@A Heartbreaking Patch of Staggering Genius: adds capacity (but no interface) for deeply nested projects, categories, and project groups. As a side effect, gets rid of the hacky special 'all public projects in domain' group. There are probably bugs in this, and some of those bugs are probably security holes, so watch out.
@
text
@d59 2
d62 1
a62 1
import org.webmacro.servlet.*;
d82 1
a82 1
 * @@version $Id: UserEdit.java,v 1.29 2001/04/26 16:16:43 leonardr Exp $
d139 2
a140 2
    protected String processRequest(Connection conn, WebContext context)
        throws HandlerException, RedirectException, ACLException
d142 1
a142 1
        String templateName = super.processRequest(conn, context);
d152 2
a153 1
        organization = processField(context, ORGANIZATION_FIELD, user.getOrganization());
d200 1
a200 1
            throw new HandlerException(e.getMessage());
d210 1
a210 1
                                   WebContext context, User user, 
d228 1
a228 1
            HttpServletRequest request = context.getRequest ();
d241 2
a242 2
                String ignoreField = context.getForm(IGNORE_PREFIX 
                                                     + role.getID());
d244 1
a244 1
                    context.getForm(GRANT_PREFIX + role.getID());
d265 2
a266 2
                String ignoreField = context.getForm(IGNORE_PREFIX 
                                                     + role.getID());
d268 1
a268 1
                    context.getForm(GRANT_PREFIX + role.getID());
d309 1
a309 1
    protected void updateRoles (User loginUser, WebContext context,
d337 1
a337 1
    protected void performRoleOp (User performingUser, WebContext context, 
d342 2
a343 2
        String operation = context.getForm(project.getID() + '.' +
                                           role.getID());
@


1.29
log
@Patches I forgot to commit before, for decoupling privateness from proprietariness.
@
text
@d80 1
a80 1
 * @@version $Id: UserEdit.java,v 1.28 2001/03/24 00:44:13 leonardr Exp $
a109 5
     * Prefix for roles to be granted in a domain's public projects.
     */
    private static final String GRANT_PUBLIC_PREFIX = "Grant Public ";

    /**
a258 1
            Project publicProject = domain.getSpecialPublicProject();
a265 2
                String grantPublicField = 
                    context.getForm(GRANT_PUBLIC_PREFIX + role.getID());
a282 15
                        }                    
                    }
                    
                    if (grantPublicField != null)
                    {
                        if (!userACL.hasRoleInPublicDomainProjects(role, domain))
                        {
                            Log.debug("Granting public role " + role.getName());
                            user.grantRole(acl, role, publicProject);
                        }                    
                    } else {
                        if (userACL.hasRoleInPublicDomainProjects(role, domain))
                        {
                            Log.debug("Revoking public role " + role.getName());
                            user.revokeRole(acl, role, publicProject);
@


1.28
log
@Get the domain of the user being edited, no the current domain.
@
text
@d50 2
d80 1
a80 1
 * @@version $Id: UserEdit.java,v 1.27 2001/03/23 23:09:34 leonardr Exp $
@


1.28.6.1
log
@Backported from the HEAD:

This text was the cause of some confusion for certain users (we will
not divulge their names to protect their identities, lest they be
ridiculed for their stupidity  ;).

IZ #4608
@
text
@d78 1
a78 1
 * @@version $Id: UserEdit.java,v 1.28 2001/03/24 00:44:13 leonardr Exp $
d95 1
a95 1
    private static final String EDIT_ROLES_ACTION = "Update Roles";
@


1.27
log
@Set detour on ACLException.
@
text
@d78 1
a78 1
 * @@version $Id: UserEdit.java,v 1.26 2001/03/07 01:53:20 lucas Exp $
d233 1
a233 1
            Domain domain = getCurrentDomain(context);
a265 1
                Log.debug("Considering role " + role.getName());
a274 1
                    Log.debug("Can't ignore it.");
d276 1
a276 1
                    {
a281 4
                        else
                        {
                            Log.debug("Would grant " + role.getName() + " but they already have it.");
                        }
d287 1
a287 1
                            Log.debug("revoking role " + role.getName());
a289 5
                        else
                        {
                            Log.debug("Would revoke " + role.getName() + " but " + user.getLoginName() + " doesn't have it.");
                        }

a298 5
                        else
                        {
                            Log.debug("Would grant public " + role.getName() + " but they already have it.");
                        }

d302 1
a302 1
                            Log.debug("REvoking public role " + role.getName());
a304 5
                        else
                        {
                            Log.debug("Would revoke public " + role.getName() + " but they don't have it.");
                        }

a306 5
                else
                {
                    Log.debug("Ignoring it.");
                }

@


1.26
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d78 1
a78 1
 * @@version $Id: UserEdit.java,v 1.25 2001/02/27 23:20:06 leonardr Exp $
d188 5
d266 1
d276 1
d281 1
d283 8
a290 2
                        }                    
                    } else {
d293 1
d296 5
d307 1
d310 5
d318 1
d321 5
d327 4
@


1.25
log
@Added code to treat unprivileged users' UserEdit submissions as lack-of-interest-in-checkboxes, not unchecked-checkboxes.
@
text
@a71 1

d78 1
a78 1
 * @@version $Id: UserEdit.java,v 1.24 2001/02/27 22:47:50 leonardr Exp $
@


1.24
log
@Remove debugging.
@
text
@d79 1
a79 1
 * @@version $Id: UserEdit.java,v 1.23 2001/02/27 22:15:12 leonardr Exp $
d99 5
a198 1
        if (DEBUG) Log.debug("done");
d236 6
a241 1
                if (context.getForm("Grant " + role.getID()) != null)
d243 1
a243 1
                    if (!userACL.hasRoleInHost(role))
d245 9
a253 1
                        user.grantHostRole(acl, role);
a254 5
                } else {
                    if (userACL.hasRoleInHost(role)) 
                    {
                        user.revokeHostRole(acl, role);
                    }                    
a257 1

d262 2
d269 1
a269 1
                if (grantField != null)
d271 1
a271 1
                    if (!userACL.hasRoleInDomain(role, domain))
d273 12
a284 4
                        user.grantRole(acl, role, domain);
                    }                    
                } else {
                    if (userACL.hasRoleInDomain(role, domain))
d286 10
a295 15
                        user.revokeRole(acl, role, domain);
                    }                    
                }

                if (grantPublicField != null)
                {
                    if (!userACL.hasRoleInPublicDomainProjects(role, domain))
                    {
                        user.grantRole(acl, role, publicProject);
                    }                    
                } else {
                    if (userACL.hasRoleInPublicDomainProjects(role, domain))
                    {
                        user.revokeRole(acl, role, publicProject);
                    }                    
@


1.23
log
@Made UserEdit host/domain role grant/revoke work.
@
text
@d79 1
a79 1
 * @@version $Id: UserEdit.java,v 1.22 2001/02/22 21:11:43 leonardr Exp $
a231 2
                Log.debug("Considering role " + role.getName() + ": " + (String)
                         context.getForm("Grant " + role.getID()));
a235 1
                        Log.debug("I found a request to grant " + role.getName());
a240 1
                        Log.debug("I found a request to revoke " + role.getName());
a254 3
                
                Log.debug("Considering role " + role.getName() + ": " 
                          + grantField + "/" + grantPublicField); 
a259 2
                        Log.debug("I found a request to grant " 
                                  + role.getName() + " in domain.");
a264 2
                        Log.debug("I found a request to revoke " 
                                  + role.getName() + " from domain.");
a272 3
                        Log.debug("I found a request to grant " 
                                  + role.getName() 
                                  + " in public domain projects.");
a277 3
                        Log.debug("I found a request to revoke " 
                                  + role.getName()
                                  + " from public domain projects.");
@


1.22
log
@Fixed typo AGAIN!!!
@
text
@d79 1
a79 1
 * @@version $Id: UserEdit.java,v 1.21 2001/02/21 01:08:21 dlr Exp $
d99 10
d131 1
a131 1
    private static final String PASSWORD_CONFIRM_FIELD = "passwdConfirm";
a163 5
            if (DEBUG)
            {
                Log.debug("login user id=" + loginUser.getID());
                Log.debug("isEditingSelf=" + isEditingSelf);
            }
a210 2
        if (DEBUG) Log.debug(passwd + " (passwd) " + passwdConfirm);
        
d240 1
a240 2
                        Log.debug("Granted host role.");
                    }                    
d250 2
d255 7
a261 2
                Log.debug("Considering role " + role.getName() + ": " + (String)
                         context.getForm("Grant " + role.getID()));
d263 1
a263 1
                if (context.getForm("Grant " + role.getID()) != null)
d267 2
a268 1
                        Log.debug("I found a request to grant " + role.getName());
d274 2
a275 1
                        Log.debug("I found a request to revoke " + role.getName());
d279 20
@


1.21
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d79 1
a79 1
 * @@version $Id: UserEdit.java,v 1.20.2.6 2001/02/16 22:32:50 dlr Exp $
d121 1
a121 1
    private static final String PASSWORD_CONFIRM_FIELD = "paswdConfirm";
@


1.20
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d2 1
a2 1
 * Copyright (c) 2000 CollabNet.  All rights reserved.
a53 1
import java.util.ArrayList;
d56 2
a57 1
import org.webmacro.util.Log;
a68 1
import org.tigris.helm.tool.UpdateException;
d70 2
a71 2
import org.tigris.helm.project.Project;
import org.tigris.helm.business.Host;
d76 4
a83 5
     * The log file.
     */
    private static Log log = new Log("usrEdt", "UserEdit");

    /**
d86 1
a86 1
    private static final boolean debug = true;
d99 25
d126 1
a126 1
    protected String processRequest(Connection conn, WebContext ctx)
d129 1
a129 2
        if (debug) log.info("started");
        String templateName = super.processRequest(conn, ctx);
d132 2
a133 4
        User loginUser = getLoginUser(ctx);        
        User user = getCurrentUser(ctx);

        // Assert that the user can
d137 6
a142 13
        try
        {
            email = processField(ctx, "email", user.getEmail());
            realName = processField(ctx, "realName", user.getName());
            organization = processField(ctx, "organization", user.getOrganization());
        }
        catch (DataSetException e)
        {
            log.exception(e);
            throw new HandlerException(e.getMessage());
        }
        String passwd = processField(ctx, "passwd");
        String passwdConfirm = processField(ctx, "passwdConfirm");
d145 1
a145 2
        String action = getAction(ctx);
        if (debug) log.info("action=" + action);
d148 1
d150 1
d154 1
a154 1
            if (debug)
d156 2
a157 2
                log.info("login user id=" + loginUser.getID());
                log.info("isEditingSelf=" + isEditingSelf);
a158 1
            addBooleanToContext(ctx, "isEditingSelf", isEditingSelf);
d165 1
a165 1
                    updateUserInfo(acl, conn, ctx, user, email, realName, 
d169 1
a169 1
                        getSessionManager(ctx).getSession()
d175 1
a175 1
                    updateRoles(loginUser, ctx, user);
a177 14

            //Check permission for viewing this page at all. The
            //domain in which permission is checked is not the current
            //domain but the domain in which the user being edited
            //resides.
            String domainID = user.getDomainID();
            if (isEditingSelf)
            {
                acl.assertPermissionForDomain("User - View - Self", domainID);
            }
            else
            {
                acl.assertPermissionForDomain("User - View", domainID);
            }
d185 1
a185 1
            log.exception(e);
d189 1
a189 1
        if (debug) log.info("done");
d196 2
a197 2
    protected void updateUserInfo (AccessControlList acl, Connection conn, 
                                   WebContext ctx, User user, 
d201 1
a201 2
        throws DataSetException, JoistDatabaseException, UpdateException, 
               SQLException, ACLException, DoesNotExist
a202 1
        if (debug) log.info("Updating user info");
d206 2
a207 2
        if (debug) log.info(passwd + " (passwd) " + passwdConfirm);

d214 2
a215 2
            user.updateInfo(acl, ctx, user.getLoginID(), email, realName, 
                            organization, passwd, passwdConfirm);
d217 1
a217 1
            HttpServletRequest request = ctx.getRequest ();
d222 2
a223 2
            Domain domain = getCurrentDomain(ctx);
            Host host = getHost(ctx);
d229 3
a231 3
                log.info("Considering role " + role.getID() + ": " + (String)
                         ctx.getForm("Grant " + role.getID()));
                if (ctx.getForm("Grant " + role.getID()) != null)
d233 1
a233 1
                    if (!userACL.hasRoleInHost(role.getID())) 
d235 3
a237 3
                        log.info("I found a request to grant " + role.getName());
                        user.grantRole(acl, role);
                        log.info("Granted host role.");
d240 1
a240 1
                    if (userACL.hasRoleInHost(role.getID())) 
d242 2
a243 2
                        log.info("I found a request to revoke " + role.getName());
                        user.revokeRole(acl, role);
d251 2
a252 2
                log.info("Considering role " + role.getID() + ": " + (String)
                         ctx.getForm("Grant " + role.getID()));
d254 1
a254 1
                if (ctx.getForm("Grant " + role.getID()) != null)
d256 1
a256 1
                    if (!userACL.hasRoleInDomain(role.getID(), domain.getID()))
d258 1
a258 1
                        log.info("I found a request to grant " + role.getName());
d262 1
a262 1
                    if (userACL.hasRoleInDomain(role.getID(), domain.getID()))
d264 1
d273 1
a273 1
            ctx.put(UPDATE_SUCCESSFUL_KEY, UPDATE_SUCCESSFUL_KEY);
d277 1
a277 1
            reportInvalidUserInput(ctx, missingFields, validationErrors);
d285 1
a285 1
     * @@param ctx  The context of user interaction.
d288 1
a288 1
    protected void updateRoles (User loginUser, WebContext ctx,
d290 1
a290 2
        throws DataSetException, SQLException, JoistDatabaseException,
               UpdateException, DoesNotExist, ACLException
a292 1
        String projectID;
a297 1
            projectID = project.getID();
d299 1
a299 1
            roles = user.getRolesInProject(projectID);
d302 1
a302 1
                performRoleOp(loginUser, ctx, user, (Role)roles.get(j), project);
d305 1
a305 1
            roles = user.getRequestedRolesInProject(projectID);
d308 1
a308 1
                performRoleOp(loginUser, ctx, user, (Role)roles.get(j), project);
d316 1
a316 1
    protected void performRoleOp (User performingUser, WebContext ctx, 
d318 1
a318 2
        throws DataSetException, SQLException, JoistDatabaseException,
               UpdateException, ACLException, DoesNotExist
d321 3
a323 2
        String operation = ctx.getForm(project.getID() + '.' + role.getID());
        if (debug) log.info("role op=" + operation);
d336 1
a336 1
                log.info("Not revoking role--insufficient permission.");
d345 1
a345 1
            if (acl.hasPermission("Project Role - Grant", project.getID()))
d353 1
a353 1
            log.warning("Unhandled role operation: " + operation);
@


1.20.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@@


1.20.2.2
log
@Ported UserEdit--still some bugs that need to be worked out.
@
text
@d54 1
d57 1
a57 2
import org.apache.turbine.util.Log;

d69 1
d71 2
a72 2

import org.tigris.helm.om.*;
d81 5
a100 25
     * The field name containing the user's email address
     */
    private static final String EMAIL_FIELD = "email";

    /**
     * The field name containing the user's real name
     */
    private static final String REAL_NAME_FIELD = "realName";

    /**
     * The field name containing the user's organization
     */
    private static final String ORGANIZATION_FIELD = "organization";

    /**
     * The field name containing the user's password
     */
    private static final String PASSWORD_FIELD = "passwd";

    /**
     * The field name containing the confirmation of the user's password
     */
    private static final String PASSWORD_CONFIRM_FIELD = "paswdConfirm";

    /**
d103 1
a103 1
    protected String processRequest(Connection conn, WebContext context)
d106 2
a107 1
        String templateName = super.processRequest(conn, context);
d110 4
a113 2
        User loginUser = getLoginUser(context);        
        User user = getCurrentUser(context);
d117 13
a129 6
        email = processField(context, EMAIL_FIELD, user.getEmail());
        realName = processField(context, REAL_NAME_FIELD, user.getRealName());
        organization = processField(context, ORGANIZATION_FIELD, user.getOrganization());

        String passwd = processField(context, PASSWORD_FIELD);
        String passwdConfirm = processField(context, PASSWORD_CONFIRM_FIELD);
d132 2
a133 1
        String action = getAction(context);
a135 1
            //Check permission for viewing this page at all.
a136 1
            user.assertViewPermission(acl);
d142 2
a143 2
                Log.debug("login user id=" + loginUser.getID());
                Log.debug("isEditingSelf=" + isEditingSelf);
d145 1
d152 1
a152 1
                    updateUserInfo(acl, context, user, email, realName, 
d156 1
a156 1
                        getSessionManager(context).getSession()
d162 1
a162 1
                    updateRoles(loginUser, context, user);
d165 14
d186 1
a186 1
            Log.error("Exception in UserEdit: ", e);
d190 1
a190 1
        if (debug) Log.debug("done");
d197 2
a198 2
    protected void updateUserInfo (AccessControlList acl, 
                                   WebContext context, User user, 
d202 2
a203 1
        throws ACLException, DoesNotExist, Exception
d205 1
d209 2
a210 2
        if (debug) Log.debug(passwd + " (passwd) " + passwdConfirm);
        
d217 2
a218 2
            user.update(acl, email, realName, 
                        organization, passwd, passwdConfirm);
d220 1
a220 1
            HttpServletRequest request = context.getRequest ();
d225 2
a226 2
            Domain domain = getCurrentDomain(context);
            Host host = getHost(context);
d232 3
a234 3
                Log.debug("Considering role " + role.getID() + ": " + (String)
                         context.getForm("Grant " + role.getID()));
                if (context.getForm("Grant " + role.getID()) != null)
d236 1
a236 1
                    if (!userACL.hasRoleInHost(role))
d238 3
a240 3
                        Log.debug("I found a request to grant " + role.getName());
                        user.grantHostRole(acl, role);
                        Log.debug("Granted host role.");
d243 1
a243 1
                    if (userACL.hasRoleInHost(role)) 
d245 2
a246 2
                        Log.debug("I found a request to revoke " + role.getName());
                        user.revokeHostRole(acl, role);
d254 2
a255 2
                Log.debug("Considering role " + role.getID() + ": " + (String)
                         context.getForm("Grant " + role.getID()));
d257 1
a257 1
                if (context.getForm("Grant " + role.getID()) != null)
d259 1
a259 1
                    if (!userACL.hasRoleInDomain(role, domain))
d261 1
a261 1
                        Log.debug("I found a request to grant " + role.getName());
d265 1
a265 1
                    if (userACL.hasRoleInDomain(role, domain))
d270 1
a270 1
                }
d275 1
a275 1
            context.put(UPDATE_SUCCESSFUL_KEY, UPDATE_SUCCESSFUL_KEY);
d279 1
a279 1
            reportInvalidUserInput(context, missingFields, validationErrors);
d287 1
a287 1
     * @@param context  The context of user interaction.
d290 1
a290 1
    protected void updateRoles (User loginUser, WebContext context,
d292 2
a293 1
        throws ACLException, Exception
d302 1
d304 1
a304 1
            roles = user.getRolesInProject(project);
d307 1
a307 1
                performRoleOp(loginUser, context, user, (Role)roles.get(j), project);
d310 1
a310 1
            roles = user.getRequestedRolesInProject(project);
d313 1
a313 1
                performRoleOp(loginUser, context, user, (Role)roles.get(j), project);
d321 1
a321 1
    protected void performRoleOp (User performingUser, WebContext context, 
d323 2
a324 1
        throws ACLException, DoesNotExist, Exception
d327 2
a328 2
        String operation = context.getForm(project.getID() + '.' + role.getID());
        if (debug) Log.debug("role op=" + operation);
d337 1
a337 1
            if (performingUser.hasRoleGrantPermission(project))
d341 1
a341 1
                Log.debug("Not revoking role--insufficient permission.");
d350 1
a350 1
            if (acl.hasPermission("Project Role - Grant", project))
d358 1
a358 1
            Log.warn("Unhandled role operation: " + operation);
@


1.20.2.3
log
@Porting changes to UserEdit
@
text
@d225 1
a225 1
                Log.debug("Considering role " + role.getName() + ": " + (String)
d247 1
a247 1
                Log.debug("Considering role " + role.getName() + ": " + (String)
a259 1
                        Log.debug("I found a request to revoke " + role.getName());
d263 1
a263 1
            }
d288 1
d318 1
a318 1
        if (debug) Log.debug("role op for =" + operation);
d327 1
a327 1
            if (performingUser.canRevokeRole(user, project))
d340 1
a340 1
            if (performingUser.hasRoleGrantPermission(project))
@


1.20.2.4
log
@Normalized copyright dates.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
@


1.20.2.5
log
@Added author and version tags.
@
text
@a75 4
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@version $Id: $
@


1.20.2.6
log
@Renamed debug constants to DEBUG.
@
text
@d79 1
a79 1
 * @@version $Id: UserEdit.java,v 1.20.2.5 2001/02/16 03:27:05 dlr Exp $
d86 1
a86 1
    private static final boolean DEBUG = true;
d154 1
a154 1
            if (DEBUG)
d189 1
a189 1
        if (DEBUG) Log.debug("done");
d206 1
a206 1
        if (DEBUG) Log.debug(passwd + " (passwd) " + passwdConfirm);
d321 2
a322 3
        String operation = context.getForm(project.getID() + '.' +
                                           role.getID());
        if (DEBUG) Log.debug("Performing role op for=" + operation);
@


1.19
log
@revert this stuff to its state as of 2001/01/24 12:42:00 GMT -- with
the following exceptions, which have some different modifications so
they'll work with changes which have happened in joist:

ProjectNewsEdit.java
SkinManager.java
SkinStyleElementValueManager.java
StyleElementManager.java
StyleManager.java

it compiles.  i dunno if it works, though.
@
text
@@


1.18
log
@Show user group memberships on user edit page.
@
text
@@


1.17
log
@Corrected a bunch of regressions to previous User instantion method.  Deprecated User's getUserID() method in favor of getID() for better conformance with BusinessObject interface and orthoginality with other business objects.  Added a guest user and interface.  Added some JavaDoc to User.
@
text
@d17 1
a17 1
 * software developed by CollabNet (http://www.CollabNet/)."
d32 1
a32 1
 * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
a223 2
            Enumeration paramNames = request.getParameterNames ();
            String paramName;
@


1.16
log
@Support for users in the host domain.
@
text
@d142 1
a142 1
                log.info("login user id=" + loginUser.getUserID());
@


1.15
log
@Note whether editing self in the context so that display of "Delete
User" button is easily controllable.
@
text
@d113 2
d146 1
a146 2
            String domainID = getCurrentDomain(ctx).getID();

d166 5
a178 1
            displayUI(conn, ctx);
a361 23
    }

    /**
     * Displays the user interface to the client.
     *
     * NOTE: This could be done in the template without much difficulty.
     *
     * @@param acl  The ACL of the user viewing the page.
     * @@param conn The JDBC connection to use.
     * @@param ctx  The context of user interaction.
     */
    protected void displayUI (Connection conn, WebContext ctx)
        throws RedirectException, JoistDatabaseException, DataSetException, 
               SQLException
    {
        // Examine the ACL of the user being edited.
        AccessControlList userACL = getCurrentUser(ctx).getACL();
        String domainID = getCurrentDomain(ctx).getID();
        String roleID = roleMgr.getRoleID(conn, "Host Admin");
        addBooleanToContext(ctx, "userIsHostAdmin", userACL.hasRole(roleID));
        roleID = roleMgr.getRoleID(conn, "Domain Admin");
        addBooleanToContext(ctx, "userIsDomainAdmin",
                            userACL.hasRoleInDomain(roleID, domainID));
@


1.14
log
@Big patch whose main effect is to make dynamic the list of roles on UserEdit dynamic.
@
text
@d143 1
@


1.13
log
@Support for user organization
@
text
@d53 1
a53 1
import java.util.List;
d55 1
d72 1
d213 18
a230 4
            
            if (acl.hasPermissionForHost("Host Role - Grant"))
            {
                if (haveValue(ctx.getForm("grantHostAdmin")))
d232 6
a237 1
                    user.grantHostAdminRole(acl);
d239 5
a243 1
                    user.revokeHostAdminRole(acl);
d247 1
a247 2
            String domainID = getCurrentDomain(ctx).getID();
            if (acl.hasPermissionForDomain("Domain Role - Grant", domainID))
d249 5
a253 1
                if (haveValue(ctx.getForm("grantDomainAdmin")))
d255 10
a264 5
                    user.grantDomainAdminRole(acl, domainID);
                }
                else
                {
                    user.revokeDomainAdminRole(acl, domainID);
@


1.12
log
@Added support for resigning your own roles.
@
text
@d112 1
a112 1
        String email, realName;
d117 1
d149 1
a149 1
                                   passwd, passwdConfirm);
d192 1
d210 1
a210 1
                            passwd, passwdConfirm);
@


1.11
log
@added user to the argument list passed to user.revokeRole
@
text
@d157 1
a157 1
                    updateRoles(acl, ctx, user);
d251 1
a251 1
    protected void updateRoles (AccessControlList acl, WebContext ctx,
d268 1
a268 1
                performRoleOp(acl, ctx, user, (Role)roles.get(j), project);
d274 1
a274 1
                performRoleOp(acl, ctx, user, (Role)roles.get(j), project);
d282 1
a282 1
    protected void performRoleOp (AccessControlList acl, WebContext ctx, 
d287 1
d298 1
a298 1
            if (acl.hasPermission("Project Role - Grant", project.getID()))
d300 3
a302 1
                user.revokeRole(acl, user, role, project);
@


1.10
log
@appendToMessage is for error messages, not messages about success.
set something in the context so that the template will know to
display an appropriate message about the update.
@
text
@d299 1
a299 1
                user.revokeRole(acl, role, project);
@


1.9
log
@Changing button name in the servlet and template before someone else changes it only in the template and breaks it (which has happened before).
@
text
@d233 4
a236 1
            appendToMessage(ctx, "Update succeeded");
@


1.8
log
@Don't run MemberAdd on non-base projects.
@
text
@d91 1
a91 1
    private static final String EDIT_USER_ACTION = "Edit User";
@


1.7
log
@Made the TigrisUpdate stuff saner with the use of business objects.
@
text
@d215 1
a215 3
                }
                else
                {
@


1.6
log
@Accessing a servlet that requires a user without specifying a user will now be equivalent to specifying yourself as the user.
@
text
@d193 1
a193 1
               SQLException, ACLException
@


1.5
log
@Got rid of more superfluous UpdateException throwage.
@
text
@a88 5
     * The context key for the user's database key.
     */
    private static final String USER_ID_KEY = "userID";

    /**
d108 1
a108 7
        String userID = ctx.getForm(USER_ID_KEY);
        if (debug) log.info("userID=" + userID);
        if (!haveValue(userID))
        {
            redirectToURL(ctx, "UserAdd");
        }

d131 2
a132 1
            AccessControlList acl = getACL(ctx, conn);
d134 1
a134 1
                getLoginUser(ctx).getUserID().equals(userID);
d137 1
a137 1
                log.info("login user id=" + getLoginUser(ctx).getUserID());
d332 1
a332 4
        if (debug) log.info("Displaying the UI");


        // Examine the ACL of the current user.        
@


1.4
log
@Got rid of unused imports.
@
text
@d294 1
a294 1
               UpdateException, ACLException
@


1.3
log
@Fixed security bug. Also display buttons for role manipulation in UserEdit only if you can use those roles.
@
text
@a54 1
import java.util.Iterator;
a64 3
import org.joist.session.SessionManager;
import org.joist.database.DataManager;
import org.joist.database.UserManager;
@


1.2
log
@Bugfix and removal of no-longer-needed debugging
@
text
@a72 1
import org.tigris.helm.database.ProjectManager;
d142 1
a142 1
        String action = (String)ctx.get("action");
d223 1
a223 1

d336 2
d348 3
a351 12

        // Examine the ACL of the logged in user.
        AccessControlList acl = getACL(ctx, conn);
        addBooleanToContext(ctx, "showHostAdmin", 
                            acl.hasPermissionForHost("Host Role - Grant"));
        addBooleanToContext(ctx, "showDomainAdmin",
                            acl.hasPermissionForDomain("Domain Role - Grant", 
                                                       domainID));

        // Examine the ACL of the current user.
        AccessControlList userACL = 
            new AccessControlList(conn, dMgr, getCurrentUser(ctx).getID());
@


1.1
log
@Initial revision
@
text
@d304 5
@


1.1.1.1
log
@Merging newhelm tree into helm, as per IZ issue #557.  Previous major version of helm is tagged TIGRIS_NOV_11_2000.
@
text
@@


1.1.1.2
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d17 1
a17 1
 * software developed by CollabNet (http://www.collab.net/)."
d32 1
a32 1
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
d53 3
a55 4
import java.util.*;
import javax.servlet.http.*;

import org.apache.turbine.util.Log;
d57 1
d66 3
d72 2
d75 1
a75 2

import org.tigris.helm.om.*;
a79 4
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@version $Id: UserEdit.java,v 1.20.2.6 2001/02/16 22:32:50 dlr Exp $
d84 1
a84 1
     * Whether to log debugging info.
d86 1
a86 1
    private static final boolean DEBUG = true;
d89 1
a89 1
     * The user edit action.
d91 1
a91 1
    private static final String EDIT_USER_ACTION = "Submit Changes";
d94 1
a94 1
     * The roles edit action.  Used to approve, defer, or delete roles.
d96 1
a96 1
    private static final String EDIT_ROLES_ACTION = "Edit Roles";
d99 1
a99 1
     * The field name containing the user's email address
d101 1
a101 1
    private static final String EMAIL_FIELD = "email";
d104 1
a104 1
     * The field name containing the user's real name
d106 1
a106 16
    private static final String REAL_NAME_FIELD = "realName";

    /**
     * The field name containing the user's organization
     */
    private static final String ORGANIZATION_FIELD = "organization";

    /**
     * The field name containing the user's password
     */
    private static final String PASSWORD_FIELD = "passwd";

    /**
     * The field name containing the confirmation of the user's password
     */
    private static final String PASSWORD_CONFIRM_FIELD = "paswdConfirm";
d111 1
a111 1
    protected String processRequest(Connection conn, WebContext context)
d114 2
a115 1
        String templateName = super.processRequest(conn, context);
d118 8
a125 2
        User loginUser = getLoginUser(context);        
        User user = getCurrentUser(context);
d128 13
a140 7
        String email, realName, organization;
        email = processField(context, EMAIL_FIELD, user.getEmail());
        realName = processField(context, REAL_NAME_FIELD, user.getRealName());
        organization = processField(context, ORGANIZATION_FIELD, user.getOrganization());

        String passwd = processField(context, PASSWORD_FIELD);
        String passwdConfirm = processField(context, PASSWORD_CONFIRM_FIELD);
d143 2
a144 1
        String action = getAction(context);
d147 1
a147 4
            //Check permission for viewing this page at all.
            AccessControlList acl = loginUser.getACL();
            user.assertViewPermission(acl);

d149 2
a150 2
                loginUser.getID().equals(user.getID());
            if (DEBUG)
d152 2
a153 2
                Log.debug("login user id=" + loginUser.getID());
                Log.debug("isEditingSelf=" + isEditingSelf);
d155 2
a156 1
            
d162 2
a163 2
                    updateUserInfo(acl, context, user, email, realName, 
                                   organization, passwd, passwdConfirm);
d166 1
a166 1
                        getSessionManager(context).getSession()
d172 1
a172 1
                    updateRoles(loginUser, context, user);
d175 10
d192 1
a192 1
            Log.error("Exception in UserEdit: ", e);
d196 1
a196 1
        if (DEBUG) Log.debug("done");
d203 2
a204 2
    protected void updateUserInfo (AccessControlList acl, 
                                   WebContext context, User user, 
a205 1
                                   String organization,
d207 2
a208 1
        throws ACLException, DoesNotExist, Exception
d210 1
d214 2
a215 2
        if (DEBUG) Log.debug(passwd + " (passwd) " + passwdConfirm);
        
d222 2
a223 2
            user.update(acl, email, realName, 
                        organization, passwd, passwdConfirm);
d225 1
a225 10
            HttpServletRequest request = context.getRequest ();
            AccessControlList userACL = user.getACL();

            //Grant roles they didn't have before.
            String roleID;
            Domain domain = getCurrentDomain(context);
            Host host = getHost(context);
            List domainRoles = host.getDomainRoles();
            List hostRoles = host.getHostRoles();
            for (Iterator i = hostRoles.iterator(); i.hasNext();)
d227 5
a231 4
                Role role = (Role)i.next();
                Log.debug("Considering role " + role.getName() + ": " + (String)
                         context.getForm("Grant " + role.getID()));
                if (context.getForm("Grant " + role.getID()) != null)
d233 1
a233 12
                    if (!userACL.hasRoleInHost(role))
                    {
                        Log.debug("I found a request to grant " + role.getName());
                        user.grantHostRole(acl, role);
                        Log.debug("Granted host role.");
                    }                    
                } else {
                    if (userACL.hasRoleInHost(role)) 
                    {
                        Log.debug("I found a request to revoke " + role.getName());
                        user.revokeHostRole(acl, role);
                    }                    
d237 2
a238 1
            for (Iterator i = domainRoles.iterator(); i.hasNext();)
d240 5
a244 5
                Role role = (Role)i.next();
                Log.debug("Considering role " + role.getName() + ": " + (String)
                         context.getForm("Grant " + role.getID()));

                if (context.getForm("Grant " + role.getID()) != null)
d246 1
a246 11
                    if (!userACL.hasRoleInDomain(role, domain))
                    {
                        Log.debug("I found a request to grant " + role.getName());
                        user.grantRole(acl, role, domain);
                    }                    
                } else {
                    if (userACL.hasRoleInDomain(role, domain))
                    {
                        Log.debug("I found a request to revoke " + role.getName());
                        user.revokeRole(acl, role, domain);
                    }                    
d250 1
a250 4
            final String UPDATE_SUCCESSFUL_KEY = "updateSuccessful";
            // what we put into the context doesn't matter ... so 
            // long as this key is true to WM
            context.put(UPDATE_SUCCESSFUL_KEY, UPDATE_SUCCESSFUL_KEY);
d254 1
a254 1
            reportInvalidUserInput(context, missingFields, validationErrors);
d262 1
a262 1
     * @@param context  The context of user interaction.
d265 1
a265 1
    protected void updateRoles (User loginUser, WebContext context,
d267 2
a268 1
        throws ACLException, Exception
d271 1
d277 1
d279 1
a279 1
            roles = user.getRolesInProject(project);
d282 1
a282 1
                performRoleOp(loginUser, context, user, (Role)roles.get(j), project);
d285 1
a285 1
            roles = user.getRequestedRolesInProject(project);
d288 1
a288 1
                performRoleOp(loginUser, context, user, (Role)roles.get(j), project);
d296 1
a296 1
    protected void performRoleOp (User performingUser, WebContext context, 
d298 2
a299 1
        throws ACLException, DoesNotExist, Exception
d301 2
a302 9
        AccessControlList acl = performingUser.getACL();
        String operation = context.getForm(project.getID() + '.' +
                                           role.getID());
        if (DEBUG) Log.debug("Performing role op for=" + operation);

        if (operation == null)
        {
            return;
        }
d306 1
a306 1
            if (performingUser.canRevokeRole(user, project))
a308 2
            } else {
                Log.debug("Not revoking role--insufficient permission.");
d317 1
a317 1
            if (performingUser.hasRoleGrantPermission(project))
d325 1
a325 1
            Log.warn("Unhandled role operation: " + operation);
d327 33
@

