use of com.cdeledu.common.base.AjaxJson in project wechat by dllwh.
the class ShiroHelper method login.
/**
* ----------------------------------------------------- Fields end
*/
public static AjaxJson login(String userName, String passWord) {
// 用户名密码令牌
UsernamePasswordToken token = new UsernamePasswordToken(userName, passWord);
token.setRememberMe(false);
String logMsg = "", resultMsg = "";
AjaxJson ajaxJson = new AjaxJson();
boolean suc = false;
// 获得当前登录用户对象Subject,现在状态为 “未认证”
Subject subject = SecurityUtils.getSubject();
try {
subject.login(token);
} catch (UnknownAccountException uae) {
logMsg = "对用户[" + userName + "]进行登录验证..验证未通过,未知账户";
resultMsg = MessageConstant.LOGIN_USER_UNKNOWN;
} catch (IncorrectCredentialsException ice) {
logMsg = "对用户[" + userName + "]进行登录验证..验证未通过,错误的凭证";
resultMsg = MessageConstant.LOGIN_USER_REEOE;
} catch (LockedAccountException lae) {
logMsg = "对用户[" + userName + "]进行登录验证..验证未通过,账户已锁定";
resultMsg = MessageConstant.LOGIN_USER_LOCK;
} catch (DisabledAccountException dae) {
logMsg = "对用户[" + userName + "]进行登录验证..验证未通过,帐号已被禁用";
resultMsg = MessageConstant.LOGIN_USER_DISABLED;
} catch (ExpiredCredentialsException ece) {
logMsg = "对用户[" + userName + "]进行登录验证..验证未通过,帐号已过期";
resultMsg = MessageConstant.LOGIN_USER_EXPIRED;
} catch (ExcessiveAttemptsException eae) {
logMsg = "对用户[" + userName + "]进行登录验证..验证未通过,用户名或密码错误次数过多";
resultMsg = MessageConstant.LOGIN_USER_MORE;
} catch (UnauthorizedException e) {
logMsg = "对用户[" + userName + "]进行登录验证..验证未通过,您没有得到相应的授权!";
resultMsg = MessageConstant.LOGIN_USER_UNAUTHORIZED;
} catch (AuthenticationException ae) {
logMsg = "对用户[" + userName + "]进行登录验证..验证未通过," + ae.getMessage();
resultMsg = MessageConstant.LOGIN_ERROR;
}
if (subject.isAuthenticated()) {
logMsg = "对用户[" + userName + "]进行登录验证..验证通过";
suc = true;
} else {
token.clear();
}
ajaxJson.setSuccess(suc);
ajaxJson.setMsg(resultMsg);
ajaxJson.setObj(logMsg);
return ajaxJson;
}
use of com.cdeledu.common.base.AjaxJson in project wechat by dllwh.
the class IconController method saveIcon.
/**
* @方法描述: 上传图标
* @创建者: 皇族灬战狼
* @创建时间: 2016年9月22日 下午2:18:32
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "saveIcon")
@ResponseBody
public AjaxJson saveIcon(HttpServletRequest request) throws Exception {
AjaxJson result = new AjaxJson();
message = "上传成功";
result.setMsg(message);
// String css = ".back{background:url('../images/back.png') no-repeat;}";
return result;
}
use of com.cdeledu.common.base.AjaxJson in project wechat by dllwh.
the class IconController method initIcon.
@RequestMapping(value = "initIcon")
@ResponseBody
public AjaxJson initIcon() {
AjaxJson result = new AjaxJson();
try {
result.setMsg("数据初始化成功");
Map<String, String> filePathMap = Maps.newConcurrentMap();
ClassLoader baseUrl = Thread.currentThread().getContextClassLoader();
filePathMap.put("bootstrap", baseUrl.getResource("bootstrapIconInfo/bootstrap.css").getPath());
filePathMap.put("fontAwesome", baseUrl.getResource("bootstrapIconInfo/font-awesome.css").getPath());
filePathMap.put("simpleLine", baseUrl.getResource("bootstrapIconInfo/simple-line-icons.css").getPath());
List<Map<String, String>> resultList = BootstrapHelper.getBootstrapIconInfo(filePathMap);
SysIcon sysIcon = null;
for (Map<String, String> map : resultList) {
try {
sysIcon = new SysIcon();
sysIcon.setDisplayName(map.get("displayName"));
sysIcon.setSourceType(map.get("sourceType"));
if (sysIconService.findOneForJdbc(sysIcon) != null) {
sysIcon.setClassName(map.get("className"));
sysIconService.insert(sysIcon);
}
} catch (Exception e) {
continue;
}
}
} catch (Exception e) {
result.setMsg("数据初始化失败,原因" + e.getMessage());
result.setSuccess(false);
}
return result;
}
use of com.cdeledu.common.base.AjaxJson in project wechat by dllwh.
the class LoginController method checkuser.
/**
* ----------------------------------------------------- Fields end
*/
/**
* @方法:登陆验证
* @创建人:独泪了无痕
* @param user
* @return
*/
@RequestMapping(params = "checkuser")
@ResponseBody
public AjaxJson checkuser(HttpServletRequest request, SysUser user) {
AjaxJson reslutMsg = new AjaxJson();
HttpSession session = WebUtilHelper.getSession();
// Session session = ShiroHelper.getSession();
boolean suc = true;
String logMsg = "";
String userName = user.getUserName().trim();
try {
String password = PasswordUtil.encrypt(userName, user.getPassword().trim());
AjaxJson loginResult = ShiroHelper.login(userName, password);
int loginStatus = 2;
if (loginResult.isSuccess()) {
loginStatus = 1;
session.removeAttribute(GlobalConstants.IMAGECAPTCHA);
} else {
logMsg = loginResult.getMsg();
suc = false;
}
try {
LogManager.getInstance().executeLog(LogTaskFactory.loginLog(userName, String.valueOf(loginResult.getObj()), loginStatus, getIp(request), getBrowser(request)));
} catch (Exception e) {
}
} catch (Exception e) {
logMsg = "用户名或密码错误,请重新登录!";
suc = false;
}
reslutMsg.setMsg(logMsg);
reslutMsg.setSuccess(suc);
return reslutMsg;
}
use of com.cdeledu.common.base.AjaxJson in project wechat by dllwh.
the class LoginController method register.
/**
* 注册跳转
*
* @return
*/
@RequestMapping(value = "register", method = RequestMethod.GET)
public AjaxJson register(SysUser user) {
AjaxJson result = new AjaxJson();
boolean namestander = user.getUserName().trim().startsWith("qq") || user.getUserName().trim().startsWith("sina") || user.getUserName().trim().startsWith("github") || user.getUserName().trim().startsWith("baidu") || user.getUserName().trim().startsWith("weixin");
if (namestander) {
result.setSuccess(false);
result.setMsg("不能以qq、sina、weixin、baidu、github 开头注册");
return result;
}
return result;
}
Aggregations