[cvs] Expresso commit by mtraum: remove depreciated class

JCorporate Ltd jcorp at jcorp2.servlets.net
Mon Oct 11 22:13:10 PDT 2004


Log Message:
-----------
remove depreciated class

Removed Files:
-------------
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/services/dbobj:
        UserDBObj.java

Revision Data
-------------
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/services/dbobj/UserDBObj.java
+++ /dev/null
@@ -1,1006 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. 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 acknowledgment:
- *       "This product includes software developed by Jcorporate Ltd.
- *        (http://www.jcorporate.com/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written permission,
- *    please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- *    or other Jcorporate product names; nor may "Expresso" or other
- *    Jcorporate product names appear in their name, without prior
- *    written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- *    market space, i.e. framework, without prior written permission
- *    of Jcorporate Ltd. For written permission, please contact
- *    partners at jcorporate.com.
- *
- * 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 JCORPORATE LTD 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 the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.services.dbobj;
-
-import com.jcorporate.expresso.core.controller.ControllerRequest;
-import com.jcorporate.expresso.core.db.DBConnection;
-import com.jcorporate.expresso.core.db.DBException;
-import com.jcorporate.expresso.core.dbobj.SecuredDBObject;
-import com.jcorporate.expresso.core.dbobj.ValidValue;
-import com.jcorporate.expresso.core.logging.LogException;
-import com.jcorporate.expresso.core.misc.Base64;
-import com.jcorporate.expresso.core.misc.DateTime;
-import com.jcorporate.expresso.core.misc.EMailSender;
-import com.jcorporate.expresso.core.misc.EventHandler;
-import com.jcorporate.expresso.core.security.CryptoManager;
-import com.jcorporate.expresso.core.security.User;
-import com.jcorporate.expresso.core.security.UserInfo;
-import com.jcorporate.expresso.ext.dbobj.RegisteredUser;
-import com.jcorporate.expresso.kernel.exception.ChainedException;
-import com.jcorporate.expresso.kernel.util.FastStringBuffer;
-import org.apache.log4j.Logger;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Vector;
-
-
-/**
- *
- * @see com.jcorporate.expresso.services.dbobj.DefaultUserInfo
- * @author        Michael Nash
- * @deprecated    Use DefaultUserInfo instead Since Expresso 4.0
- */
-public class UserDBObj
-        extends SecuredDBObject
-        implements UserInfo {
-
-    private static final String thisClass = UserDBObj.class.getName() + ".";
-
-    private static Logger log = Logger.getLogger(UserDBObj.class);
-    public static final String EXPUID = "ExpUid";
-    public static final String USERNAME = "UserName";
-    public static final String DESCRIPTION = "Descrip";
-    public static final String LASTNAME = "LastName";
-    public static final String FIRSTNAME = "FirstName";
-    public static final String PASSWORD = "Passwd";
-    public static final String EMAIL = "EMail";
-    public static final String ACCOUNT_STATUS = "AccountStatus";
-    public static final String CREATION_DATE = "CreateDate";
-    public static final String EMAIL_VALIDATION_CODE = "EmailValCode";
-
-    /**
-     * @see com.jcorporate.expresso.core.dbobj.SecuredDBObject#SecuredDBObject
-     *
-     * @throws  DBException
-     */
-    public UserDBObj()
-            throws DBException {
-        super();
-    } /* UserDBObj() */
-
-    /**
-     * Constructor
-     * Creation date: (8/9/00 5:44:22 PM)
-     *
-     * @param   dbConnection com.jcorporate.expresso.core.db.DBConnection
-     * @throws  DBException
-     */
-    public UserDBObj(DBConnection dbConnection)
-            throws DBException {
-        super(dbConnection);
-    } /* UserDBObj(DBConnection) */
-
-    /**
-     * Use over (String) constructor.  Initializes the object in the context
-     * of the user who's uid belongs to the parameter.
-     * @param uid the Uid of the user context
-     * @throws DBException if there's an initialization problem
-     */
-    public UserDBObj(int uid)
-            throws DBException {
-        super(uid);
-    }
-
-    /**
-     * For using DBObjects within Controllers.  Initializes based upon the current
-     * user and the requested db. [Of course this can be modified later]
-     *
-     * @param request - The controller request handed to you by the framework.
-     * @throws DBException
-     */
-    public UserDBObj(ControllerRequest request)
-            throws DBException {
-        super(request);
-    }
-
-    /**
-     * Encode the password before adding the record to the database
-     *
-     * @throws    DBException If the add fails
-     */
-    public void add()
-            throws DBException {
-
-        // If a User is added without a status, we set the AccountStatus to "I"
-        // for security reasons
-        if (getField(ACCOUNT_STATUS).equals("")) {
-            setField(ACCOUNT_STATUS, "I");
-        }
-        // We should always have a CreateDate
-        if (getField(CREATION_DATE).equals("")) {
-            setField(CREATION_DATE, DateTime.getDateTimeForDB(this.getDataContext()));
-        }
-
-
-        User user = new User();
-        user.setDataContext(this.getDataContext());
-        user.addNotify(this);
-
-        super.add();
-    } /* add() */
-
-
-    /**
-     * When a user entry is deleted, the corresponding entries in the group
-     * members table must also be deleted
-     *
-     * @throws    DBException If the delete fails
-     */
-    public void delete()
-            throws DBException {
-        GroupMembers gml = new GroupMembers();
-        gml.setDataContext(getDataContext());
-        gml.setField("ExpUid", getField(EXPUID));
-
-        GroupMembers oneMember = null;
-
-        for (Iterator e = gml.searchAndRetrieveList().iterator();
-             e.hasNext();) {
-            oneMember = (GroupMembers) e.next();
-
-            /* We check this in case it's been removed by the time we get */
-            /* to it by group nesting */
-            if (oneMember.find()) {
-                oneMember.delete();
-            }
-        } /* for each group member listing */
-
-
-        User user = new User();
-        user.setDataContext(this.getDataContext());
-        user.deleteNotify(this);
-
-        super.delete();
-    } /* delete() */
-
-
-    public String getAccountStatus()
-            throws DBException {
-        return getField(ACCOUNT_STATUS);
-    }
-
-    /**
-     * to be deprecated soon.
-     * @throws DBException
-     * @return a Vector of all UserDBOBbj objects
-     */
-    public Vector getAllUsers()
-            throws DBException {
-        UserDBObj u = new UserDBObj(this.getUid());
-        u.setDataContext(getDataContext());
-
-        return new Vector(u.searchAndRetrieveList(USERNAME));
-    }
-
-    /**
-     * Returns a list of all users on the UserDBOBject table.
-     * @throws DBException
-     * @return an ArrayList of DBOBjects sorted by user name
-     */
-    public ArrayList getAllUsersList()
-            throws DBException {
-        return searchAndRetrieveList(USERNAME);
-    }
-
-    public String getCreateDate()
-            throws DBException {
-        return getField(CREATION_DATE);
-    }
-
-    public String getEmail()
-            throws DBException {
-        return getField(EMAIL);
-    }
-
-    /**
-     * Here we generate an authorization code that would be hard for someone to
-     * guess. The idea is that the person has to check the email sent to them to
-     * get this number, and then click on the specially encoded URL to ensure that
-     * he/she actually is checking the email account used at registration.
-     *
-     * The little trick of getting the time in milliseconds that the person
-     * registered, multiplying by some constant, and then rounding, is extremely
-     * weak. We need a better method of generating a unique code that will
-     * "play nice" in a query string.
-     *
-     * @throws  DBException
-     * @return java.lang.String
-     */
-    public String getEmailAuthCode()
-            throws DBException {
-        Date createDate = getFieldDate(CREATION_DATE);
-        long dateLong = createDate.getTime();
-        long emailAuthCode = Math.round(dateLong * 1.71);
-
-        return Long.toString(emailAuthCode);
-    } /* getEmailAuthCode() */
-
-
-    public String getEmailValCode()
-            throws DBException {
-        return getField(EMAIL_VALIDATION_CODE);
-    }
-
-    /**
-     * Return a vector of the group names that this user belongs to
-     *
-     * @return    Vector Group names that this user belongs to
-     * @throws    DBException If an error occurs when the group info is read
-     */
-    public Vector getGroups()
-            throws DBException {
-        Vector myGroups = new Vector(1);
-        GroupMembers memberList = new GroupMembers();
-        memberList.setDataContext(getDataContext());
-
-        GroupMembers oneMember = null;
-        memberList.setField(GroupMembers.EXPUID, getField(EXPUID));
-
-        for (Iterator e = memberList.searchAndRetrieveList().iterator();
-             e.hasNext();) {
-            oneMember = (GroupMembers) e.next();
-
-            //Don't add it to a valid group if the membership has
-            //expired
-            if (!oneMember.hasExpired()) {
-                myGroups.addElement(oneMember.getField("GroupName"));
-            }
-        }
-
-        return myGroups;
-    } /* getGroups() */
-
-
-    public String getLoginName()
-            throws DBException {
-        return getField(USERNAME);
-    }
-
-    public String getPassword()
-            throws DBException {
-        return getField(PASSWORD);
-    }
-
-    public boolean getRegComplete()
-            throws DBException {
-
-        // Always true for now...
-        return true;
-    }
-
-    public String getRegistrationDomain()
-            throws DBException {
-
-        // No domain id in the DB in this version...return "default"
-        return "default";
-    }
-
-    public int getUid()
-            throws DBException {
-        return getFieldInt(EXPUID);
-    }
-
-    public String getUpdateDate()
-            throws DBException {
-        return getField("UpdateDate");
-    }
-
-    public String getUserName()
-            throws DBException {
-        return getField(DESCRIPTION);
-    }
-
-    /**
-     *
-     * @param   fieldName the name of the field to retrieve
-     * @return  java.util.Vector of ValidValueObjects
-     * @throws  com.jcorporate.expresso.core.db.DBException The exception description.
-     */
-    public synchronized Vector getValidValues(String fieldName)
-            throws DBException {
-        if (ACCOUNT_STATUS.equals(fieldName)) {
-            Vector values = new Vector();
-            ValidValue vv = new ValidValue("A", "Active");
-            values.addElement(vv);
-            vv = new ValidValue("I", "Inactive Until Email Confirmation");
-            values.addElement(vv);
-            vv = new ValidValue("D", "Disabled");
-            values.addElement(vv);
-
-            return values;
-        }
-
-        return super.getValidValues(fieldName);
-    } /* getValidValues(String) */
-
-
-    /**
-     * hashEncodePassword:  If passed a plaintext string > 0 bytes, then this
-     * function will SHA1 hash the password, then Base64 encode it and return it
-     * as a string.
-     *
-     * If the password is zero length, then it will simply return a zero length
-     * string also.
-     *
-     * @param plaintext - the password to process in this manner: <br>
-     *                      returnValue = Base64(SHA-1(plaintext))
-     * @throws  DBException
-     * @return a hash/base64 encoded String
-     */
-    private String hashEncodePassword(String plaintext)
-            throws DBException {
-        if (plaintext == null) {
-            throw new DBException("Password Must not be NULL");
-        }
-        if (plaintext.length() == 0) {
-            return plaintext;
-        }
-        try {
-            return Base64.encode(CryptoManager.getInstance().getStringHash().produceHash(
-                    plaintext.getBytes()));
-        } catch (Exception ex) {
-            throw new DBException("Error hashing Password:" +
-                    "  You may not have installed the" +
-                    " Cryptography Extensions Properly:", ex);
-        }
-    } /* hashEncodePassword(String) */
-
-
-    /**
-     * Send this user a notification via e-mail.
-     *
-     * @param    subject Subject of the e-mail
-     * @param    message Message to send in body of e-mail
-     * @throws    DBException If the mail message cannot be sent
-     * @throws  LogException
-     */
-    public void notify(String subject, String message)
-            throws DBException, LogException {
-        log.info("Notifying user " + getField(EXPUID) + " of " + subject);
-
-        String sendToUser = getField(EMAIL);
-
-        try {
-            EMailSender ems = new EMailSender();
-            ems.setDBName(getDataContext());
-            ems.send(sendToUser, subject, message);
-        } catch (Exception e) {
-            throw new DBException("Uncaught exception sending e-mail", e);
-        }
-    } /* notify(String, String) */
-
-
-    /**
-     * Check if the given number is in the range of letters and
-     * digits that we want to use for generating a password
-     * Previously in com.jcorporate.expresso.ext.servlet.RegisterUser.java
-     *
-     * @param   x The byte to check
-     * @return true if the byte is a printable ASCII character
-     */
-    private boolean okNumber(byte x) {
-        if ((x >= 65) && (x <= 90)) {
-            return true;
-        }
-        if ((x >= 48) && (x <= 57)) {
-            return true;
-        }
-        if ((x >= 97) && (x <= 122)) {
-            return true;
-        }
-
-        return false;
-    } /* okNumber(byte) */
-
-    /**
-     * passwordEquals - feed it a password and it will tell you if the hash of it
-     * matches the one on file.
-     *
-     * Also, for backwards compatability and some other issues, this function
-     * will also accept a plaintext version of the password if it is sitting in
-     * the database.  However, if a plaintext match is encountered, then it will
-     * hash the password and re-write itself to the database record.
-     *
-     * @param   tryPassword The value the user input for an attempted login.
-     * @throws  DBException
-     * @return true if the password equals
-     */
-    public boolean passwordEquals(String tryPassword)
-            throws DBException {
-        if (tryPassword == null) {
-            throw new DBException(thisClass + ":tryPassword Must not be NULL");
-        }
-
-        String fieldData = getField(PASSWORD);
-        String trieduser = getField(EXPUID);
-
-        if (log.isDebugEnabled()) {
-            log.debug("Trying user " + trieduser + ", password '" +
-                    tryPassword + "' - field data is '" + fieldData + "'");
-        }
-
-        String triedhash = hashEncodePassword(tryPassword);
-
-        if (log.isDebugEnabled()) {
-            log.debug("Password hashed is " + triedhash + "'");
-        }
-        if (triedhash.equals(fieldData)) {
-            return true;
-        } else {
-            if (log.isDebugEnabled()) {
-                log.debug("Hash doesn't equal data - trying plaintext");
-            }
-            //The second compare check is to make sure somebody isn't just
-            //replaying a snooped password and attempting to use it against
-            //us.  If Password.length() == 28 then it's a hash.
-            if (tryPassword.equals(fieldData) && fieldData.length() < 20) {
-                if (log.isDebugEnabled()) {
-                    log.debug("Password matches in plain text - hashing & writing to DB");
-                }
-
-                setField(PASSWORD, hashEncodePassword(fieldData));
-                update();
-
-                return true;
-            } else {
-
-                //No Match
-                if (log.isDebugEnabled()) {
-                    log.debug("Password doesn't equal plain text either ('" +
-                            tryPassword + "' <> '" + fieldData +
-                            "') or field data is over 20 characters");
-                }
-
-                return false;
-            }
-        }
-    } /* passwordEquals(String) */
-
-
-    /**
-     * Called by the various objects that can log in a user
-     * to do post-login tasks
-     *
-     * @throws  DBException
-     * @throws  LogException
-     */
-    public void postLogin()
-            throws DBException, LogException {
-        UserGroup oneGroup = new UserGroup(SecuredDBObject.SYSTEM_ACCOUNT);
-        oneGroup.setDataContext(getDataContext());
-
-        String theEvent = null;
-        Hashtable allEvents = new Hashtable(1);
-        String oneGroupName = null;
-
-        for (Enumeration gl = getGroups().elements(); gl.hasMoreElements();) {
-            oneGroupName = (String) gl.nextElement();
-            oneGroup.clear();
-            oneGroup.setField("GroupName", oneGroupName);
-
-            if (oneGroup.find()) {
-                theEvent = oneGroup.getField("LoginEvent");
-
-                if (!theEvent.equals("")) {
-                    allEvents.put(theEvent, oneGroup.getField("GroupName"));
-                }
-            } /* if the group exists */
-
-        } /* for each group user is a member of */
-
-
-        /* if any events need to be triggered... */
-        String theMessage = null;
-        RegisteredUser oneReg = new RegisteredUser(SecuredDBObject.SYSTEM_ACCOUNT);
-        oneReg.setDataContext(getDataContext());
-
-        if (allEvents.size() > 0) {
-            for (Enumeration el = allEvents.keys(); el.hasMoreElements();) {
-                theEvent = (String) el.nextElement();
-                oneReg.setField("ExpUid", getField(EXPUID));
-
-                if (oneReg.find()) {
-                    theMessage = ("User " + getField(EXPUID) +
-                            " (" + getField(DESCRIPTION) +
-                            ") who is a member " +
-                            "of group " +
-                            (String) allEvents.get(theEvent) +
-                            " and from company " +
-                            oneReg.getField("CompanyName") +
-                            " has just logged in.");
-                } else {
-                    theMessage = ("User " + getField(EXPUID) +
-                            " (" + getField(DESCRIPTION) +
-                            ") who is a member " +
-                            " of group " +
-                            (String) allEvents.get(theEvent) +
-                            " has just logged in.");
-                }
-
-                EventHandler.Event(getDataContext(), theEvent, theMessage, true);
-            } /* for each event */
-
-        } /* if any events to be triggered */
-
-    } /* postLogin() */
-
-
-    /**
-     * Generate a Random Password
-     *
-     * @return Random String for a password
-     */
-    public String randomPassword() {
-        int passwordLength;
-        int iterations = 0;
-
-        //
-        //Read the property value of minimum password length
-        //
-        String propValue = ""; //StringUtil.notNull(ConfigManager.getProperty(
-
-        //getDataContext(), "minPasswordSize"));
-        if (!propValue.equals("")) {
-            try {
-                passwordLength = Integer.parseInt(propValue, 10);
-            } catch (NumberFormatException ex) {
-
-                //Bad number
-                passwordLength = 6;
-            }
-        } else {
-            passwordLength = 6;
-        }
-
-        FastStringBuffer newPassword = new FastStringBuffer(passwordLength);
-
-        /////////////////////////////////
-        //
-        //Now Generate the new password.  (Code from servlet.RegisterUser) before)
-        //
-        //Get 400 bytes worth of
-        //Modified:  Fill an array of 200 possible numbers.  This is our previous max
-        //tries anyway.  Then try those in the array.  Saves many allocations,
-        //and more importantly, provides a true random number source.
-        byte[] possibleNumbers;
-
-        try {
-            possibleNumbers = CryptoManager.getInstance().getRandomGenerator().getRandomBytes(
-                    200);
-        } catch (ChainedException e) {
-            possibleNumbers = new byte[200];
-
-            //If an error occurs, just fill it with Math.random() after logging the
-            //exception.
-            Logger.getLogger("com.jcorporate.expresso.core.security.").error(
-                    "Random Password", e);
-
-            for (int i = 0; i < 200; i++) {
-                possibleNumbers[i] = (byte) (Math.random() * 122);
-            }
-        }
-        while ((newPassword.length() < passwordLength) && (iterations < 200)) {
-            iterations++;
-
-            //oneNumber = Math.random() * 122;
-            if (okNumber(possibleNumbers[iterations])) {
-                newPassword.append((char) possibleNumbers[iterations]);
-            }
-        }
-
-        return newPassword.toString();
-    } /* randomPassword() */
-
-    /**
-     * Sends an Authorization Email to a new User.
-     * The user must click on the link encoded in this email before
-     * his account will be activated.
-     *
-     * @throws  DBException
-     */
-    public void sendAuthEmail()
-            throws DBException {
-        try {
-            String dbContext = getDataContext();
-            String authURL = Setup.getValue(dbContext, "EmailValidateURL");
-            String emailAuthCode = getEmailAuthCode();
-            this.setField(EMAIL_VALIDATION_CODE, emailAuthCode);
-            this.update();
-            authURL = authURL + "?UserName=" + getField(USERNAME) +
-                    "&EmailAuthCode=" + emailAuthCode;
-
-            String subject = "New Account Validation - Please Respond";
-            StringBuffer sb = new StringBuffer();
-
-            if (!"".equals(getField(DESCRIPTION))) {
-                sb.append("Dear " + getField(DESCRIPTION) + ",");
-            }
-
-            sb.append("\n");
-            sb.append("\n");
-            sb.append("Thank you for registering");
-
-            String companyName = Setup.getValue(dbContext, "CompanyName");
-            String homePageURL = Setup.getValue(dbContext, "HomePageURL");
-
-            if (companyName != null && !"".equals(companyName)) {
-                sb.append(" with " + companyName);
-            }
-            if (homePageURL != null && !"".equals(homePageURL)) {
-                sb.append(" at " + homePageURL);
-            }
-
-            sb.append("!");
-            sb.append("\n");
-            sb.append("\n");
-            sb.append("Your account has been successfully created. " +
-                    "The final step in the");
-            sb.append("\n");
-            sb.append("registration process is to simply follow the link " +
-                    "below to let us");
-            sb.append("\n");
-            sb.append("know that you received this message. You must follow " +
-                    "the link below");
-            sb.append("\n");
-            sb.append("before your account will be activated.");
-            sb.append("\n");
-            sb.append("\n");
-            sb.append("NOTE: If you did not register, you may safely");
-            sb.append("\n");
-            sb.append("ignore this message.");
-            sb.append("\n");
-            sb.append("\n");
-            sb.append("In many email clients, you may simply click on the " +
-                    "link below to");
-            sb.append("\n");
-            sb.append("complete the registration process. If your email " +
-                    "client does not");
-            sb.append("\n");
-            sb.append("support this, cut-and-paste the link below into your " +
-                    "web browser's");
-            sb.append("\n");
-            sb.append("\"Location\" window:");
-            sb.append("\n");
-            sb.append("\n");
-            sb.append(authURL);
-            sb.append("\n");
-            sb.append("\n");
-
-            if (companyName != null && !"".equals(companyName)) {
-                sb.append("Thank you from all of us at " + companyName + ".");
-            }
-
-            sb.append("\n");
-
-            if (companyName != null && !"".equals(homePageURL)) {
-                sb.append(homePageURL);
-            }
-
-            sb.append("\n");
-
-            String message = sb.toString();
-            notify(subject, message);
-        } catch (Exception e) {
-            throw new DBException(
-                    "Error in sending account verification message to " +
-                    getField(EXPUID) + " at " + getField(EMAIL) + ": " +
-                    e.toString());
-        }
-    } /* sendAuthEmail() */
-
-
-    /**
-     * Send this user an e-mail with file attachments.
-     *
-     * @param    subject Subject of the e-mail
-     * @param    message Message to send in body of e-mail
-     * @param    fileNames of the files to attach
-     * @throws    DBException If the mail message cannot be sent
-     * @throws  LogException
-     */
-    public void sendFileTo(String subject, String message, Vector fileNames)
-            throws DBException, LogException {
-        log.info("Sending " + fileNames.size() + " files via e-mail to " +
-                getField(EXPUID));
-
-        String sendToUser = getField(EMAIL);
-
-        try { // create some properties and get the default Session
-            EMailSender ems = new EMailSender();
-            ems.setDBName(getDataContext());
-            ems.addFileAttachments(fileNames);
-            ems.send(sendToUser, subject, message);
-        } catch (Exception e) {
-            throw new DBException("Error sending e-mail", e);
-        }
-    } /* sendFileTo(String, String, Vector) */
-
-
-    /**
-     * Once a user has validated his email address through the email validation
-     * servlet, the user will receive this message giving previously requested
-     * username/password.
-     *
-     * @throws  com.jcorporate.expresso.core.db.DBException The exception description.
-     */
-    public void sendFollowUpEmail()
-            throws DBException {
-        try {
-            String subject = "New Registration Complete - Welcome!";
-            String dbContext = getDataContext();
-
-            // We can't retrieve the passsword in plain text to transmit to the user
-            // So we just create and set a new passord and send that over.
-            String password = this.randomPassword();
-            this.setPasswordField(password);
-            this.update();
-
-            StringBuffer sb = new StringBuffer();
-
-            if (!"".equals(getField(DESCRIPTION))) {
-                sb.append("Dear " + getField(DESCRIPTION) + ",");
-            }
-
-            sb.append("\n");
-            sb.append("\n");
-            sb.append("Thank you for registering");
-
-            String companyName = Setup.getValue(dbContext, "CompanyName");
-            String homePageURL = Setup.getValue(dbContext, "HomePageURL");
-
-            if (companyName != null && !"".equals(companyName)) {
-                sb.append(" with " + companyName);
-            }
-            if (homePageURL != null && !"".equals(homePageURL)) {
-                sb.append(" at " + homePageURL);
-            }
-
-            sb.append("!");
-            sb.append("\n");
-            sb.append("\n");
-            sb.append("Your account is now active. Below is the information " +
-                    "you will need to log in.");
-            sb.append("\n");
-            sb.append("Please keep this information in a safe place.We hope " +
-                    "you enjoy the site and");
-            sb.append("\n");
-            sb.append("look forward to your participation.");
-            sb.append("\n");
-            sb.append("\n");
-            sb.append("User Name: " + getField(USERNAME));
-            sb.append("\n");
-            sb.append("Password: " + password);
-            sb.append("\n");
-            sb.append("\n");
-
-            if (companyName != null && !"".equals(companyName)) {
-                sb.append("Thank you from all of us at " + companyName + ".");
-            }
-
-            sb.append("\n");
-
-            if (companyName != null && !"".equals(homePageURL)) {
-                sb.append(homePageURL);
-            }
-
-            sb.append("\n");
-
-            String message = sb.toString();
-            notify(subject, message);
-        } catch (Exception e) {
-            throw new DBException(
-                    "Error in sending account verification follow up message to " +
-                    getField(EXPUID) + " at " + getField(EMAIL) + ": " +
-                    e.toString());
-        }
-    } /* sendFollowUpEmail() */
-
-
-    public void setAccountStatus(String accountStatus)
-            throws DBException {
-        setField(ACCOUNT_STATUS, accountStatus);
-    }
-
-    public void setEmail(String email)
-            throws DBException {
-        setField(EMAIL, email);
-    }
-
-    public void setEmailValCode(String code)
-            throws DBException {
-        setField(EMAIL_VALIDATION_CODE, code);
-    }
-
-    public void setLoginName(String loginName)
-            throws DBException {
-        setField(USERNAME, loginName);
-    }
-
-    public void setPassword(String password)
-            throws DBException {
-        setField(PASSWORD, password);
-    }
-
-    /**
-     * Hash the password before writing it to the database
-     *
-     * @param   data The data to set for the password field
-     * @throws  DBException
-     */
-    public void setPasswordField(String data)
-            throws DBException {
-        super.setField(PASSWORD, hashEncodePassword(data));
-    } /* setPasswordField(String) */
-
-
-    public void setRegComplete(boolean status)
-            throws DBException {
-
-        // Ignore this for now....
-    }
-
-    public void setRegistrationDomain(String domain)
-            throws DBException {
-
-        // Simply ignore this.....
-    }
-
-    public void setUid(int uid)
-            throws DBException {
-        setField(EXPUID, uid);
-    } /* setUid(String) */
-
-
-    /**
-     * @see com.jcorporate.expresso.core.dbobj.SecuredDBObject#setupFields
-     *
-     * @throws  DBException
-     */
-    public void setupFields()
-            throws DBException {
-        setTargetTable("USERLOGIN");
-        setDescription("Users (Deprecated)");
-        setCharset("ISO-8859-1");
-        addField(EXPUID, "int", 0, false, "User Id");
-        addField(USERNAME, "char", 30, false, "User Login Name");
-        addField(DESCRIPTION, "varchar", 80, true, "User Full Name (deprecated)");
-        addField(LASTNAME, "varchar", 50, true, "Last Name");
-        addField("FirstName", "varchar", 30, true, "FirstName");
-        addField(PASSWORD, "varchar", 30, true, "Intranet Password");
-        addField(EMAIL, "varchar", 80, false, "User E-mail Address");
-        addField(ACCOUNT_STATUS, "char", 1, false, "Is User Account Active?");
-        addField(CREATION_DATE, "datetime", 0, false, "Account Creation Date");
-        addField(EMAIL_VALIDATION_CODE, "varchar", 30, true, "Validation code for Email");
-
-        //Set up the string filters.
-        setStringFilter(USERNAME, "stripFilter");
-
-        //Nobody should even put special characters here
-        setStringFilter(EMAIL, "stripFilter");
-
-        //Nobody should even put special characters here
-        setStringFilter(PASSWORD, "rawFilter");
-
-        //Must all all characters through or Password gets mucked up.
-        setStringFilter(LASTNAME, "stripFilter");
-
-        //Nobody should even put special characters here
-        setStringFilter("FirstName", "stripFilter");
-
-        //Nobody should even put special characters here
-        setStringFilter(DESCRIPTION, "rawFilter");
-
-        //The default for the field anyway, but included for completeness' sake
-        setStringFilter(EMAIL_VALIDATION_CODE, "stripFilter");
-
-        //This only has HEX strings.. no special chars
-        addKey(EXPUID);
-        addIndex("UserDBObjUserName", USERNAME, true);
-        setSecret(PASSWORD);
-        setSecret(EMAIL_VALIDATION_CODE);
-        setMultiValued(ACCOUNT_STATUS);
-        setReadOnly(CREATION_DATE);
-    } /* setupFields() */
-
-    public void setUserName(String name)
-            throws DBException {
-        setField(DESCRIPTION, name);
-    }
-
-    /**
-     *
-     *
-     * @throws  DBException
-     */
-    public void update()
-            throws DBException {
-
-        // If a User is added without a status, we set the AccountStatus to "I"
-        // for security reasons
-        if (getField(ACCOUNT_STATUS).equals("")) {
-            setField(ACCOUNT_STATUS, "I");
-        }
-        // We should always have a CreateDate
-        if (getField(CREATION_DATE).equals("")) {
-            setField(CREATION_DATE, DateTime.getDateTimeForDB(this.getDataContext()));
-        }
-
-        super.update();
-        User user = new User();
-        user.setDataContext(this.getDataContext());
-        user.updateNotify(this);
-
-    } /* update() */
-
-
-    public String getPrimaryGroup()
-            throws DBException {
-        return null;
-    }
-} /* UserDBObj */


More information about the cvs mailing list