Change to wdcy
parent
96c87f890d
commit
31f24a5808
|
@ -17,6 +17,6 @@ package cc.wdcy.domain.shared.security;
|
||||||
|
|
||||||
public interface SecurityHolder {
|
public interface SecurityHolder {
|
||||||
|
|
||||||
HonyeeUserDetails userDetails();
|
WdcyUserDetails userDetails();
|
||||||
|
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@ public class SecurityUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static User currentUser() {
|
public static User currentUser() {
|
||||||
HonyeeUserDetails userDetails = securityHolder.userDetails();
|
WdcyUserDetails userDetails = securityHolder.userDetails();
|
||||||
return (userDetails != null ? userDetails.user() : null);
|
return (userDetails != null ? userDetails.user() : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,7 +11,6 @@
|
||||||
*/
|
*/
|
||||||
package cc.wdcy.domain.shared.security;
|
package cc.wdcy.domain.shared.security;
|
||||||
|
|
||||||
import cc.wdcy.infrastructure.DateUtils;
|
|
||||||
import cc.wdcy.domain.user.User;
|
import cc.wdcy.domain.user.User;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
@ -23,27 +22,23 @@ import java.util.Collection;
|
||||||
/**
|
/**
|
||||||
* @author Shengzhao Li
|
* @author Shengzhao Li
|
||||||
*/
|
*/
|
||||||
public class HonyeeUserDetails implements UserDetails {
|
public class WdcyUserDetails implements UserDetails {
|
||||||
|
|
||||||
protected static final String ROLE_PREFIX = "ROLE_";
|
protected static final String ROLE_PREFIX = "ROLE_";
|
||||||
protected static final GrantedAuthority DEFAULT_USER_ROLE = new SimpleGrantedAuthority(ROLE_PREFIX + "USER");
|
protected static final GrantedAuthority DEFAULT_USER_ROLE = new SimpleGrantedAuthority(ROLE_PREFIX + "USER");
|
||||||
protected static final GrantedAuthority ADMIN_USER_ROLE = new SimpleGrantedAuthority(ROLE_PREFIX + "ADMIN");
|
|
||||||
|
|
||||||
protected User user;
|
protected User user;
|
||||||
|
|
||||||
|
|
||||||
public HonyeeUserDetails() {
|
public WdcyUserDetails() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public HonyeeUserDetails(User user) {
|
public WdcyUserDetails(User user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||||
// if (user.defaultUser()) {
|
|
||||||
// return Arrays.asList(ADMIN_USER_ROLE, DEFAULT_USER_ROLE);
|
|
||||||
// }
|
|
||||||
return Arrays.asList(DEFAULT_USER_ROLE, new SimpleGrantedAuthority(ROLE_PREFIX + "UNITY"), new SimpleGrantedAuthority(ROLE_PREFIX + "MOBILE"));
|
return Arrays.asList(DEFAULT_USER_ROLE, new SimpleGrantedAuthority(ROLE_PREFIX + "UNITY"), new SimpleGrantedAuthority(ROLE_PREFIX + "MOBILE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,12 +76,6 @@ public class HonyeeUserDetails implements UserDetails {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLastLoginTime() {
|
|
||||||
if (user != null && user.lastLoginTime() != null) {
|
|
||||||
return DateUtils.toDateText(user.lastLoginTime(), DateUtils.DEFAULT_DATE_TIME_FORMAT);
|
|
||||||
}
|
|
||||||
return "---";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
|
@ -13,7 +13,6 @@ package cc.wdcy.domain.user;
|
||||||
|
|
||||||
import cc.wdcy.domain.AbstractDomain;
|
import cc.wdcy.domain.AbstractDomain;
|
||||||
import cc.wdcy.domain.shared.BeanProvider;
|
import cc.wdcy.domain.shared.BeanProvider;
|
||||||
import cc.wdcy.infrastructure.PasswordHandler;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -101,12 +100,6 @@ public class User extends AbstractDomain {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String resetPassword() {
|
|
||||||
String newOriginalPass = PasswordHandler.randomPassword();
|
|
||||||
this.password = PasswordHandler.encryptPassword(newOriginalPass);
|
|
||||||
this.saveOrUpdate();
|
|
||||||
return newOriginalPass;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Date lastLoginTime() {
|
public Date lastLoginTime() {
|
||||||
|
|
|
@ -11,11 +11,6 @@
|
||||||
*/
|
*/
|
||||||
package cc.wdcy.infrastructure;
|
package cc.wdcy.infrastructure;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,113 +18,9 @@ import java.util.Date;
|
||||||
*/
|
*/
|
||||||
public abstract class DateUtils {
|
public abstract class DateUtils {
|
||||||
|
|
||||||
/**
|
|
||||||
* Default time format : yyyy-MM-dd HH:mm:ss
|
|
||||||
*/
|
|
||||||
public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Time format : yyyy-MM-dd HH:mm
|
|
||||||
*/
|
|
||||||
public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm";
|
|
||||||
public static final String TIME_FORMAT = "HH:mm";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default date format
|
|
||||||
*/
|
|
||||||
public static final String DATE_FORMAT = "yyyy-MM-dd";
|
|
||||||
/**
|
|
||||||
* Default month format
|
|
||||||
*/
|
|
||||||
public static final String MONTH_FORMAT = "yyyy-MM";
|
|
||||||
/**
|
|
||||||
* Default day format
|
|
||||||
*/
|
|
||||||
public static final String DAY_FORMAT = "dd";
|
|
||||||
|
|
||||||
public static final long DAY_MILLISECONDS = (1000l * 60 * 60 * 24);
|
|
||||||
|
|
||||||
//Date pattern, demo: 2013-09-11
|
|
||||||
public static final String DATE_PATTERN = "^[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}$";
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isDate(String dateAsText) {
|
|
||||||
return StringUtils.isNotEmpty(dateAsText) && dateAsText.matches(DATE_PATTERN);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date now() {
|
public static Date now() {
|
||||||
return new Date();
|
return new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toDateText(Date date) {
|
|
||||||
return toDateText(date, DATE_FORMAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toDateText(Date date, String pattern) {
|
|
||||||
if (date == null || pattern == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
|
|
||||||
return dateFormat.format(date);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Date getDate(String dateText) {
|
|
||||||
return getDate(dateText, DATE_FORMAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Date getDate(String dateText, String pattern) {
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
|
|
||||||
try {
|
|
||||||
return dateFormat.parse(dateText);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new IllegalStateException("Parse date from [" + dateText + "," + pattern + "] failed", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toDateTime(Date date) {
|
|
||||||
return toDateText(date, DATE_TIME_FORMAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return current year.
|
|
||||||
*
|
|
||||||
* @return Current year
|
|
||||||
*/
|
|
||||||
public static int currentYear() {
|
|
||||||
return calendar().get(Calendar.YEAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Calendar calendar() {
|
|
||||||
return Calendar.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isToday(Date date) {
|
|
||||||
if (date == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String dateAsText = toDateText(date);
|
|
||||||
String todayAsText = toDateText(now());
|
|
||||||
return dateAsText.equals(todayAsText);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get tow dates period as days,
|
|
||||||
* return -1 if the start or end is null
|
|
||||||
*
|
|
||||||
* @param start Start date
|
|
||||||
* @param end End date
|
|
||||||
* @return Period as days or -1
|
|
||||||
*/
|
|
||||||
public static long periodAsDays(Date start, Date end) {
|
|
||||||
if (start == null || end == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
start = org.apache.commons.lang.time.DateUtils.truncate(start, Calendar.DAY_OF_MONTH);
|
|
||||||
end = org.apache.commons.lang.time.DateUtils.truncate(end, Calendar.DAY_OF_MONTH);
|
|
||||||
|
|
||||||
long periodAsMilliSeconds = end.getTime() - start.getTime();
|
|
||||||
return (periodAsMilliSeconds / (DAY_MILLISECONDS));
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
|
||||||
* www.honyee.biz
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is the confidential and proprietary information of
|
|
||||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
|
||||||
* You shall not disclose such Confidential Information and shall use
|
|
||||||
* it only in accordance with the terms of the license agreement you
|
|
||||||
* entered into with Honyee Industry Group Co., Ltd.
|
|
||||||
*/
|
|
||||||
package cc.wdcy.infrastructure;
|
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
|
||||||
import com.google.zxing.EncodeHintType;
|
|
||||||
import com.google.zxing.WriterException;
|
|
||||||
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
||||||
import com.google.zxing.common.BitMatrix;
|
|
||||||
import com.google.zxing.qrcode.QRCodeWriter;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Shengzhao Li
|
|
||||||
*/
|
|
||||||
public abstract class DimensionalCodeHelper {
|
|
||||||
|
|
||||||
|
|
||||||
//Default size: 200 * 200
|
|
||||||
public static byte[] encode(String content) {
|
|
||||||
return encode(content, 200, 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static byte[] encode(String content, int width, int height) {
|
|
||||||
Map<EncodeHintType, Object> hints = new HashMap<>();
|
|
||||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
|
||||||
|
|
||||||
QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
|
||||||
BitMatrix matrix;
|
|
||||||
try {
|
|
||||||
matrix = qrCodeWriter.encode(content, BarcodeFormat.QR_CODE, width, height, hints);
|
|
||||||
} catch (WriterException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
MatrixToImageWriter.writeToStream(matrix, "png", os);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
return os.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
|
||||||
* www.honyee.biz
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is the confidential and proprietary information of
|
|
||||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
|
||||||
* You shall not disclose such Confidential Information and shall use
|
|
||||||
* it only in accordance with the terms of the license agreement you
|
|
||||||
* entered into with Honyee Industry Group Co., Ltd.
|
|
||||||
*/
|
|
||||||
package cc.wdcy.infrastructure;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Shengzhao Li
|
|
||||||
*/
|
|
||||||
public abstract class MatchUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigDecimal regex.
|
|
||||||
*/
|
|
||||||
public static final String BIG_DECIMAL_REGEX = "^(\\d+)||(\\d+\\.\\d+)$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Positive Number regex.
|
|
||||||
*/
|
|
||||||
public static final String POSITIVE_NUMBER_REGEX = "^\\d+$";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Email regex.
|
|
||||||
*/
|
|
||||||
public static final String EMAIL_REGEX = ".+@.+\\.[a-z]+";
|
|
||||||
|
|
||||||
public static boolean isBigDecimal(String text) {
|
|
||||||
return StringUtils.isNotEmpty(text) && text.matches(BIG_DECIMAL_REGEX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isEmail(String email) {
|
|
||||||
return StringUtils.isNotEmpty(email) && email.matches(EMAIL_REGEX);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPositiveNumber(String numberText) {
|
|
||||||
return StringUtils.isNotEmpty(numberText) && numberText.matches(POSITIVE_NUMBER_REGEX);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,9 +11,7 @@
|
||||||
*/
|
*/
|
||||||
package cc.wdcy.infrastructure;
|
package cc.wdcy.infrastructure;
|
||||||
|
|
||||||
import cc.wdcy.domain.shared.GuidGenerator;
|
|
||||||
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
|
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shengzhao Li
|
* @author Shengzhao Li
|
||||||
|
@ -21,25 +19,8 @@ import org.springframework.util.StringUtils;
|
||||||
public abstract class PasswordHandler {
|
public abstract class PasswordHandler {
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Encrypt factor, use it for reversible password
|
|
||||||
*/
|
|
||||||
private static final int ENCRYPT_FACTOR = 7;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a random password from {@link java.util.UUID},
|
|
||||||
* the length is 8.
|
|
||||||
*
|
|
||||||
* @return Random password
|
|
||||||
*/
|
|
||||||
public static String randomPassword() {
|
|
||||||
String uuid = GuidGenerator.generate();
|
|
||||||
return uuid.substring(0, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt password ,if original password is empty,
|
* Encrypt password ,if original password is empty,
|
||||||
* will call {@link #randomPassword()} get a random original password.
|
|
||||||
*
|
*
|
||||||
* @param originalPassword Original password
|
* @param originalPassword Original password
|
||||||
* @return Encrypted password
|
* @return Encrypted password
|
||||||
|
@ -49,31 +30,5 @@ public abstract class PasswordHandler {
|
||||||
return md5PasswordEncoder.encodePassword(originalPassword, null);
|
return md5PasswordEncoder.encodePassword(originalPassword, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Encrypt the reversible password
|
|
||||||
*
|
|
||||||
* @param originalPassword originalPassword
|
|
||||||
* @return encrypted password
|
|
||||||
*/
|
|
||||||
public static String encryptReversiblePassword(String originalPassword) {
|
|
||||||
if (!StringUtils.hasText(originalPassword)) {
|
|
||||||
return originalPassword;
|
|
||||||
}
|
|
||||||
byte[] bytes = originalPassword.getBytes();
|
|
||||||
for (int i = 0; i < bytes.length; i++) {
|
|
||||||
byte b = bytes[i];
|
|
||||||
bytes[i] = (byte) (b ^ ENCRYPT_FACTOR);
|
|
||||||
}
|
|
||||||
return new String(bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decrypt the encrypted password.
|
|
||||||
*
|
|
||||||
* @param encryptedPassword encryptedPassword
|
|
||||||
* @return decrypted password
|
|
||||||
*/
|
|
||||||
public static String decryptReversiblePassword(String encryptedPassword) {
|
|
||||||
return encryptReversiblePassword(encryptedPassword);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -11,7 +11,7 @@
|
||||||
*/
|
*/
|
||||||
package cc.wdcy.service.impl;
|
package cc.wdcy.service.impl;
|
||||||
|
|
||||||
import cc.wdcy.domain.shared.security.HonyeeUserDetails;
|
import cc.wdcy.domain.shared.security.WdcyUserDetails;
|
||||||
import cc.wdcy.domain.user.User;
|
import cc.wdcy.domain.user.User;
|
||||||
import cc.wdcy.domain.user.UserRepository;
|
import cc.wdcy.domain.user.UserRepository;
|
||||||
import cc.wdcy.service.UserService;
|
import cc.wdcy.service.UserService;
|
||||||
|
@ -36,6 +36,6 @@ public class UserServiceImpl implements UserService {
|
||||||
throw new UsernameNotFoundException("Not found any user for username[" + username + "]");
|
throw new UsernameNotFoundException("Not found any user for username[" + username + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HonyeeUserDetails(user);
|
return new WdcyUserDetails(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,7 +11,7 @@
|
||||||
*/
|
*/
|
||||||
package cc.wdcy.web.context;
|
package cc.wdcy.web.context;
|
||||||
|
|
||||||
import cc.wdcy.domain.shared.security.HonyeeUserDetails;
|
import cc.wdcy.domain.shared.security.WdcyUserDetails;
|
||||||
import cc.wdcy.domain.shared.security.SecurityHolder;
|
import cc.wdcy.domain.shared.security.SecurityHolder;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
@ -22,14 +22,14 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
public class SpringSecurityHolder implements SecurityHolder {
|
public class SpringSecurityHolder implements SecurityHolder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HonyeeUserDetails userDetails() {
|
public WdcyUserDetails userDetails() {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (authentication == null) {
|
if (authentication == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Object principal = authentication.getPrincipal();
|
Object principal = authentication.getPrincipal();
|
||||||
if (principal instanceof HonyeeUserDetails) {
|
if (principal instanceof WdcyUserDetails) {
|
||||||
return (HonyeeUserDetails) principal;
|
return (WdcyUserDetails) principal;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
package cc.wdcy.web.controller;
|
package cc.wdcy.web.controller;
|
||||||
|
|
||||||
import cc.wdcy.service.UserService;
|
import cc.wdcy.service.UserService;
|
||||||
import cc.wdcy.web.validator.UserFormDtoValidator;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
@ -28,8 +27,6 @@ public class UserController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Autowired
|
|
||||||
private UserFormDtoValidator validator;
|
|
||||||
|
|
||||||
@RequestMapping("overview.htm")
|
@RequestMapping("overview.htm")
|
||||||
public String overview(Model model) {
|
public String overview(Model model) {
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
|
||||||
* www.honyee.biz
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is the confidential and proprietary information of
|
|
||||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
|
||||||
* You shall not disclose such Confidential Information and shall use
|
|
||||||
* it only in accordance with the terms of the license agreement you
|
|
||||||
* entered into with Honyee Industry Group Co., Ltd.
|
|
||||||
*/
|
|
||||||
package cc.wdcy.web.validator;
|
|
||||||
|
|
||||||
import cc.wdcy.domain.dto.user.UserFormDto;
|
|
||||||
import cc.wdcy.infrastructure.MatchUtils;
|
|
||||||
import cc.wdcy.service.UserService;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.validation.Errors;
|
|
||||||
import org.springframework.validation.Validator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Shengzhao Li
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class UserFormDtoValidator implements Validator {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supports(Class<?> aClass) {
|
|
||||||
return UserFormDto.class.equals(aClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validate(Object target, Errors errors) {
|
|
||||||
UserFormDto userFormDto = (UserFormDto) target;
|
|
||||||
validateUsername(userFormDto, errors);
|
|
||||||
validateEmail(userFormDto, errors);
|
|
||||||
|
|
||||||
if (userFormDto.isNewly()) {
|
|
||||||
validatePassword(userFormDto, errors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validatePassword(UserFormDto userFormDto, Errors errors) {
|
|
||||||
String password = userFormDto.getPassword();
|
|
||||||
if (password.length() < 6) {
|
|
||||||
errors.rejectValue("password", null, "用户密码至少6位");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!password.equals(userFormDto.getRePassword())) {
|
|
||||||
errors.rejectValue("rePassword", null, "两次输入的密码不相同");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateEmail(UserFormDto userFormDto, Errors errors) {
|
|
||||||
String email = userFormDto.getEmail();
|
|
||||||
if (!MatchUtils.isEmail(email)) {
|
|
||||||
errors.rejectValue("email", null, "邮件地址格式错误");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateUsername(UserFormDto userFormDto, Errors errors) {
|
|
||||||
String username = userFormDto.getUsername();
|
|
||||||
if (StringUtils.isEmpty(username)) {
|
|
||||||
errors.rejectValue("username", null, "用户名不能为空");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!username.equals(userFormDto.getExistUsername())) {
|
|
||||||
// boolean exist = userService.loadExistUsername(username);
|
|
||||||
// if (exist) {
|
|
||||||
// errors.rejectValue("username", null, "该用户名已经存在");
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,111 +0,0 @@
|
||||||
basic.empty.showtable=true
|
|
||||||
basic.show.header=true
|
|
||||||
|
|
||||||
# page | list
|
|
||||||
sort.amount=page
|
|
||||||
|
|
||||||
export.amount=list
|
|
||||||
export.decorated=true
|
|
||||||
|
|
||||||
paging.banner.group_size=5
|
|
||||||
paging.banner.placement=bottom
|
|
||||||
|
|
||||||
|
|
||||||
css.tr.even=even
|
|
||||||
css.tr.odd=odd
|
|
||||||
css.th.sorted=sorted
|
|
||||||
css.th.ascending=order1
|
|
||||||
css.th.descending=order2
|
|
||||||
css.table=
|
|
||||||
css.th.sortable=sortable
|
|
||||||
|
|
||||||
# factory classes for extensions
|
|
||||||
factory.requestHelper=org.displaytag.util.DefaultRequestHelperFactory
|
|
||||||
|
|
||||||
# factory class for decorators
|
|
||||||
factory.decorator=org.displaytag.decorator.DefaultDecoratorFactory
|
|
||||||
|
|
||||||
# locale provider (Jstl provider by default)
|
|
||||||
locale.provider=org.displaytag.localization.I18nJstlAdapter
|
|
||||||
|
|
||||||
# locale.resolver (nothing by default, simply use locale from request)
|
|
||||||
#locale.resolver=
|
|
||||||
|
|
||||||
export.types=csv excel xml pdf
|
|
||||||
|
|
||||||
export.csv.class=org.displaytag.export.CsvView
|
|
||||||
export.excel.class=org.displaytag.export.ExcelView
|
|
||||||
export.xml.class=org.displaytag.export.XmlView
|
|
||||||
export.pdf.class=org.displaytag.export.PdfView
|
|
||||||
|
|
||||||
export.csv=true
|
|
||||||
export.csv.label=<span class="export csv">CSV </span>
|
|
||||||
export.csv.include_header=false
|
|
||||||
export.csv.filename=
|
|
||||||
|
|
||||||
export.excel=true
|
|
||||||
export.excel.label=<span class="export excel">Excel </span>
|
|
||||||
export.excel.include_header=true
|
|
||||||
export.excel.filename=
|
|
||||||
|
|
||||||
export.xml=true
|
|
||||||
export.xml.label=<span class="export xml">XML </span>
|
|
||||||
export.xml.filename=
|
|
||||||
|
|
||||||
export.pdf=false
|
|
||||||
export.pdf.label=<span class="export pdf">PDF </span>
|
|
||||||
export.pdf.include_header=true
|
|
||||||
export.pdf.filename=
|
|
||||||
|
|
||||||
export.rtf=false
|
|
||||||
export.rtf.label=<span class="export rtf">RTF </span>
|
|
||||||
export.rtf.include_header=true
|
|
||||||
export.rtf.filename=
|
|
||||||
|
|
||||||
# messages
|
|
||||||
|
|
||||||
basic.msg.empty_list=
|
|
||||||
basic.msg.empty_list_row=<tr class="empty"><td colspan="{0}"> </td></tr>
|
|
||||||
error.msg.invalid_page=invalid page
|
|
||||||
|
|
||||||
export.banner=<div class="exportlinks">\u5bfc\u51fa\u9009\u9879: {0}</div>
|
|
||||||
export.banner.sepchar= |
|
|
||||||
|
|
||||||
paging.banner.item_name=\u6761
|
|
||||||
paging.banner.items_name=\u6761
|
|
||||||
|
|
||||||
paging.banner.no_items_found=
|
|
||||||
paging.banner.one_item_found=
|
|
||||||
paging.banner.all_items_found=
|
|
||||||
paging.banner.some_items_found=
|
|
||||||
|
|
||||||
#paging.banner.full=<span class="pagelinks">[<a href="{1}">\u9996\u9875</a>/<a href="{2}">\u4e0a\u9875</a>] {0} [<a href="{3}">\u4e0b\u9875</a>/<a href="{4}">\u672b\u9875</a>]</span>
|
|
||||||
#paging.banner.first=<span class="pagelinks">[\u9996\u9875/\u4e0a\u9875] {0} [<a href="{3}">\u4e0b\u9875</a>/<a href="{4}">\u672b\u9875</a>]</span>
|
|
||||||
#paging.banner.last=<span class="pagelinks">[<a href="{1}">\u9996\u9875</a>/<a href="{2}">\u4e0a\u9875</a>] {0} [\u4e0b\u9875/\u672b\u9875]</span>
|
|
||||||
#paging.banner.onepage=<span class="pagelinks">{0}</span>
|
|
||||||
paging.banner.full=<div class="pager clearfix text-center"><ul><li><a href="{1}">«\u4e0a\u9875</a></li>{0}<li><a href="{4}">\u4e0b\u9875»</a></li></ul></div>
|
|
||||||
paging.banner.first=<div class="pager clearfix text-center"><ul><li><a href="javascript:void(0);">«\u4e0a\u9875</a></li>{0}<li><a href="{4}">\u4e0b\u9875»</a></li></ul></div>
|
|
||||||
paging.banner.last=<div class="pager clearfix text-center"><ul><li><a href="{1}">«\u4e0a\u9875</a></li>{0}<li><a href="javascript:void(0);">\u4e0b\u9875»</a></li></ul></div>
|
|
||||||
paging.banner.onepage=<div class="pager clearfix text-center"><ul><li><a href="javascript:void(0);">«\u4e0a\u9875</a></li>{0}<li><a href="javascript:void(0);">\u4e0b\u9875»</a></li></ul></div>
|
|
||||||
|
|
||||||
|
|
||||||
#paging.banner.page.selected=<strong>{0}</strong>
|
|
||||||
#paging.banner.page.link=<a href="{1}">{0}</a>
|
|
||||||
#paging.banner.page.separator=
|
|
||||||
paging.banner.page.selected=<li class="active"><a href="javascript:void(0);">{0}</a></li>
|
|
||||||
paging.banner.page.link=<li><a href="{1}">{0}</a></li>
|
|
||||||
paging.banner.page.separator=
|
|
||||||
|
|
||||||
|
|
||||||
# external sort and pagination
|
|
||||||
pagination.sort.param=sort
|
|
||||||
pagination.sortdirection.param=dir
|
|
||||||
pagination.pagenumber.param=pageNumber
|
|
||||||
pagination.searchid.param=searchid
|
|
||||||
pagination.sort.asc.value=asc
|
|
||||||
pagination.sort.desc.value=desc
|
|
||||||
pagination.sort.skippagenumber=true
|
|
||||||
|
|
||||||
# unused
|
|
||||||
save.excel.banner=<a href="{0}" rel="external">\u4fdd\u5b58 ({1} \u5b57\u8282)</a>
|
|
||||||
save.excel.filename=export.xls
|
|
|
@ -1,22 +0,0 @@
|
||||||
#Email configure
|
|
||||||
#mail host name
|
|
||||||
host.name=smtp.exmail.qq.com
|
|
||||||
#mail send port,default 25
|
|
||||||
mail.smtp.port=25
|
|
||||||
#mail use username
|
|
||||||
mail.username=no-reply@honyee.cc
|
|
||||||
#mail use password
|
|
||||||
mail.password=honyee@2013
|
|
||||||
#default mail address
|
|
||||||
default.mail.address=no-reply@honyee.cc
|
|
||||||
# auth
|
|
||||||
mail.smtp.auth=true
|
|
||||||
# true is use new thread send mail, default false
|
|
||||||
#If develop in production, change it to true
|
|
||||||
mail.send.use.thread=false
|
|
||||||
|
|
||||||
|
|
||||||
#Develop configuration
|
|
||||||
#If develop in production, change it to false
|
|
||||||
mail.develop.environment=true
|
|
||||||
mail.develop.address=shengzhao@honyee.cc
|
|
|
@ -17,7 +17,6 @@
|
||||||
<property name="locations">
|
<property name="locations">
|
||||||
<list>
|
<list>
|
||||||
<value>classpath:database.properties</value>
|
<value>classpath:database.properties</value>
|
||||||
<value>classpath:mail.properties</value>
|
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
@ -32,9 +31,9 @@
|
||||||
<property name="validationQuery" value="SELECT 1"/>
|
<property name="validationQuery" value="SELECT 1"/>
|
||||||
<property name="testOnReturn" value="false"/>
|
<property name="testOnReturn" value="false"/>
|
||||||
<property name="testOnBorrow" value="true"/>
|
<property name="testOnBorrow" value="true"/>
|
||||||
<!--Based on 1000 connected user -->
|
<!--Based on 100 connected user -->
|
||||||
<property name="maxActive" value="200"/>
|
<property name="maxActive" value="20"/>
|
||||||
<property name="maxIdle" value="50"/>
|
<property name="maxIdle" value="5"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
|
||||||
|
|
||||||
|
|
||||||
<!--Mail configuration-->
|
|
||||||
<bean id="javaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
|
||||||
<property name="host" value="${host.name}"/>
|
|
||||||
<property name="port" value="${mail.smtp.port}"/>
|
|
||||||
<property name="username" value="${mail.username}"/>
|
|
||||||
<property name="password" value="${mail.password}"/>
|
|
||||||
<property name="defaultEncoding" value="UTF-8"/>
|
|
||||||
<property name="javaMailProperties">
|
|
||||||
<props>
|
|
||||||
<prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
|
|
||||||
</props>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
</beans>
|
|
|
@ -1,21 +0,0 @@
|
||||||
<p><strong>职位描述:</strong></p>
|
|
||||||
|
|
||||||
<p> </p>
|
|
||||||
|
|
||||||
<p> </p>
|
|
||||||
|
|
||||||
<p><strong>岗位职责:</strong></p>
|
|
||||||
|
|
||||||
<p> </p>
|
|
||||||
|
|
||||||
<p> </p>
|
|
||||||
|
|
||||||
<p> </p>
|
|
||||||
|
|
||||||
<p><strong>联系方式:</strong></p>
|
|
||||||
|
|
||||||
<p> </p>
|
|
||||||
|
|
||||||
<p> </p>
|
|
||||||
|
|
||||||
<p> </p>
|
|
|
@ -25,9 +25,9 @@
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width,user-scalable=no"/>
|
<meta name="viewport" content="width=device-width,user-scalable=no"/>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
<meta name="keywords" content="honyee.cc"/>
|
<meta name="keywords" content="wdcy.cc"/>
|
||||||
<meta name="description" content="honyee.cc"/>
|
<meta name="description" content="wdcy.cc"/>
|
||||||
<meta name="author" content="honyee.cc"/>
|
<meta name="author" content="wdcy.cc"/>
|
||||||
|
|
||||||
<title><decorator:title default=""/> - Oauth</title>
|
<title><decorator:title default=""/> - Oauth</title>
|
||||||
<decorator:head/>
|
<decorator:head/>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
package cc.wdcy;
|
package cc.wdcy;
|
||||||
|
|
||||||
import cc.wdcy.domain.shared.BeanProvider;
|
import cc.wdcy.domain.shared.BeanProvider;
|
||||||
import cc.wdcy.domain.shared.security.HonyeeUserDetails;
|
import cc.wdcy.domain.shared.security.WdcyUserDetails;
|
||||||
import cc.wdcy.domain.shared.security.SecurityUtils;
|
import cc.wdcy.domain.shared.security.SecurityUtils;
|
||||||
import cc.wdcy.web.context.SpringSecurityHolder;
|
import cc.wdcy.web.context.SpringSecurityHolder;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
@ -31,7 +31,7 @@ public abstract class ContextTest extends AbstractTransactionalTestNGSpringConte
|
||||||
SecurityUtils securityUtils = new SecurityUtils();
|
SecurityUtils securityUtils = new SecurityUtils();
|
||||||
securityUtils.setSecurityHolder(new SpringSecurityHolder() {
|
securityUtils.setSecurityHolder(new SpringSecurityHolder() {
|
||||||
@Override
|
@Override
|
||||||
public HonyeeUserDetails userDetails() {
|
public WdcyUserDetails userDetails() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
|
||||||
* www.honyee.biz
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is the confidential and proprietary information of
|
|
||||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
|
||||||
* You shall not disclose such Confidential Information and shall use
|
|
||||||
* it only in accordance with the terms of the license agreement you
|
|
||||||
* entered into with Honyee Industry Group Co., Ltd.
|
|
||||||
*/
|
|
||||||
package cc.wdcy.infrastructure;
|
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import static org.testng.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Shengzhao Li
|
|
||||||
*/
|
|
||||||
public class DateUtilsTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isToday() throws Exception {
|
|
||||||
boolean today = DateUtils.isToday(DateUtils.now());
|
|
||||||
assertTrue(today);
|
|
||||||
|
|
||||||
today = DateUtils.isToday(DateUtils.getDate("2013-03-09"));
|
|
||||||
assertFalse(today);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isDate() throws Exception {
|
|
||||||
boolean isDate = DateUtils.isDate(null);
|
|
||||||
assertFalse(isDate);
|
|
||||||
|
|
||||||
isDate = DateUtils.isDate("2013-09-11");
|
|
||||||
assertTrue(isDate);
|
|
||||||
|
|
||||||
isDate = DateUtils.isDate("20130911");
|
|
||||||
assertFalse(isDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* OOps! what happened, waiting................
|
|
||||||
*/
|
|
||||||
@Test(enabled = false)
|
|
||||||
public void periodAsDays() {
|
|
||||||
Date start = DateUtils.now();
|
|
||||||
Date end = DateUtils.now();
|
|
||||||
|
|
||||||
long days = DateUtils.periodAsDays(start, end);
|
|
||||||
System.out.println("Period: " + days);
|
|
||||||
assertEquals(days, 0);
|
|
||||||
|
|
||||||
start = DateUtils.getDate("2013-03-01 12:23:23", DateUtils.DEFAULT_DATE_TIME_FORMAT);
|
|
||||||
end = DateUtils.getDate("2013-03-11 16:00:11", DateUtils.DEFAULT_DATE_TIME_FORMAT);
|
|
||||||
System.out.println("Start [" + DateUtils.toDateTime(start) + "], End [" + DateUtils.toDateTime(end) + "]");
|
|
||||||
|
|
||||||
days = DateUtils.periodAsDays(start, end);
|
|
||||||
System.out.println("Period: " + days);
|
|
||||||
assertEquals(days, 10);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
|
||||||
* www.honyee.biz
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is the confidential and proprietary information of
|
|
||||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
|
||||||
* You shall not disclose such Confidential Information and shall use
|
|
||||||
* it only in accordance with the terms of the license agreement you
|
|
||||||
* entered into with Honyee Industry Group Co., Ltd.
|
|
||||||
*/
|
|
||||||
package cc.wdcy.infrastructure;
|
|
||||||
|
|
||||||
import com.google.zxing.*;
|
|
||||||
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
|
|
||||||
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
||||||
import com.google.zxing.common.BitMatrix;
|
|
||||||
import com.google.zxing.common.HybridBinarizer;
|
|
||||||
import com.google.zxing.qrcode.QRCodeReader;
|
|
||||||
import com.google.zxing.qrcode.QRCodeWriter;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.testng.Assert.assertNotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Shengzhao Li
|
|
||||||
*/
|
|
||||||
public class DimensionalCodeHelperTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void encode() throws Exception {
|
|
||||||
|
|
||||||
File file = file();
|
|
||||||
|
|
||||||
Map<EncodeHintType, Object> hints = new HashMap<>();
|
|
||||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
|
||||||
|
|
||||||
QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
|
||||||
BitMatrix encode = qrCodeWriter.encode("http://honyee.biz 宏义", BarcodeFormat.QR_CODE, 200, 200, hints);
|
|
||||||
|
|
||||||
assertNotNull(encode);
|
|
||||||
MatrixToImageWriter.writeToFile(encode, "png", file);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void decode() throws Exception {
|
|
||||||
|
|
||||||
File file = file();
|
|
||||||
|
|
||||||
QRCodeReader qrCodeReader = new QRCodeReader();
|
|
||||||
|
|
||||||
Map<DecodeHintType, Object> hints = new HashMap<>();
|
|
||||||
hints.put(DecodeHintType.CHARACTER_SET, "UTF-8");
|
|
||||||
|
|
||||||
LuminanceSource source = new BufferedImageLuminanceSource(ImageIO.read(file));
|
|
||||||
Binarizer binarizer = new HybridBinarizer(source);
|
|
||||||
BinaryBitmap image = new BinaryBitmap(binarizer);
|
|
||||||
|
|
||||||
Result result = qrCodeReader.decode(image, hints);
|
|
||||||
String text = result.getText();
|
|
||||||
System.out.println(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
private File file() throws IOException, URISyntaxException {
|
|
||||||
Resource resource = new ClassPathResource("dim-code.png");
|
|
||||||
return resource.getFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
|
||||||
* www.honyee.biz
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is the confidential and proprietary information of
|
|
||||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
|
||||||
* You shall not disclose such Confidential Information and shall use
|
|
||||||
* it only in accordance with the terms of the license agreement you
|
|
||||||
* entered into with Honyee Industry Group Co., Ltd.
|
|
||||||
*/
|
|
||||||
package cc.wdcy.infrastructure;
|
|
||||||
|
|
||||||
import cc.wdcy.domain.shared.GuidGenerator;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Shengzhao Li
|
|
||||||
*/
|
|
||||||
public class GuidTest {
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void guid() {
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
String generate = GuidGenerator.generate();
|
|
||||||
System.out.println(generate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
|
||||||
* www.honyee.biz
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is the confidential and proprietary information of
|
|
||||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
|
||||||
* You shall not disclose such Confidential Information and shall use
|
|
||||||
* it only in accordance with the terms of the license agreement you
|
|
||||||
* entered into with Honyee Industry Group Co., Ltd.
|
|
||||||
*/
|
|
||||||
package cc.wdcy.infrastructure;
|
|
||||||
|
|
||||||
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Shengzhao Li
|
|
||||||
*/
|
|
||||||
public class MD5Test {
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void encode() {
|
|
||||||
Md5PasswordEncoder encoder = new Md5PasswordEncoder();
|
|
||||||
String encode = encoder.encodePassword("honyee2013", null);
|
|
||||||
System.out.println(encode);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2013 Honyee Industry Group Co., Ltd
|
|
||||||
* www.honyee.biz
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is the confidential and proprietary information of
|
|
||||||
* Honyee Industry Group Co., Ltd ("Confidential Information").
|
|
||||||
* You shall not disclose such Confidential Information and shall use
|
|
||||||
* it only in accordance with the terms of the license agreement you
|
|
||||||
* entered into with Honyee Industry Group Co., Ltd.
|
|
||||||
*/
|
|
||||||
package cc.wdcy.infrastructure;
|
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import static org.testng.Assert.assertFalse;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Shengzhao Li
|
|
||||||
*/
|
|
||||||
public class MatchUtilsTest {
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isEmail() {
|
|
||||||
|
|
||||||
boolean result = MatchUtils.isEmail("addd");
|
|
||||||
assertFalse(result);
|
|
||||||
|
|
||||||
result = MatchUtils.isEmail("addd@honyee.cc");
|
|
||||||
assertTrue(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 345 B |
|
@ -8,8 +8,7 @@
|
||||||
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||||
<property name="locations">
|
<property name="locations">
|
||||||
<list>
|
<list>
|
||||||
<value>classpath:database.properties</value>
|
<value>classpath:test.properties</value>
|
||||||
<!--<value>classpath:mail.properties</value>-->
|
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
@ -45,20 +44,6 @@
|
||||||
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
|
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!--Mail configuration-->
|
|
||||||
<!--<bean id="javaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">-->
|
|
||||||
<!--<property name="host" value="${host.name}"/>-->
|
|
||||||
<!--<property name="port" value="${mail.smtp.port}"/>-->
|
|
||||||
<!--<property name="username" value="${mail.username}"/>-->
|
|
||||||
<!--<property name="password" value="${mail.password}"/>-->
|
|
||||||
|
|
||||||
<!--<property name="defaultEncoding" value="UTF-8"/>-->
|
|
||||||
<!--<property name="javaMailProperties">-->
|
|
||||||
<!--<props>-->
|
|
||||||
<!--<prop key="mail.smtp.auth">${mail.smtp.auth}</prop>-->
|
|
||||||
<!--</props>-->
|
|
||||||
<!--</property>-->
|
|
||||||
<!--</bean>-->
|
|
||||||
|
|
||||||
|
|
||||||
</beans>
|
</beans>
|
Loading…
Reference in New Issue