81,092
社区成员
发帖
与我相关
我的任务
分享
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
// token是用户输入的用户名和密码
// 第一步从token中取出用户名
String userCode = (String) token.getPrincipal();
SmbmsUser findUser=null;
try {
findUser= smbmsUser.findUser(userCode);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (findUser==null) {
return null;
}
String userpassword = findUser.getUserpassword();
String salt = findUser.getSalt();
SmbmsUserPO smbmsUserPO = new SmbmsUserPO();
smbmsUserPO.setId(findUser.getId());
smbmsUserPO.setUsercode(findUser.getUsercode());
smbmsUserPO.setUsername(findUser.getUsername());
List<SysPermission> findMenuListByUserId =null;
try {
findMenuListByUserId = sysPermissionService.findMenuListByUserId(String.valueOf(findUser.getId()));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//将用户菜单 设置到activeUser
smbmsUserPO.setMenus(findMenuListByUserId);
SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo(smbmsUserPO, userpassword, ByteSource.Util.bytes(salt), this.getName());
return simpleAuthenticationInfo;
}