// Path: src/main/java/com/zlwh/hands/api/common/Constants.java
// public class Constants {
// 	
// 	//用户类型
// 	public static final String USER_TYPE_GUEST = "0";
// 	public static final String USER_TYPE_USER = "1";
// 	public static final String USER_TYPE_THIRDPARTY = "2";
// 	
// 	//用户状态
// 	public static final String USER_STATUS_NORMAL = "0";
// 	public static final String USER_STATUS_LOCK = "1";
// 	
// 	//会话状态
// 	public static final String SESSION_STATUS_LOGIN = "0";
// 	public static final String SESSION_STATUS_LOGOUT = "1";
// 	public static final String SESSION_STATUS_KICKOUT = "2";
// 	public static final String SESSION_STATUS_EXPIRE = "3";
// 	
// 	//设备类型
// 	public static final String DEVICE_TYPE_IPHONE = "0";
// 	public static final String DEVICE_TYPE_IPAD = "1";
// 	public static final String DEVICE_TYPE_IWATCH = "2";
// 	public static final String DEVICE_TYPE_ANDROID = "5";
// 	public static final String DEVICE_TYPE_ANDROID_PAD = "6";
// 	public static final String DEVICE_TYPE_ANDROID_WATCH = "7";
// 	
// 	//错误码
// 	public static final String ERRORCODE_INVALID_PARAM = "1000";
// 	public static final String ERRORCODE_AUTHENTICODE_TOO_FREQUENTLY = "1001";
// 	public static final String ERRORCODE_INVALID_PHONE_NUM = "1002";
// 	public static final String ERRORCODE_USER_EXIST = "1003";
// 	public static final String ERRORCODE_SIMPLE_PASSWORD = "1004";
// 	public static final String ERRORCODE_INVALID_AUTHENTICODE = "1005";
// 	public static final String ERRORCODE_INVALID_DEVICE_TYPE = "1006";
// 	public static final String ERRORCODE_INVALID_USERNAME_PASSWORD = "1007";
// 	public static final String ERRORCODE_USER_LOCKED = "1008";
// 	public static final String ERRORCODE_INVALID_TOKEN = "1009";
// 	public static final String ERRORCODE_NOT_LOGIN = "1010";
// 	public static final String ERRORCODE_SESSION_KICKOUT = "1011";
// 	public static final String ERRORCODE_SESSION_LOGOUT = "1012";
// 	public static final String ERRORCODE_SESSION_EXPIRE = "1013";
// 	
// }
// 
// Path: src/main/java/com/zlwh/hands/api/common/UserToken.java
// public class UserToken implements Serializable{
// 
// 	private static final long serialVersionUID = -2910636802113452789L;
// 	private String userId;
// 	private String sessionId;
// 	private String userType;
// 	private String loginName;
// 	private Long loginTime;
// 	
// 	public UserToken(String userId,String sessionId,String userType,String loginName,Long loginTime) {
// 		this.userId = userId;
// 		this.sessionId = sessionId;
// 		this.userType = userType;
// 		this.loginName = loginName;
// 		this.loginTime = loginTime;
// 	}
// 	
// 	public UserToken(String userId,String userType) {
// 		this(userId,null,userType,null,null);
// 	}
// 	
// 	public UserToken(String userId,String sessionId,String userType,Long loginTime) {
// 		this(userId,sessionId,userType,null,loginTime);
// 	}
// 
// 	public String getUserId() {
// 		return userId;
// 	}
// 
// 	public String getSessionId() {
// 		return sessionId;
// 	}
// 
// 	public String getUserType() {
// 		return userType;
// 	}
// 
// 	public String getLoginName() {
// 		return loginName;
// 	}
// 
// 	public Long getLoginTime() {
// 		return loginTime;
// 	}
// }


