Source code: org/sbugs/forms/LoginForm.java
1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; version 2 only.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
14 */
15 package org.sbugs.forms;
16
17 import javax.servlet.http.*;
18 import org.apache.struts.action.*;
19
20 public class LoginForm extends ActionForm
21 {
22 private String username;
23 private String password;
24 private String attemptedResource;
25
26 public LoginForm()
27 {
28 }
29
30 public String getAttemptedResource()
31 {
32 return attemptedResource;
33 }
34
35 public void setAttemptedResource( String resource )
36 {
37 attemptedResource = resource;
38 }
39
40 public String getUsername()
41 {
42 return username;
43 }
44
45 public void setUsername( String name )
46 {
47 username = name;
48 }
49
50 public String getPassword()
51 {
52 return password;
53 }
54
55 public void setPassword( String passwordParam )
56 {
57 password = passwordParam;
58 }
59
60 public ActionErrors validate( ActionMapping mapping, HttpServletRequest request )
61 {
62 ActionErrors errors = new ActionErrors();
63 if( getPassword() == null
64 || "".equals( getPassword() ) )
65 {
66 errors.add( "password", new ActionError( "missing.password" ) );
67 }
68 if( getUsername() == null
69 || "".equals( getPassword() ) )
70 {
71 errors.add( "username", new ActionError( "missing.username" ) );
72 }
73
74 return errors;
75 }
76
77 public boolean ready()
78 {
79 return ( getPassword() != null
80 && getUsername() != null );
81 }
82 }