use of cn.cerc.jmis.form.AbstractForm in project summer-mis by cn-cerc.
the class AppLoginPage method checkLogin.
@Override
public boolean checkLogin(String userCode, String password) throws ServletException, IOException {
IForm form = this.getForm();
HttpServletRequest req = this.getRequest();
log.debug(String.format("校验用户帐号(%s)与密码", userCode));
// 进行设备首次登记
String deviceId = form.getClient().getId();
req.setAttribute("userCode", userCode);
req.setAttribute("password", password);
req.setAttribute("needVerify", "false");
// 如长度大于10表示用手机号码登入
if (userCode.length() > 10) {
String oldCode = userCode;
userCode = getAccountFromTel(form.getHandle(), oldCode);
log.debug(String.format("将手机号 %s 转化成帐号 %s", oldCode, userCode));
}
boolean result = false;
log.debug(String.format("进行用户帐号(%s)与密码认证", userCode));
// 进行用户名、密码认证
LocalService app;
if (form instanceof AbstractForm)
app = new LocalService((AbstractForm) form);
else
app = new LocalService(form.getHandle());
app.setService("SvrUserLogin.check");
String IP = getIPAddress();
if (app.exec("Account_", userCode, "Password_", password, "MachineID_", deviceId, "ClientIP_", IP, "Language_", form.getClient().getLanguage())) {
String sid = app.getDataOut().getHead().getString("SessionID_");
if (sid != null && !sid.equals("")) {
log.debug(String.format("认证成功,取得sid(%s)", sid));
((ClientDevice) this.getForm().getClient()).setSid(sid);
result = true;
}
} else {
// 登陆验证失败,进行判断,手机号为空,则回到登陆页,手机不为空,密码为空,则跳到发送验证码页面
String mobile = Utils.safeString(app.getDataOut().getHead().getString("Mobile_"));
if (mobile == null || "".equals(mobile)) {
log.debug(String.format("用户帐号(%s)与密码认证失败", userCode));
req.setAttribute("loginMsg", app.getMessage());
this.execute();
} else if (password == null || "".equals(password)) {
getResponse().sendRedirect("TFrmEasyReg?phone=" + mobile);
return false;
} else {
log.debug(String.format("用户帐号(%s)与密码认证失败", userCode));
req.setAttribute("loginMsg", app.getMessage());
this.execute();
}
}
return result;
}
use of cn.cerc.jmis.form.AbstractForm in project summer-mis by cn-cerc.
the class SecurityEnvironment method check.
// 用于Service中,检查若当前环境不安全时,需要检查 验证码是否正确
public static void check(AbstractHandle service) throws DataValidateException {
if (!(service.getHandle() instanceof AbstractForm)) {
log.error("程序调用错误,需要修正!");
DataValidateException.stopRun(R.asString(service, "程序调用错误,需要修正!"), true);
}
AbstractForm form = (AbstractForm) service.getHandle();
if (isSecurity(form)) {
return;
}
safetyCheck(form);
}
use of cn.cerc.jmis.form.AbstractForm in project summer-mis by cn-cerc.
the class UIPagePhone method execute.
@Override
public void execute() throws ServletException, IOException {
HttpServletRequest request = getRequest();
IForm form = this.getForm();
CustomHandle sess = (CustomHandle) form.getHandle().getProperty(null);
if (sess.logon()) {
List<UrlRecord> rightMenus = getHeader().getRightMenus();
RightMenus menus = Application.getBean("RightMenus", RightMenus.class);
menus.setHandle(form.getHandle());
for (IMenuBar item : menus.getItems()) item.enrollMenu(form, rightMenus);
} else {
getHeader().getHomePage().setSite(Application.getAppConfig().getFormWelcome());
}
// 系统通知消息
Component content = this.getContent();
if (form instanceof AbstractForm) {
this.getHeader().initHeader();
request.setAttribute(content.getId(), content);
for (Component component : content.getComponents()) {
request.setAttribute(component.getId(), component);
}
}
// 开始输出
PrintWriter out = getResponse().getWriter();
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.printf("<title>%s</title>\n", this.getForm().getTitle());
out.printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n");
out.printf("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n");
out.println("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=9; IE=8; IE=7;\"/>");
out.printf("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0\"/>\n");
out.print(this.getCssHtml());
out.print(getScriptHtml());
out.println("<script>");
out.println("var Application = new TApplication();");
out.printf("Application.device = '%s';\n", form.getClient().getDevice());
out.printf("Application.bottom = '%s';\n", this.getFooter().getId());
String msg = form.getParam("message", "");
msg = msg == null ? "" : msg.replaceAll("\r\n", "<br/>");
out.printf("Application.message = '%s';\n", msg);
out.printf("Application.searchFormId = '%s';\n", this.searchWaitingId);
out.println("$(document).ready(function() {");
out.println("Application.init();");
out.println("});");
out.println("</script>");
out.println("</head>");
outBody(out);
out.println("</html>");
}
use of cn.cerc.jmis.form.AbstractForm in project summer-mis by cn-cerc.
the class UIPageDialog method execute.
@Override
public void execute() throws ServletException, IOException {
// 此行代码不能删除!
this.getFooter();
IForm form = this.getForm();
HttpServletRequest request = form.getRequest();
CustomHandle sess = (CustomHandle) form.getHandle().getProperty(null);
request.setAttribute("passport", sess.logon());
request.setAttribute("logon", sess.logon());
if (sess.logon()) {
List<UrlRecord> rightMenus = getHeader().getRightMenus();
RightMenus menus = Application.getBean("RightMenus", RightMenus.class);
menus.setHandle(form.getHandle());
for (IMenuBar item : menus.getItems()) item.enrollMenu(form, rightMenus);
} else {
getHeader().getHomePage().setSite(Application.getAppConfig().getFormWelcome());
}
// 设置首页
request.setAttribute("_showMenu_", "true".equals(form.getParam("showMenus", "true")));
// 系统通知消息
if (request.getAttribute("message") == null)
request.setAttribute("message", "");
if (form instanceof AbstractForm) {
if (this.isShowMenus())
this.getHeader().initHeader();
}
String msg = form.getParam("message", "");
request.setAttribute("msg", msg == null ? "" : msg.replaceAll("\r\n", "<br/>"));
request.setAttribute("formno", form.getParam("formNo", "000"));
request.setAttribute("form", form);
// 添加分页控制
Component operaPages = null;
if (pages != null) {
this.put("pages", pages);
operaPages = new OperaPages(this.getToolBar(), this.getForm(), pages);
this.put("_operaPages_", operaPages);
}
// 输出jsp模版
String url = String.format("/WEB-INF/%s/%s", Application.getAppConfig().getPathForms(), this.getViewFile());
getRequest().getServletContext().getRequestDispatcher(url).forward(getRequest(), getResponse());
}
use of cn.cerc.jmis.form.AbstractForm in project summer-mis by cn-cerc.
the class UIPageModify method execute.
@Override
public void execute() throws ServletException, IOException {
HttpServletRequest request = getRequest();
IForm form = this.getForm();
CustomHandle sess = (CustomHandle) form.getHandle().getProperty(null);
if (sess.logon()) {
List<UrlRecord> rightMenus = getHeader().getRightMenus();
RightMenus menus = Application.getBean("RightMenus", RightMenus.class);
menus.setHandle(form.getHandle());
for (IMenuBar item : menus.getItems()) item.enrollMenu(form, rightMenus);
} else {
getHeader().getHomePage().setSite(Application.getAppConfig().getFormWelcome());
}
// 系统通知消息
Component content = this.getContent();
if (form instanceof AbstractForm) {
this.getHeader().initHeader();
request.setAttribute(content.getId(), content);
for (Component component : content.getComponents()) {
request.setAttribute(component.getId(), component);
}
}
// 开始输出
PrintWriter out = getResponse().getWriter();
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.printf("<title>%s</title>\n", this.getForm().getTitle());
out.printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n");
out.println("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=9; IE=8; IE=7;\"/>");
out.printf("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0\"/>\n");
out.print(this.getCssHtml());
out.print(getScriptHtml());
out.println("<script>");
out.println("var Application = new TApplication();");
out.printf("Application.device = '%s';\n", form.getClient().getDevice());
out.printf("Application.bottom = '%s';\n", this.getFooter().getId());
String msg = form.getParam("message", "");
msg = msg == null ? "" : msg.replaceAll("\r\n", "<br/>");
out.printf("Application.message = '%s';\n", msg);
out.printf("Application.searchFormId = '%s';\n", this.searchWaitingId);
out.println("$(document).ready(function() {");
out.println("Application.init();");
out.println("});");
out.println("</script>");
out.println("</head>");
outBody(out);
out.println("</html>");
}
Aggregations