View Javadoc

1   /*
2    * Joey and its relative products are published under the terms
3    * of the Apache Software License.
4    */
5   /*
6    * Created on 2004/01/12
7    */
8   package org.asyrinx.joey.tapestry.components.stative;
9   
10  import org.apache.tapestry.ApplicationRuntimeException;
11  import org.apache.tapestry.BaseComponent;
12  import org.apache.tapestry.IRequestCycle;
13  import org.asyrinx.brownie.core.user.IUser;
14  import org.asyrinx.brownie.core.user.LoginManager;
15  
16  /***
17   * @author akima
18   */
19  public abstract class LoginForm extends BaseComponent {
20  
21  	private String userId = null;
22  	private String password = null;
23  
24  	public void formSubmit(IRequestCycle cycle) {
25  		final LoginManager loginManager =
26  			new LoginManager(this.getUserCertifierClassName());
27  		final IUser user = loginManager.tryLogin(getUserId(), getPassword());
28  		if (cycle.getPage().getVisit() instanceof BaseVisit) {
29  			final BaseVisit visit = (BaseVisit) cycle.getPage().getVisit();
30  			visit.setLoginUser(user);
31  		} else {
32  			throw new ApplicationRuntimeException("Visit must be extended BaseVisit");
33  		}
34  		cycle.activate(getPage());
35  	}
36  
37  	/***
38  	 * @return
39  	 */
40  	public String getPassword() {
41  		return password;
42  	}
43  
44  	/***
45  	 * @return
46  	 */
47  	public String getUserId() {
48  		return userId;
49  	}
50  
51  	/***
52  	 * @param string
53  	 */
54  	public void setPassword(String string) {
55  		password = string;
56  	}
57  
58  	/***
59  	 * @param string
60  	 */
61  	public void setUserId(String string) {
62  		userId = string;
63  	}
64  
65  	abstract public String getUserCertifierClassName();
66  	abstract public void setUserCertifierClassName(String string);
67  
68  }