commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hus...@apache.org
Subject cvs commit: jakarta-commons-sandbox/chain/apps/mailreader/src/java/org/apache/commons/chain/mailreader/commands LogonUser.java
Date Thu, 01 Apr 2004 03:38:22 GMT
husted      2004/03/31 19:38:22

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

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message