public Long get(String phone, String type) throws ServiceException { return cache.get(SMS_LAST_SEND_TIME, getKey(phone, type), Long.class); }
@Override public V get(K key) throws CacheException { if (log.isTraceEnabled()) { log.trace("Getting object from cache[{}] for key[{}]", name, key); } try { if (key == null) { if (log.isTraceEnabled()) { log.trace("Value for key[{}] is null.", key); } return null; } else { String rawValue = cacheService.get(name, key.toString(), String.class); return deserializeValue(rawValue); } } catch (Throwable t) { throw new CacheException(t); } }
public void checkChangePhoneValidCode(String phone, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckChangePhoneCode. "; checkPhone(phone, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (!cache.exist(CacheKeys.VALID_CODE_CHANGE_PHONE.name(), phone)) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_CHANGE_PHONE.name(), phone, String.class))) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_REPASSWORD.name(), phone); } }
public void checkChangeEmailValidCode(String email, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckChangePhoneCode. "; checkEmail(email, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (!cache.exist(CacheKeys.VALID_CODE_CHANGE_PHONE.name(), email)) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_CHANGE_PHONE.name(), email, String.class))) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_REPASSWORD.name(), email); } }
public void checkLoginValidCode(String email, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckLoginCode. "; checkEmail(email, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 获得验证码 if (!cache.exist(CacheKeys.VALID_CODE_LOGIN.name(), email)) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_LOGIN.name(), email, String.class))) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_LOGIN.name(), email); } }
public void checkRegisterValidCode(String phone, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckRegisterCode. "; checkPhone(phone, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 获得验证码 if (!cache.exist(CacheKeys.VALID_CODE_REGISTER.name(), phone)) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_REGISTER.name(), phone, String.class))) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_REGISTER.name(), phone); } }
public void checkRepasswordValidCode(String phone, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckRepasswordCode. "; checkPhone(phone, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 获得验证码 if (!cache.exist(CacheKeys.VALID_CODE_REPASSWORD.name(), phone)) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_REPASSWORD.name(), phone, String.class))) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_REPASSWORD.name(), phone); } }
public void checkRegisterValidCode(String email, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckRegisterCode. "; checkEmail(email, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 获得验证码 if (!cache.exist(CacheKeys.VALID_CODE_REGISTER.name(), email)) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_REGISTER.name(), email, String.class))) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_REGISTER.name(), email); } }
public void checkRepasswordValidCode(String email, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckRepasswordCode. "; checkEmail(email, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 获得验证码 if (!cache.exist(CacheKeys.VALID_CODE_REPASSWORD.name(), email)) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_REPASSWORD.name(), email, String.class))) { throw new ServiceException(UserErrorCode.USER_EMAIL_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_REPASSWORD.name(), email); } }
public void checkLoginValidCode(String phone, String validCode, boolean remove) throws ServiceException { String msg = "Failed to CheckLoginCode. "; checkPhone(phone, msg); if (VerifyTools.isBlank(validCode)) { log.error(msg + "params is null: validCode"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } // 获得验证码 if (!cache.exist(CacheKeys.VALID_CODE_LOGIN.name(), phone)) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_EXPIRED); } if (!validCode.equals(cache.get(CacheKeys.VALID_CODE_LOGIN.name(), phone, String.class))) { throw new ServiceException(UserErrorCode.USER_SMS_VALID_CODE_ERROR); } if (remove) { cache.del(CacheKeys.VALID_CODE_LOGIN.name(), phone); } }