use of com.easy.cloud.core.authority.pojo.dto.EcAuthorityUserDTO in project dq-easy-cloud by dq-open-cloud.
the class EcAuthorityRealm method doGetAuthorizationInfo.
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
EcAuthorityUserDTO<Long> authorityUserDTO = (EcAuthorityUserDTO) principals.getPrimaryPrincipal();
List<SysRoleDTO> roleList = sysRoleService.findByUserId(authorityUserDTO.getAuthorityUserId());
Set<Integer> roleNos = new HashSet<>();
for (SysRoleDTO role : roleList) {
authorizationInfo.addRole(role.getName());
roleNos.add(role.getRoleNo());
}
List<SysResourceDTO> roleResourceDTOs = sysResourceService.findByRoleNos(new ArrayList<>(roleNos));
for (SysResourceDTO resourceDTO : roleResourceDTOs) {
authorizationInfo.addStringPermission(resourceDTO.getPermission());
}
return authorizationInfo;
}
use of com.easy.cloud.core.authority.pojo.dto.EcAuthorityUserDTO in project dq-easy-cloud by dq-open-cloud.
the class EcAuthorityRealm method doGetAuthenticationInfoPassword.
/**
* <p>
* 使用账号密码的方式登录
* </p>
*
* @param token
* @return org.apache.shiro.authc.AuthenticationInfo
* @author daiqi
* @date 2018/6/29 17:50
*/
protected AuthenticationInfo doGetAuthenticationInfoPassword(AuthenticationToken token) {
// 获取用户的输入的账号.
String username = (String) token.getPrincipal();
EcAuthorityUserDTO authorityUserDTO = sysUserService.findByUsername(username);
// 账户冻结
if (authorityUserDTO.getLocked() == 1) {
throw new LockedAccountException();
}
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(authorityUserDTO, authorityUserDTO.getPassword(), ByteSource.Util.bytes(authorityUserDTO.getSalt()), authorityUserDTO.getAuthCacheKey());
return authenticationInfo;
}
Aggregations