Search in sources :

Example 21 with AccountVO

use of com.netsteadfast.greenstep.vo.AccountVO in project bamboobsc by billchen198318.

the class ShiroLoginSupport method forceCreateLoginSubject.

public Subject forceCreateLoginSubject(HttpServletRequest request, HttpServletResponse response, String accountId, String captchaStr) throws Exception {
    AccountVO account = this.queryUser(accountId);
    if (account == null) {
        logger.warn("no accountId: " + accountId);
        throw new Exception("no accountId: " + accountId);
    }
    request.getSession().setAttribute(GreenStepBaseFormAuthenticationFilter.DEFAULT_CAPTCHA_PARAM, captchaStr);
    GreenStepBaseUsernamePasswordToken token = new GreenStepBaseUsernamePasswordToken();
    token.setCaptcha(captchaStr);
    token.setUsername(account.getAccount());
    token.setPassword(account.getPassword().toCharArray());
    Subject subject = this.getSubject(request, response);
    subject.login(token);
    return subject;
}
Also used : AccountVO(com.netsteadfast.greenstep.vo.AccountVO) Subject(org.apache.shiro.subject.Subject)

Example 22 with AccountVO

use of com.netsteadfast.greenstep.vo.AccountVO in project bamboobsc by billchen198318.

the class ShiroLoginSupport method forceCreateLoginSubject.

public Subject forceCreateLoginSubject(String accountId) throws Exception {
    AccountVO account = this.queryUser(accountId);
    if (account == null) {
        logger.warn("no accountId: " + accountId);
        throw new Exception("no accountId: " + accountId);
    }
    Subject subject = SecurityUtils.getSubject();
    GreenStepBaseUsernamePasswordToken token = new GreenStepBaseUsernamePasswordToken();
    token.setCaptcha("0123");
    token.setUsername(account.getAccount());
    token.setPassword(account.getPassword().toCharArray());
    subject.login(token);
    return subject;
}
Also used : AccountVO(com.netsteadfast.greenstep.vo.AccountVO) Subject(org.apache.shiro.subject.Subject)

Example 23 with AccountVO

use of com.netsteadfast.greenstep.vo.AccountVO in project bamboobsc by billchen198318.

the class GreenStepBaseFormAuthenticationFilter method queryUser.

private AccountVO queryUser(String account) throws Exception {
    if (StringUtils.isBlank(account)) {
        return null;
    }
    AccountVO accountObj = new AccountVO();
    accountObj.setAccount(account);
    DefaultResult<AccountVO> result = accountService.findByUK(accountObj);
    if (result.getValue() == null) {
        return null;
    }
    accountObj = result.getValue();
    return accountObj;
}
Also used : AccountVO(com.netsteadfast.greenstep.vo.AccountVO)

Example 24 with AccountVO

use of com.netsteadfast.greenstep.vo.AccountVO in project bamboobsc by billchen198318.

the class SystemMessageNoticeManagementAction method loadSysMsgNoticeData.

private void loadSysMsgNoticeData() throws ServiceException, Exception {
    this.transformFields2ValueObject(this.sysMsgNotice, new String[] { "oid" });
    DefaultResult<SysMsgNoticeVO> result = this.sysMsgNoticeService.findObjectByOid(this.sysMsgNotice);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    this.sysMsgNotice = result.getValue();
    String[] dateTmp = sysMsgNotice.getDate().split(Constants.DATETIME_DELIMITER);
    this.date1 = dateTmp[0].substring(0, 4) + "-" + dateTmp[0].substring(4, 6) + "-" + dateTmp[0].substring(6, 8);
    this.date2 = dateTmp[1].substring(0, 4) + "-" + dateTmp[1].substring(4, 6) + "-" + dateTmp[1].substring(6, 8);
    String[] time = sysMsgNotice.getTime().split(Constants.DATETIME_DELIMITER);
    this.startHour = time[0].substring(0, 2);
    this.startMinutes = time[0].substring(2, 4);
    this.endHour = time[1].substring(0, 2);
    this.endMinutes = time[1].substring(2, 4);
    SysMsgNoticeConfigVO config = new SysMsgNoticeConfigVO();
    config.setMsgId(sysMsgNotice.getMsgId());
    DefaultResult<SysMsgNoticeConfigVO> configResult = this.sysMsgNoticeConfigService.findByUK(config);
    if (configResult.getValue() == null) {
        throw new ServiceException(configResult.getSystemMessage().getValue());
    }
    config = configResult.getValue();
    this.selectConfigOid = config.getOid();
    AccountVO account = new AccountVO();
    if (!"*".equals(sysMsgNotice.getToAccount())) {
        account.setAccount(sysMsgNotice.getToAccount());
        DefaultResult<AccountVO> aResult = this.accountService.findByUK(account);
        if (aResult.getValue() == null) {
            throw new ServiceException(aResult.getSystemMessage().getValue());
        }
        account = aResult.getValue();
        this.selectAccountOid = account.getOid();
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysMsgNoticeConfigVO(com.netsteadfast.greenstep.vo.SysMsgNoticeConfigVO) AccountVO(com.netsteadfast.greenstep.vo.AccountVO) SysMsgNoticeVO(com.netsteadfast.greenstep.vo.SysMsgNoticeVO)

Example 25 with AccountVO

use of com.netsteadfast.greenstep.vo.AccountVO in project bamboobsc by billchen198318.

the class EmployeeLogicServiceImpl method create.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<EmployeeVO> create(EmployeeVO employee, List<String> organizationOid) throws ServiceException, Exception {
    if (employee == null || super.isBlank(employee.getEmpId())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("empId", employee.getEmpId());
    if (this.getEmployeeService().countByParams(params) > 0) {
        throw new ServiceException("Please change another Id!");
    }
    AccountVO account = this.tranAccount(employee);
    if (this.isAdministrator(account.getAccount())) {
        throw new ServiceException("Please change another Account!");
    }
    DefaultResult<AccountVO> mResult = this.getAccountService().saveObject(account);
    if (mResult.getValue() == null) {
        throw new ServiceException(mResult.getSystemMessage().getValue());
    }
    DefaultResult<EmployeeVO> result = this.getEmployeeService().saveObject(employee);
    employee = result.getValue();
    this.createEmployeeOrganization(employee, organizationOid);
    // create default role
    UserRoleVO userRole = new UserRoleVO();
    userRole.setAccount(employee.getAccount());
    userRole.setRole(this.roleLogicService.getDefaultUserRole());
    userRole.setDescription(employee.getAccount() + " `s role!");
    this.getUserRoleService().saveObject(userRole);
    this.createHierarchy(employee, BscConstants.EMPLOYEE_HIER_ZERO_OID);
    return result;
}
Also used : EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) UserRoleVO(com.netsteadfast.greenstep.vo.UserRoleVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) AccountVO(com.netsteadfast.greenstep.vo.AccountVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AccountVO (com.netsteadfast.greenstep.vo.AccountVO)26 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)12 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)7 Transactional (org.springframework.transaction.annotation.Transactional)7 Subject (org.apache.shiro.subject.Subject)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)3 UserRoleVO (com.netsteadfast.greenstep.vo.UserRoleVO)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 AuthenticationException (org.apache.shiro.authc.AuthenticationException)3 RoleVO (com.netsteadfast.greenstep.vo.RoleVO)2 SysCalendarNoteVO (com.netsteadfast.greenstep.vo.SysCalendarNoteVO)2 SysMenuRoleVO (com.netsteadfast.greenstep.vo.SysMenuRoleVO)2 SysMsgNoticeConfigVO (com.netsteadfast.greenstep.vo.SysMsgNoticeConfigVO)2 SysMsgNoticeVO (com.netsteadfast.greenstep.vo.SysMsgNoticeVO)2 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)1 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)1 WebMessagePublishBaseObj (com.netsteadfast.greenstep.model.WebMessagePublishBaseObj)1 BbReportRoleView (com.netsteadfast.greenstep.po.hbm.BbReportRoleView)1