| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
package org.chenillekit.access.components; |
| 16 | |
|
| 17 | |
import org.apache.tapestry5.ValidationTracker; |
| 18 | |
import org.apache.tapestry5.annotations.ApplicationState; |
| 19 | |
import org.apache.tapestry5.annotations.Component; |
| 20 | |
import org.apache.tapestry5.annotations.Property; |
| 21 | |
import org.apache.tapestry5.corelib.components.Form; |
| 22 | |
import org.apache.tapestry5.ioc.Messages; |
| 23 | |
import org.apache.tapestry5.ioc.annotations.Inject; |
| 24 | |
import org.apache.tapestry5.ioc.annotations.Local; |
| 25 | |
import org.chenillekit.access.ChenilleKitAccessConstants; |
| 26 | |
import org.chenillekit.access.WebSessionUser; |
| 27 | |
import org.chenillekit.access.services.AuthenticationService; |
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | 1 | public class Login |
| 35 | |
{ |
| 36 | |
@ApplicationState |
| 37 | |
private WebSessionUser webSessionUser; |
| 38 | |
|
| 39 | |
@Inject |
| 40 | |
private Messages messages; |
| 41 | |
|
| 42 | |
@Inject @Local |
| 43 | |
private AuthenticationService authenticationService; |
| 44 | |
|
| 45 | |
@Component |
| 46 | |
private Form chenillekitLoginForm; |
| 47 | |
|
| 48 | |
@Property |
| 49 | |
private String username; |
| 50 | |
|
| 51 | |
@Property |
| 52 | |
private String password; |
| 53 | |
|
| 54 | |
private WebSessionUser tmpUser; |
| 55 | |
|
| 56 | |
void onValidateForm() |
| 57 | |
{ |
| 58 | 1 | ValidationTracker tracker = chenillekitLoginForm.getDefaultTracker(); |
| 59 | |
|
| 60 | 1 | tmpUser = authenticationService.doAuthenticate(username, password); |
| 61 | |
|
| 62 | 1 | if (tmpUser == null) |
| 63 | 0 | tracker.recordError(messages.format(ChenilleKitAccessConstants.NOT_AUTHENTICATED_ERROR_MESSAGE, username)); |
| 64 | |
|
| 65 | 1 | } |
| 66 | |
|
| 67 | |
void onFailure() |
| 68 | |
{ |
| 69 | |
|
| 70 | 0 | } |
| 71 | |
|
| 72 | |
void onSuccess() |
| 73 | |
{ |
| 74 | 1 | webSessionUser = tmpUser; |
| 75 | 1 | } |
| 76 | |
|
| 77 | |
} |