import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.InvalidSessionException;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.thinkgem.jeesite.common.security.Cryptos;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.zlwh.hands.api.common.Constants;
import com.zlwh.hands.api.common.UserToken;
		}
		StringBuilder tokenStr = new StringBuilder();
		tokenStr.append(ut.getUserId());
		tokenStr.append(SEPARATE);
		tokenStr.append(ut.getSessionId() == null ? "":ut.getSessionId());
		tokenStr.append(SEPARATE);
		tokenStr.append(ut.getUserType());
		tokenStr.append(SEPARATE);
		tokenStr.append(ut.getLoginName() == null ? "":ut.getLoginName());
		tokenStr.append(SEPARATE);
		tokenStr.append(ut.getLoginTime() == null ? "":ut.getLoginTime());
		logger.info("original token string :"+tokenStr);
		return Cryptos.aesEncrypt(tokenStr.toString(), ENCRYPT_KEY);
	}
	
	/**
	 * 解密Token
	 */
	public static UserToken decryptToken(String encrypt) {
		if (encrypt == null) {
			return null;
		}
		String[] tmpArray = null;
		try {
			String tokenStr = Cryptos.aesDecrypt(encrypt, ENCRYPT_KEY);
			tmpArray = tokenStr.split(SEPARATE);
		} catch (Exception e) {
			return null;
		}
		String userType = tmpArray[2];
// Path: src/main/java/com/zlwh/hands/api/common/Constants.java
// public class Constants {
// 	
// 	//用户类型
// 	public static final String USER_TYPE_GUEST = "0";
// 	public static final String USER_TYPE_USER = "1";
// 	public static final String USER_TYPE_THIRDPARTY = "2";
// 	
// 	//用户状态
// 	public static final String USER_STATUS_NORMAL = "0";
// 	public static final String USER_STATUS_LOCK = "1";
// 	
// 	//会话状态
// 	public static final String SESSION_STATUS_LOGIN = "0";
// 	public static final String SESSION_STATUS_LOGOUT = "1";
// 	public static final String SESSION_STATUS_KICKOUT = "2";
// 	public static final String SESSION_STATUS_EXPIRE = "3";
// 	
// 	//设备类型
// 	public static final String DEVICE_TYPE_IPHONE = "0";
// 	public static final String DEVICE_TYPE_IPAD = "1";
// 	public static final String DEVICE_TYPE_IWATCH = "2";
// 	public static final String DEVICE_TYPE_ANDROID = "5";
// 	public static final String DEVICE_TYPE_ANDROID_PAD = "6";
// 	public static final String DEVICE_TYPE_ANDROID_WATCH = "7";
// 	
// 	//错误码
// 	public static final String ERRORCODE_INVALID_PARAM = "1000";
// 	public static final String ERRORCODE_AUTHENTICODE_TOO_FREQUENTLY = "1001";
// 	public static final String ERRORCODE_INVALID_PHONE_NUM = "1002";
// 	public static final String ERRORCODE_USER_EXIST = "1003";
// 	public static final String ERRORCODE_SIMPLE_PASSWORD = "1004";
// 	public static final String ERRORCODE_INVALID_AUTHENTICODE = "1005";
// 	public static final String ERRORCODE_INVALID_DEVICE_TYPE = "1006";
// 	public static final String ERRORCODE_INVALID_USERNAME_PASSWORD = "1007";
// 	public static final String ERRORCODE_USER_LOCKED = "1008";
// 	public static final String ERRORCODE_INVALID_TOKEN = "1009";
// 	public static final String ERRORCODE_NOT_LOGIN = "1010";
// 	public static final String ERRORCODE_SESSION_KICKOUT = "1011";
// 	public static final String ERRORCODE_SESSION_LOGOUT = "1012";
// 	public static final String ERRORCODE_SESSION_EXPIRE = "1013";
// 	
// }
// 
// Path: src/main/java/com/zlwh/hands/api/common/UserToken.java
// public class UserToken implements Serializable{
// 
// 	private static final long serialVersionUID = -2910636802113452789L;
// 	private String userId;
// 	private String sessionId;
// 	private String userType;
// 	private String loginName;
// 	private Long loginTime;
// 	
// 	public UserToken(String userId,String sessionId,String userType,String loginName,Long loginTime) {
// 		this.userId = userId;
// 		this.sessionId = sessionId;
// 		this.userType = userType;
// 		this.loginName = loginName;
// 		this.loginTime = loginTime;
// 	}
// 	
// 	public UserToken(String userId,String userType) {
// 		this(userId,null,userType,null,null);
// 	}
// 	
// 	public UserToken(String userId,String sessionId,String userType,Long loginTime) {
// 		this(userId,sessionId,userType,null,loginTime);
// 	}
// 
// 	public String getUserId() {
// 		return userId;
// 	}
// 
// 	public String getSessionId() {
// 		return sessionId;
// 	}
// 
// 	public String getUserType() {
// 		return userType;
// 	}
// 
// 	public String getLoginName() {
// 		return loginName;
// 	}
// 
// 	public Long getLoginTime() {
// 		return loginTime;
// 	}
// }


// Path: src/main/java/com/zlwh/hands/api/common/utils/TokenUtils.java
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.InvalidSessionException;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.thinkgem.jeesite.common.security.Cryptos;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.zlwh.hands.api.common.Constants;
import com.zlwh.hands.api.common.UserToken;

		}
		StringBuilder tokenStr = new StringBuilder();
		tokenStr.append(ut.getUserId());
		tokenStr.append(SEPARATE);
		tokenStr.append(ut.getSessionId() == null ? "":ut.getSessionId());
		tokenStr.append(SEPARATE);
		tokenStr.append(ut.getUserType());
		tokenStr.append(SEPARATE);
		tokenStr.append(ut.getLoginName() == null ? "":ut.getLoginName());
		tokenStr.append(SEPARATE);
		tokenStr.append(ut.getLoginTime() == null ? "":ut.getLoginTime());
		logger.info("original token string :"+tokenStr);
		return Cryptos.aesEncrypt(tokenStr.toString(), ENCRYPT_KEY);
	}
	
	/**
	 * 解密Token
	 */
	public static UserToken decryptToken(String encrypt) {
		if (encrypt == null) {
			return null;
		}
		String[] tmpArray = null;
		try {
			String tokenStr = Cryptos.aesDecrypt(encrypt, ENCRYPT_KEY);
			tmpArray = tokenStr.split(SEPARATE);
		} catch (Exception e) {
			return null;
		}
		String userType = tmpArray[2];
		if (Constants.USER_TYPE_GUEST.equals(userType)) {