Package com.iisigroup.cap.exception

Examples of com.iisigroup.cap.exception.CapMessageException


                .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.exception.CapMessageException

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.