| | |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.User; |
| | | import com.yuanchu.limslaboratory.service.UserService; |
| | | import com.yuanchu.limslaboratory.utils.MyUtils; |
| | | import com.yuanchu.limslaboratory.utils.SpringUtils; |
| | | import com.yuanchu.limslaboratory.utils.SpringUtil; |
| | | import org.apache.shiro.authc.*; |
| | | import org.apache.shiro.authc.credential.CredentialsMatcher; |
| | | import org.apache.shiro.authz.AuthorizationInfo; |
| | | import org.apache.shiro.realm.AuthorizingRealm; |
| | | import org.apache.shiro.subject.PrincipalCollection; |
| | |
| | | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) { |
| | | String principal = (String) authenticationToken.getPrincipal(); |
| | | //获取UserService对象 |
| | | UserService userService = SpringUtils.getBean(UserService.class); |
| | | UserService userService = SpringUtil.getBean(UserService.class); |
| | | user = userService.AccordingUsernameSelectAll(principal); |
| | | MyUtils.PrintLog(user.toString()); |
| | | if (!ObjectUtils.isEmpty(user)) { |
| | | return new SimpleAuthenticationInfo(user.getAccount(), user.getPassword(), this.getName()); |
| | | } else { |
| | | throw new UnknownAccountException(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) { |
| | | // HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher(); |
| | | // //设置使用MD5加密算法 |
| | | // hashedCredentialsMatcher.setHashAlgorithmName(Md5Hash.ALGORITHM_NAME); |
| | | // //散列次数 |
| | | // hashedCredentialsMatcher.setHashIterations(1024); |
| | | // super.setCredentialsMatcher(hashedCredentialsMatcher); |
| | | super.setCredentialsMatcher(credentialsMatcher); |
| | | } |
| | | } |