@@ -0,0 +1,2028 @@
+/*%0A * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/commands/LogonUser.java,v 1.1 2004/04/01 03:38:22 husted Exp $%0A * $Revision: 1.1 $%0A * $Date: 2004/04/01 03:38:22 $%0A *%0A * Copyright 2000-2004 Apache Software Foundation%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.apache.commons.chain.mailreader.commands;%0A%0Aimport org.apache.commons.chain.Command;%0Aimport org.apache.commons.chain.Context;%0Aimport org.apache.commons.chain.mailreader.MailReader;%0Aimport org.apache.struts.webapp.example.User;%0Aimport org.apache.struts.webapp.example.UserDatabase;%0A%0A/**%0A * Find username in database, confirm credentials, and set as current user.%0A */%0Apublic class LogonUser implements Command %7B%0A%0A    static boolean isBlank(String string) %7B%0A        return ((string == null) %7C%7C (string.trim().length() == 0));%0A    %7D%0A%0A    public boolean execute(Context context) throws Exception %7B%0A%0A        MailReader app = (MailReader) context;%0A        Context input = app.getInput();%0A        String username = (String) input.get(MailReader.PN_USERNAME);%0A        String password = (String) input.get(MailReader.PN_PASSWORD);%0A        UserDatabase database = app.getDatabase();%0A        User user = database.findUser(username);%0A        if (null != user) %7B%0A            String dbPassword = user.getPassword();%0A            if (!password.equals(dbPassword)) user = null;%0A        %7D%0A%0A        app.setUser(user);%0A%0A        return false;%0A    %7D%0A%7D%0A

Add LogonUser command