head	1.7;
access;
symbols
	TIGRIS_NOV_12_2000:1.6
	OLDHELM:1.6.0.4
	TIGRIS_NOV_11_2000:1.6
	TIGRIS_SEP_13_2000:1.6.0.2
	TIGRIS_BASELINE:1.6;
locks; strict;
comment	@# @;


1.7
date	2000.11.12.23.10.06;	author dlr;	state dead;
branches;
next	1.6;

1.6
date	2000.09.20.03.13.14;	author brian;	state Exp;
branches;
next	1.5;

1.5
date	2000.05.23.19.57.34;	author jrobbins;	state Exp;
branches;
next	1.4;

1.4
date	2000.04.18.00.10.33;	author jrobbins;	state Exp;
branches;
next	1.3;

1.3
date	2000.02.03.04.21.31;	author jrobbins;	state Exp;
branches;
next	1.2;

1.2
date	2000.01.31.02.41.53;	author jrobbins;	state Exp;
branches;
next	1.1;

1.1
date	2000.01.30.01.59.36;	author jrobbins;	state Exp;
branches;
next	;


desc
@@


1.7
log
@Does not exist--possibly only WRT this location--in newhelm.
@
text
@/* ================================================================
 * Copyright (c) 2000 Collab.Net.  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 Collab.Net (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 Collab.Net.
 * 
 * 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 COLLAB.NET 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 Collab.Net.
 */


package org.tigris.helm.admin;

import java.io.*;
import java.util.*;
import com.sun.java.util.collections.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

import org.webmacro.util.*;
import org.webmacro.servlet.*;
import org.webmacro.engine.*;
import org.webmacro.broker.*;
import org.webmacro.resource.*;

import org.joist.*;
import org.joist.util.*;
import org.joist.session.*;

import org.joist.security.UnsecureServlet;
import org.joist.security.RedirectException;

/**
  * Display and process the login screen.
  *  - Get loginID and password from the screen
  *  - Use both the Name and Password to select from the User table
  *  - If no match, redisplay the Login screen with a "Login Failed" message
  *  - If a record is found:
  *    - Look up the Roles and Permissions for this User
  *    - Cache Permissions for this User
  *    - Redirect to the Start Page for this User
  *
  */

public class TLogin extends UnsecureServlet 
{
    static private Log log = new Log("tlogin", "Tlogin screen");
    static private boolean debug = true;

    /**
     *  Display and process the tlogin screen.
     */
	protected String
    processRequest (Connection connection, WebContext context)
	throws HandlerException, RedirectException
    {
	String templateName = super.processRequest(connection, context);

	SessionManager sMgr = getSessionManager(context);

	// Get loginID and password from the screen
	String loginID = context.getForm("loginID");
	String password = context.getForm("password");
	String action = (String)context.get("action");

	if (debug) log.debug("TLogin: action=" + action );

	try
	{
	    boolean validAction = action.equals("none");

	    if (action.equals("New Password"))
	    {
		validAction = true;

		if (debug) log.debug("TLogin: action=New Password");
		if (loginID.equals(""))
		{
		    if (debug) log.debug("Tlogin: missing loginID");
		    context.put("Message",
			"Your login name is required for new password");
		}
		else
		{
		    if (debug) log.debug("Tlogin: calling newPassword");
		    context.put("Message",
			"Your new password has been e-mailed to you");
		    TPasswordRegenerator pwd =
			new TPasswordRegenerator(myProperties);
		    pwd.newPassword(connection, context, loginID);
		}
	    }

	    if (action.equals("Login"))
	    {
		validAction = true;

		if ((loginID == null) || (loginID.trim().length() == 0) ||
		   (password == null) || (password.trim().length() == 0))
		{
		    context.put("Message",
			"Please enter a Login Name and Password");
		    return templateName;
		}

		// Check if the login name - password is valid, and cache
		// login info in the session.
		if (!sMgr.loginIsValid(connection, context, loginID, password))
		{
		    // Login failed.  Bail out now and redisplay the login page.
		    context.put("Message", "Login Failed");
		    return templateName;
		}
	    
		//  Look up the Roles and Permissions for this User and
		//  cache them in the session.
		sMgr.getPermissions(connection, context);

		//  Redirect to the target page or the Start Page for this User
		redirectToDetour(context);
	    }

	    if (!validAction) redirectToUnauthorized();
	}
	catch (SQLException e)
	{
	    String message = "SQL problem in Tlogin: " + e.getMessage();
	    if (debug) log.debug(message);
	    throw new HandlerException(message);
	}
	catch (JoistException e)
	{
	    String message = "Problem in Tlogin: " + e.getMessage();
	    if (debug) log.debug(message);
	    throw new HandlerException(message);
	}

	return templateName;
    }
}

@


1.6
log
@
Obtained from:
Submitted by:
Reviewed by:

Moved from org.helm to org.tigris.helm
Moved from org/helm to org/tigris/helm

perl -pi.bak -e, how I love thee

note: this update was done POST-CVS-REPOSITORY surgury.  In order to
get this right, you may need to remove the directories

$CVSROOT/helm/java/org/helm
$CVSROOT/helm/data/htdoc/look/www/org/helm
$CVSROOT/helm/templates/org/helm

before doing the "CVS update" call, since those directories don't
exist anymore and CVS will try to create lockfiles for you in them,
giving you an error.
@
text
@@


1.5
log
@added tigris-specific subclass of PasswordRegenerator to keep tigris database tables in synch
@
text
@d48 1
a48 1
package org.helm.admin;
@


1.4
log
@switched from collections2.jar to collections.jar
@
text
@d67 1
a67 1
import org.joist.security.Login;
d82 3
a84 2
public class TLogin extends org.joist.security.Login {
    static private Log log = new Log("tlogin", "Tigris Login screen");
d88 1
a88 1
     *  Display and process the login screen.
a93 2
	if (debug) log.debug("TLogin: started!");

a94 1
	if (debug) log.debug("TLogin: step 1");
a95 3
	HttpServletRequest request = context.getRequest();
	HttpServletResponse response = context.getResponse();
	HttpSession session = context.getSession();
a97 2
	if (debug) log.debug("TLogin: step 2");

a102 2
        if (debug) log.debug("TLogin: step 3");
        
d105 69
a173 1
	if (debug) log.debug("TLogin:  done");
d175 1
a175 1
        return templateName;
d177 2
a178 2
  
} /* end class TLogin */
@


1.3
log
@Added tigris.org license
PR:
Obtained from:
Submitted by:
Reviewed by:
@
text
@d52 1
@


1.2
log
@updated TView since some of it was moved into joist; made copyrights consistent
@
text
@d1 46
a46 1
// Copyright (c) 2000 Collab.Net, Inc. All Rights Reserved.
@


1.1
log
@initial checking
@
text
@a33 4
  * @@author jrobbins@@collab.net
  * @@version $id$
  *
  * Copyright (c) 1999 Collab.Net, inc.
@

