My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package action;

import java.security.NoSuchAlgorithmException;
import java.util.NoSuchElementException;

import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.HandlesEvent;
import net.sourceforge.stripes.action.RedirectResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.UrlBinding;
import net.sourceforge.stripes.validation.LocalizableError;
import net.sourceforge.stripes.validation.Validate;
import net.sourceforge.stripes.validation.ValidationErrors;
import net.sourceforge.stripes.validation.ValidationMethod;
import example.model.User;

@UrlBinding("/blog/login")
public class LoginAction extends BaseAction {

@Validate(required = true, minlength = 1, maxlength = 255, on = "login")
private String screenName;

@Validate(required = true, minlength = 1, maxlength = 255, on = "login")
private String password;

@ValidationMethod(on = "login")
public void validateLogin(ValidationErrors errors) throws NoSuchAlgorithmException {
String e = hashPassword(password);
try {
User user = new User();
user = pm().find(user).where(user.screenName).is(screenName).result();
if (user==null || !e.equals(user.getEncryptedPassword()) )
errors.addGlobalError(new LocalizableError("loginmsg"));
else
context.setLogin(user);
} catch (NoSuchElementException exp) {
errors.addGlobalError(new LocalizableError("loginmsg"));
}
}

@DefaultHandler
public Resolution start() {
return new ForwardResolution("/login.jsp");
}

@HandlesEvent("login")
public Resolution login() {
return new RedirectResolution(HubAction.class);
}

public String getScreenName() {
return screenName;
}

public void setScreenName(String screenName) {
this.screenName = screenName;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}


}

Change log

r98 by thewebsemantic on Dec 9, 2009   Diff
[No log message]
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 2050 bytes, 69 lines
Powered by Google Project Hosting