// 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;
package com.zlwh.hands.api.common.utils;



/**
 * 
 * UserToken工具类
 * 
 * 用户第一次访问时创建Token，该用户被标识为匿名用户
 * 用户登录时生成新的Token，该用户被标识为登录用户
 * 
 * @author yuanjifeng
 *
 */
public class TokenUtils {
	
	private static final Logger logger = LoggerFactory.getLogger(TokenUtils.class);
	
	private static final String ENCRYPT_KEY = "59FF4BEDF5155319CE6F39815653C60A";
	private static final String SEPARATE = ":";
	private static final String SESSION_KEY = "CUSERTOKEN";

	/**
	 * 加密Token
	 * ${userId}:${sessionId}:${userType}:${loginName}:${loginTime}
	 * 
	 */
// 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;

package com.zlwh.hands.api.common.utils;



/**
 * 
 * UserToken工具类
 * 
 * 用户第一次访问时创建Token，该用户被标识为匿名用户
 * 用户登录时生成新的Token，该用户被标识为登录用户
 * 
 * @author yuanjifeng
 *
 */
public class TokenUtils {
	
	private static final Logger logger = LoggerFactory.getLogger(TokenUtils.class);
	
	private static final String ENCRYPT_KEY = "59FF4BEDF5155319CE6F39815653C60A";
	private static final String SEPARATE = ":";
	private static final String SESSION_KEY = "CUSERTOKEN";

	/**
	 * 加密Token
	 * ${userId}:${sessionId}:${userType}:${loginName}:${loginTime}
	 * 
	 */
	public static String encryptToken(UserToken ut) {