use of org.neusoft.neubbs.exception.ServiceException in project neubbs by nuitcoder.
the class EmailServiceImpl method sendAccountActivateMail.
@Override
public void sendAccountActivateMail(String email, String emailToken) {
String activateUrl = neubbsConfig.getAccountApiVaslidateUrl();
if (activateUrl == null) {
throw new ServiceException(ApiMessage.UNKNOWN_ERROR).log(LogWarnEnum.ES1);
}
String emailContent = StringUtil.generateActivateMailHtmlContent(activateUrl + emailToken);
this.send(SetConst.EMAIL_SENDER_NAME, email, SetConst.EMAIL_SUBJECT_ACTIVATE, emailContent);
}
use of org.neusoft.neubbs.exception.ServiceException in project neubbs by nuitcoder.
the class UserServiceImpl method alterUserActivateStateByEmailToken.
@Override
public UserDO alterUserActivateStateByEmailToken(String emailToken) {
// parse token
String plainText = SecretUtil.decodeBase64(emailToken);
String[] array = plainText.split("-");
if (array.length != SetConst.LENGTH_TWO) {
throw new ServiceException(ApiMessage.INVALID_TOKEN).log(LogWarnEnum.US12);
}
String email = array[0];
if (!PatternUtil.matchEmail(email)) {
throw new ServiceException(ApiMessage.INVALID_TOKEN).log(LogWarnEnum.US12);
}
String expireTime = array[1];
if (StringUtil.isExpire(expireTime)) {
throw new ServiceException(ApiMessage.LINK_INVALID).log(LogWarnEnum.US4);
}
this.confirmUserActivatedByEmail(email);
if (userDAO.updateUserStateToActivateByEmail(email) == 0) {
throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.US2);
}
return userDAO.getUserByEmail(email);
}
use of org.neusoft.neubbs.exception.ServiceException in project neubbs by nuitcoder.
the class TopicServiceImpl method alterTopicContent.
@Override
public void alterTopicContent(int topicId, String newCategoryNick, String newTitle, String newTopicContent) {
this.getTopicNotNull(topicId);
this.getTopicContentNotNull(topicId);
TopicCategoryDO category = this.getTopicCategoryNotNullByNick(newCategoryNick);
// update forum_topic 'fucg_id', 'ft_title'
if (topicDAO.updateCategoryById(topicId, category.getId()) == 0 || topicDAO.updateTitleById(topicId, newTitle) == 0) {
throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.TS7);
}
// update forum_topic_content 'ftc_content'
if (topicContentDAO.updateContentByTopicId(topicId, newTopicContent) == 0) {
throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.TS8);
}
}
use of org.neusoft.neubbs.exception.ServiceException in project neubbs by nuitcoder.
the class HttpServiceImpl method outputCaptchaImage.
@Override
public void outputCaptchaImage(BufferedImage captchaImage) {
try {
ServletOutputStream outputStream = PublicParamsUtil.getResponse().getOutputStream();
ImageIO.write(captchaImage, "jpg", outputStream);
outputStream.flush();
outputStream.close();
} catch (IOException e) {
throw new ServiceException(ApiMessage.GENERATE_CAPTCHA_FAIL).log(LogWarnEnum.US17);
}
}
use of org.neusoft.neubbs.exception.ServiceException in project neubbs by nuitcoder.
the class UserServiceImpl method loginVerification.
@Override
public UserDO loginVerification(String username, String password) {
// check username, get user information
UserDO user;
try {
user = this.getUserInfoByName(username);
} catch (ServiceException ae) {
// prevent user know real error message
throw new ServiceException(ApiMessage.USERNAME_OR_PASSWORD_INCORRECT).log(ae.getLog());
}
String cipherText = this.encryptUserPassword(password);
if (!cipherText.equals(user.getPassword())) {
throw new ServiceException(ApiMessage.USERNAME_OR_PASSWORD_INCORRECT).log(LogWarnEnum.US7);
}
return user;
}
Aggregations