Search in sources :

Example 6 with AgileBaseUser

use of com.jeeagile.core.security.user.AgileBaseUser in project jeeagile by jeeagile.

the class AgileSpringSecurity method userLogout.

@Override
public void userLogout() {
    AgileBaseUser userData = getUserData();
    if (userData != null && AgileStringUtil.isNotEmpty(userData.getUserId())) {
        AgileCacheUtil.evict(AgileCacheConstants.AGILE_CACHE_SESSION_NAME, userData.getUserToken());
        sessionRegistry.removeSessionInformation(userData.getUserToken());
    }
}
Also used : AgileBaseUser(com.jeeagile.core.security.user.AgileBaseUser)

Example 7 with AgileBaseUser

use of com.jeeagile.core.security.user.AgileBaseUser in project jeeagile by jeeagile.

the class AgileSysPersonServiceImpl method updatePersonInfo.

@Override
public boolean updatePersonInfo(AgileUpdatePerson agileUpdatePerson) {
    AgileBaseUser userData = getCurrentUserData();
    AgileSysUser agileSysUser = new AgileSysUser();
    BeanUtils.copyProperties(agileUpdatePerson, agileSysUser);
    agileSysUser.setId(userData.getUserId());
    return agileSysUserService.updateById(agileSysUser);
}
Also used : AgileSysUser(com.jeeagile.system.entity.AgileSysUser) AgileBaseUser(com.jeeagile.core.security.user.AgileBaseUser)

Example 8 with AgileBaseUser

use of com.jeeagile.core.security.user.AgileBaseUser in project jeeagile by jeeagile.

the class AgileSysPersonServiceImpl method updatePersonPwd.

@Override
public boolean updatePersonPwd(AgileUpdatePwd agileUpdatePwd) {
    AgileBaseUser userData = getCurrentUserData();
    AgileSysUser oldSysUser = agileSysUserService.getById(userData.getUserId());
    String oldUserPwd = AgileSecurityUtil.encryptPassword(agileUpdatePwd.getOldPwd());
    String newUserPwd = AgileSecurityUtil.encryptPassword(agileUpdatePwd.getNewPwd());
    if (oldSysUser.getUserPwd().equals(oldUserPwd)) {
        AgileSysUser newSysUser = new AgileSysUser();
        newSysUser.setId(oldSysUser.getId());
        newSysUser.setUserPwd(newUserPwd);
        return agileSysUserService.updateById(newSysUser);
    } else {
        throw new AgileValidateException("输入的老密码有误,请确认!");
    }
}
Also used : AgileValidateException(com.jeeagile.core.exception.AgileValidateException) AgileSysUser(com.jeeagile.system.entity.AgileSysUser) AgileBaseUser(com.jeeagile.core.security.user.AgileBaseUser)

Example 9 with AgileBaseUser

use of com.jeeagile.core.security.user.AgileBaseUser in project jeeagile by jeeagile.

the class AgileSysPersonServiceImpl method getPersonInfo.

@Override
public AgilePersonInfo getPersonInfo() {
    AgilePersonInfo agilePersonInfo = new AgilePersonInfo();
    AgileBaseUser userData = getCurrentUserData();
    AgileSysUser agileSysUser = agileSysUserService.getById(userData.getUserId());
    if (agileSysUser != null && AgileStringUtil.isNotEmpty(agileSysUser.getId())) {
        BeanUtils.copyProperties(agileSysUser, agilePersonInfo);
        agilePersonInfo.setDeptName(userData.getDeptName());
        List<String> roleNameList = agileSysPersonMapper.getRoleNameByUserId(agileSysUser.getId());
        List<String> postNameList = agileSysPersonMapper.getPostNameByUserId(agileSysUser.getId());
        agilePersonInfo.setRoleNameList(roleNameList);
        agilePersonInfo.setPostNameList(postNameList);
    }
    return agilePersonInfo;
}
Also used : AgilePersonInfo(com.jeeagile.system.vo.AgilePersonInfo) AgileSysUser(com.jeeagile.system.entity.AgileSysUser) AgileBaseUser(com.jeeagile.core.security.user.AgileBaseUser)

Example 10 with AgileBaseUser

use of com.jeeagile.core.security.user.AgileBaseUser in project jeeagile by jeeagile.

the class AgileAuthorizingRealm method doGetAuthorizationInfo.

/**
 * 用户授权
 *
 * @param principalCollection
 * @return
 */
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
    try {
        AgileBaseUser userData = (AgileBaseUser) principalCollection.getPrimaryPrincipal();
        if (userData == null || AgileStringUtil.isEmpty(userData.getUserId())) {
            throw new AgileAuthException(AgileResultCode.FAIL_USER_INFO);
        }
        SimpleAuthorizationInfo authenticationInfo = new SimpleAuthorizationInfo();
        List<String> userPermList = userData.getUserPerm();
        if (userPermList == null || userPermList.isEmpty()) {
            userPermList = agileUserDetailsService.getUserPerm(userData);
            userData.setUserPerm(userPermList);
        }
        authenticationInfo.addStringPermissions(userPermList);
        List<String> userRoleList = userData.getUserRole();
        if (userRoleList == null || userRoleList.isEmpty()) {
            userRoleList = agileUserDetailsService.getUserRole(userData);
            userData.setUserRole(userRoleList);
        }
        authenticationInfo.addRoles(userRoleList);
        return authenticationInfo;
    } catch (AgileBaseException ex) {
        throw ex;
    } catch (Exception ex) {
        throw new AgileAuthException(AgileResultCode.FAIL_AUTH_EXCEPTION, ex.getMessage());
    }
}
Also used : SimpleAuthorizationInfo(org.apache.shiro.authz.SimpleAuthorizationInfo) AgileBaseException(com.jeeagile.core.exception.AgileBaseException) AgileBaseUser(com.jeeagile.core.security.user.AgileBaseUser) AgileAuthException(com.jeeagile.core.exception.AgileAuthException) AgileAuthException(com.jeeagile.core.exception.AgileAuthException) AgileFrameException(com.jeeagile.core.exception.AgileFrameException) AgileBaseException(com.jeeagile.core.exception.AgileBaseException)

Aggregations

AgileBaseUser (com.jeeagile.core.security.user.AgileBaseUser)10 AgileAuthException (com.jeeagile.core.exception.AgileAuthException)3 AgileBaseException (com.jeeagile.core.exception.AgileBaseException)3 AgileFrameException (com.jeeagile.core.exception.AgileFrameException)3 AgileSysUser (com.jeeagile.system.entity.AgileSysUser)3 UserAgent (eu.bitwalker.useragentutils.UserAgent)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 AgileValidateException (com.jeeagile.core.exception.AgileValidateException)1 AgileReference (com.jeeagile.core.protocol.annotation.AgileReference)1 AgileResultCode (com.jeeagile.core.result.AgileResultCode)1 AgileOnlineUser (com.jeeagile.core.security.user.AgileOnlineUser)1 IAgileUserDetailsService (com.jeeagile.core.security.userdetails.IAgileUserDetailsService)1 AgileAgentUtil (com.jeeagile.core.util.AgileAgentUtil)1 AgileStringUtil (com.jeeagile.core.util.AgileStringUtil)1 AgileServletUtil (com.jeeagile.core.util.spring.AgileServletUtil)1 AgileLoggerOperate (com.jeeagile.logger.entity.AgileLoggerOperate)1 AgileUserDetails (com.jeeagile.springsecurity.userdetails.AgileUserDetails)1 AgilePersonInfo (com.jeeagile.system.vo.AgilePersonInfo)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1