📄 loginaction.java
字号:
/*
* Created on 2004-5-12
*
*/
package com.esimple.service.rbac.action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import com.esimple.framework.web.action.BaseAction;
import com.esimple.framework.web.action.BaseForm;
import com.esimple.service.rbac.login.*;
import com.esimple.service.rbac.Constants;
import com.esimple.service.rbac.po.Operator;
/**
* @author steven
*
*/
public class LoginAction extends BaseAction {
private List interceptors = new ArrayList();
private Authentication authModule;
private int retryTimes = -1;
public void setRetryTimes(int retryTimes) {
this.retryTimes = retryTimes;
}
public void setInterceptors(List interceptors) {
this.interceptors = interceptors;
}
public List getInterceptors() {
return this.interceptors;
}
public void setAuthModule(Authentication authModule) {
this.authModule = authModule;
}
public Authentication getAuthModule() {
return this.authModule;
}
public String execute(
BaseForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
String info = null;
ActionErrors errors = new ActionErrors();
try {
String loginID =
form.getValueAsString(Constants.INPUT_LOGINID, true);
String password =
form.getValueAsString(Constants.INPUT_PASSWD, true);
//errors = new ActionErrors();
if (loginID == null) {
errors.add(
ActionErrors.GLOBAL_ERROR,
new ActionError("error.login.nologinid"));
saveErrors(request, errors);
return FORWARD_FAILURE;
}
Operator oper = new Operator();
oper.setLoginid(loginID);
if (authModule.login(oper, password)) {
doInterceptor(form, request);
} else {
errors.add(
ActionErrors.GLOBAL_ERROR,
new ActionError("error.login"));
saveErrors(request, errors);
return FORWARD_FAILURE;
}
} catch (Exception e) {
e.printStackTrace();
errors.add(
ActionErrors.GLOBAL_ERROR,
new ActionError("error.login.exception"));
saveErrors(request, errors);
return FORWARD_FAILURE;
}
return FORWARD_SUCCESS;
}
private void doInterceptor(BaseForm form, HttpServletRequest request)
throws Exception {
for (int i = 0; i < interceptors.size(); i++) {
Object it = interceptors.get(i);
if (it == null)
continue;
if (it instanceof LoginInterceptor) {
((LoginInterceptor) it).onLogin(form, request);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -