Package com.iisigroup.cap.base.model

Examples of com.iisigroup.cap.base.model.CodeType


    return dao.find(oid);
  }

  @Override
  public void deleteById(String oid) {
    CodeType codeType = dao.find(oid);
    if (codeType != null) {
      dao.delete(codeType);
    }
  }
View Full Code Here


  @CapAuditLogAction(functionCode=CapFunctionCode.F101, actionType = CapActionTypeEnum.Update)
  public IResult modify(IRequest request) {
    AjaxFormResult result = new AjaxFormResult();
    String type = request.get("type");
    String locale = CapSecurityContext.getLocale().toString();
    CodeType code = codeTypeService.getByCodeTypeAndValue(
        request.get("codeType"), request.get("codeValue"), locale);

    if ("A".equals(type)) {
      if (code != null) {
        // codetype.0001 代碼重覆!
        throw new CapMessageException(
            CapAppContext.getMessage("codetype.0001"), getClass());
      }
      code = new CodeType();
    } else {
      if (code != null && !code.getOid().equals(request.get("oid"))) {
        // codetype.0001 代碼重覆!
        throw new CapMessageException(
            CapAppContext.getMessage("codetype.0001"), getClass());
      } else if (code == null) {
        code = codeTypeService.getById(request.get("oid"));
      }
    }
    CapBeanUtil.map2Bean(request, code, CodeType.class);
    if ("A".equals(type)) {
      code.setOid(null);
    }
    code.setUpdater(CapSecurityContext.getUserId());
    code.setUpdateTime(CapDate.getCurrentTimestamp());
    codeTypeService.saveCodeType(code);
    return result;
  }
View Full Code Here

        int minLen = Integer.parseInt(parmPwdMinLen.getParmValue());
        int maxHistory = Integer.parseInt(parmPwdMaxHistory.getParmValue());
        int changeInteval = Integer.parseInt(parmPwdChangeInteval
                .getParmValue());
        String ruleType = parmPwdRule.getParmValue();
        CodeType rule = codeTypeDao.findByCodeTypeAndCodeValue("pwdrule",
                ruleType, CapSecurityContext.getLocale().toString());
        if (StringUtils.isBlank(password) || StringUtils.isBlank(password2)) {
            throw new CapMessageException(CapAppContext.getMessage("error.001",
                    new Object[] {}), getClass());
        }
        if (!password.equals(password2) || password.length() < minLen) {
            throw new CapMessageException(CapAppContext.getMessage("error.002",
                    new Object[] { minLen }), getClass());
        }
        if (userId.equalsIgnoreCase(password)) {
            throw new CapMessageException(CapAppContext.getMessage("error.004",
                    new Object[] { minLen }), getClass());
        }
        // pwd history validate
        User user = userDao.findByCode(userId);
        if (user != null) {
            List<PwdLog> list = userPwdHistoryDao.findByUserCode(
                    user.getOid(), maxHistory);
            int i = 0;
            PasswordEncoder passwordEncoder = new StandardPasswordEncoder(
                    userId);
            for (PwdLog h : list) {
                // user status 不為 1 時,check change interval: 最近一次變更不得小於間隔
                if (i == 0 && !"1".equals(user.getStatus()) && !forcePwdChange) {
                    if (CapDate.calculateDays(Calendar.getInstance().getTime(),
                            h.getUpdateTime()) <= changeInteval) {
                        throw new CapMessageException(CapAppContext.getMessage(
                                "error.005", new Object[] { changeInteval }),
                                getClass());
                    }
                }
                if (passwordEncoder.matches(password, h.getPassword())) {
                    throw new CapMessageException(CapAppContext.getMessage(
                            "error.003", new Object[] { maxHistory }),
                            getClass());
                }
                i++;
            }
        }
        String pattern = null;
        switch (Integer.parseInt(ruleType)) {
        case 1:
            pattern = "^(?=.*[0-9])(?=.*[a-zA-Z])(?=\\S+$).{" + minLen + ",}$";
            break;
        case 2:
            pattern = "^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[!@#$%^&()_-])(?=\\S+$).{"
                    + minLen + ",}$";
            break;
        case 3:
            pattern = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=\\S+$).{" + minLen
                    + ",}$";
            break;
        case 4:
            pattern = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&()_-])(?=\\S+$).{"
                    + minLen + ",}$";
            break;
        }
        if (pattern != null && !password.matches(pattern)) {
            throw new CapMessageException(CapAppContext.getMessage("error.008",
                    new Object[] { rule.getCodeDesc() }), getClass());
        }
        return true;
    }// ;
View Full Code Here

TOP

Related Classes of com.iisigroup.cap.base.model.CodeType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.