Browse Source

APP基础功能

wanghui 8 years ago
parent
commit
dfe4b5b911

+ 1 - 1
src/main/java/com/goafanti/admin/controller/AdminApiController.java

@@ -456,7 +456,7 @@ public class AdminApiController extends CertifyApiController {
 		u.setPassword(passwordUtil.getEncryptPwd(u));
 		u.setLvl(UserLevel.GENERAL.getCode());
 		u.setAid(TokenManager.getAdminId());
-		userService.insertRegister(u, "", inputUser.getUnitName(), inputUser.getUsername());
+		userService.insertRegister(u,inputUser.getUnitName(), inputUser.getUsername());
 		return res;
 	}
 

+ 78 - 77
src/main/java/com/goafanti/app/controller/AppApiController.java

@@ -1,77 +1,78 @@
-package com.goafanti.app.controller;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.goafanti.achievement.service.AchievementService;
-import com.goafanti.activity.service.ActivityService;
-import com.goafanti.banners.enums.BannersType;
-import com.goafanti.banners.service.BannersService;
-import com.goafanti.common.bo.Result;
-import com.goafanti.common.constant.ErrorConstants;
-import com.goafanti.common.controller.BaseApiController;
-import com.goafanti.demand.service.DemandService;
-import com.goafanti.news.enums.NewsType;
-import com.goafanti.news.service.NewsService;
-
-@RestController
-@RequestMapping(path = "/api/portal/app", method = RequestMethod.GET)
-public class AppApiController extends BaseApiController {
-	@Resource
-	private BannersService		bannersService;
-	@Resource
-	private ActivityService		activityService;
-	@Resource
-	private NewsService			newsService;
-	@Resource
-	private AchievementService	achievementService;
-	@Resource
-	private DemandService		demandService;
-
-	@RequestMapping(value = "/index", method = RequestMethod.GET)
-	public Result index(HttpServletRequest request) {
-		Map<String, Object> result = new HashMap<>();
-		String domainName = request.getServerName();
-		result.put("banners", bannersService.findPortalBanners(BannersType.APP.getKey()));
-		result.put("activities", activityService.findPortalList(0, 3, null));
-		result.put("policies", newsService.findNewsList(0, NewsType.GJZC.getCode(), 3, domainName, true));
-		result.put("news", newsService.findNewsList(0, NewsType.JTDT.getCode(), 5, domainName, true));
-		return res().data(result);
-	}
-
-	/**
-	 * 科技成果详情
-	 */
-	@RequestMapping(value = "/achievementDetail", method = RequestMethod.GET)
-	public Result achievementDetail(String id) {
-		Result res = new Result();
-		if (StringUtils.isBlank(id)) {
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "成果ID"));
-			return res;
-		}
-		res.setData(achievementService.selectAchievementDetail(id));
-		return res;
-	}
-
-	/**
-	 * 科技需求详情
-	 */
-	@RequestMapping(value = "/demandDetail", method = RequestMethod.GET)
-	public Result demandDetail(String id) {
-		Result res = new Result();
-		if (StringUtils.isBlank(id)) {
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
-			return res;
-		}
-		res.setData(demandService.selectDemandDetail(id));
-		return res;
-	}
-}
+package com.goafanti.app.controller;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.goafanti.achievement.service.AchievementService;
+import com.goafanti.activity.service.ActivityService;
+import com.goafanti.banners.enums.BannersType;
+import com.goafanti.banners.service.BannersService;
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.controller.BaseApiController;
+import com.goafanti.demand.service.DemandService;
+import com.goafanti.news.enums.NewsType;
+import com.goafanti.news.service.NewsService;
+
+@RestController
+@RequestMapping(path = "/api/open/app", method = RequestMethod.GET)
+public class AppApiController extends BaseApiController {
+	@Resource
+	private BannersService		bannersService;
+	@Resource
+	private ActivityService		activityService;
+	@Resource
+	private NewsService			newsService;
+	@Resource
+	private AchievementService	achievementService;
+	@Resource
+	private DemandService		demandService;
+	@RequestMapping(value = "/index", method = RequestMethod.GET)
+	public Result index(HttpServletRequest request) {
+		Map<String, Object> result = new HashMap<>();
+		String domainName = request.getServerName();
+		result.put("banners", bannersService.findPortalBanners(BannersType.APP.getKey()));
+		result.put("activities", activityService.findPortalList(0, 3, null));
+		result.put("policies", newsService.findNewsList(0, NewsType.GJZC.getCode(), 3, domainName, true));
+		result.put("news", newsService.findNewsList(0, NewsType.JTDT.getCode(), 5, domainName, true));
+		return res().data(result);
+	}
+
+	/**
+	 * 科技成果详情
+	 */
+	@RequestMapping(value = "/achievementDetail", method = RequestMethod.GET)
+	public Result achievementDetail(String id) {
+		Result res = new Result();
+		if (StringUtils.isBlank(id)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "成果ID"));
+			return res;
+		}
+		res.setData(achievementService.selectAchievementDetail(id));
+		return res;
+	}
+
+	/**
+	 * 科技需求详情
+	 */
+	@RequestMapping(value = "/demandDetail", method = RequestMethod.GET)
+	public Result demandDetail(String id) {
+		Result res = new Result();
+		if (StringUtils.isBlank(id)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
+			return res;
+		}
+		res.setData(demandService.selectDemandDetail(id));
+		return res;
+	}
+	
+
+}

+ 73 - 59
src/main/java/com/goafanti/common/bo/Result.java

@@ -1,59 +1,73 @@
-package com.goafanti.common.bo;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Result {
-	private Object		data;
-	private List<Error>	error	= new ArrayList<Error>();
-
-	public Result() {
-	}
-
-	public Result(Object data) {
-		this.data = data;
-	}
-
-	/**
-	 * @return the data
-	 */
-	public Object getData() {
-		return data;
-	}
-
-	/**
-	 * @param data
-	 *            the data to set
-	 */
-	public void setData(Object data) {
-		this.data = data;
-	}
-
-	/**
-	 * @return the error
-	 */
-	public List<Error> getError() {
-		return error;
-	}
-
-	/**
-	 * @param error
-	 *            the error to set
-	 */
-	public void setError(List<Error> error) {
-		this.error = error;
-	}
-
-	public Result error(Error e) {
-		if (e != null) {
-			this.error.add(e);
-		}
-		return this;
-	}
-
-	public Result data(Object o) {
-		this.data = o;
-		return this;
-	}
-
-}
+package com.goafanti.common.bo;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.shiro.SecurityUtils;
+
+import com.goafanti.core.shiro.token.TokenManager;
+
+public class Result {
+	private Object		data;
+	private List<Error>	error	= new ArrayList<Error>();
+	private Serializable token;
+	public Result() {
+		/*if(TokenManager.isLogin())
+		this.token = SecurityUtils.getSubject().getSession().getId();*/
+	}
+
+	public Result(Object data) {
+		this.data = data;
+	}
+
+	/**
+	 * @return the data
+	 */
+	public Object getData() {
+		return data;
+	}
+
+	/**
+	 * @param data
+	 *            the data to set
+	 */
+	public void setData(Object data) {
+		this.data = data;
+	}
+
+	/**
+	 * @return the error
+	 */
+	public List<Error> getError() {
+		return error;
+	}
+
+	/**
+	 * @param error
+	 *            the error to set
+	 */
+	public void setError(List<Error> error) {
+		this.error = error;
+	}
+
+	public Result error(Error e) {
+		if (e != null) {
+			this.error.add(e);
+		}
+		return this;
+	}
+
+	public Result data(Object o) {
+		this.data = o;
+		return this;
+	}
+
+	public Serializable getToken() {
+		return token;
+	}
+
+	public void setToken(Serializable token) {
+		this.token = token;
+	}
+}

+ 35 - 1
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -419,7 +419,7 @@ public class PublicController extends BaseController {
 			return res;
 		}
 		if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.RESET_CODE).equals(resetCode)) {
-			res.getError().add(buildError(ErrorConstants.RESET_CODE_ERROR, "", "页面失效,请重新获取验证码!"));
+			res.getError().add(buildError(ErrorConstants.RESET_CODE_ERROR, "", "验证码错误,请重新获取验证码!"));
 			cleanCodeSession();
 			return res;
 		}
@@ -458,5 +458,39 @@ public class PublicController extends BaseController {
 		VerifyCodeUtils.clearMobileCode();
 		VerifyCodeUtils.clearMobileCodeTime();
 	}
+	
+	/**
+	 * APP手机验证码
+	 * 
+	 * @param mobile
+	 * @param sign
+	 *            是否用与找回密码
+	 * @param type
+	 * @return
+	 */
+	@RequestMapping(value = "/getAppMCode", method = RequestMethod.GET)
+	@ResponseBody
+	public Result getAppMcode(String mobile, boolean sign, Integer type) {
+		Result res = new Result();
+		// 用于找回密码
+		if (sign) {
+			if (null == userService.selectByMobieAndType(mobile.trim(), type)) {
+				res.getError().add(buildError(ErrorConstants.NON_REGISTER, "", "该用户未注册!"));
+				return res;
+			}
+		}
+		if (TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE_TIME) == null
+				|| TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE_TIME) == "") {
+			sendMessage(mobile, res);
+		} else if (TimeUtils.checkOverTime("getMCode")) {
+			VerifyCodeUtils.clearMobileCode();
+			VerifyCodeUtils.clearMobileCodeTime();
+			sendMessage(mobile, res);
+		} else {
+			res.getError().add(buildError(ErrorConstants.MCODE_FREQUENCY_ERROR, "", "手机验证码发送频繁!"));
+		}
 
+		return res;
+	}
+	
 }

+ 2 - 2
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -347,12 +347,12 @@
 	
 	<select id="findCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
 		select id,identify_name as name from user where identify_name like
-		concat('%',#{identifyName},'%') and status <![CDATA[!= ]]> 2
+		concat('%',#{identifyName},'%') and status <![CDATA[!= ]]> 1
 	</select>
 	
 	<select id="judgeCustomerByName" resultType="java.lang.Integer">
 		select count(0) from user where identify_name = #{identifyName,jdbcType=VARCHAR}
-		and status <![CDATA[!= ]]> 2
+		and status <![CDATA[!= ]]> 1
 	</select>
 	
 	<select id="findOrganizationCustomerDetail" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerOrganizationDetailBo">

+ 43 - 44
src/main/java/com/goafanti/core/shiro/filter/LoginFilter.java

@@ -1,44 +1,43 @@
-package com.goafanti.core.shiro.filter;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.shiro.web.filter.AccessControlFilter;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.goafanti.common.bo.Error;
-import com.goafanti.common.bo.Result;
-import com.goafanti.common.utils.LoggerUtils;
-import com.goafanti.core.shiro.token.TokenManager;
-
-public class LoginFilter extends AccessControlFilter {
-	final static Class<LoginFilter>	CLASS	= LoginFilter.class;
-
-	@Autowired
-	private ShiroFilterUtils		shiroFilterUtils;
-
-	@Override
-	protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
-			throws Exception {
-
-		if (TokenManager.isLogin()) {
-			return Boolean.TRUE;
-		}
-		return Boolean.FALSE;
-	}
-
-	@Override
-	protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
-		// 保存Request和Response 到登录后的链接
-		if (!shiroFilterUtils.isAjax((HttpServletRequest) request)) {
-			saveRequestAndRedirectToLogin(request, response);
-		} else {
-			LoggerUtils.debug(getClass(), "当前用户没有登录,并且是Ajax请求!");
-			shiroFilterUtils.out((HttpServletResponse) response, new Result().error(new Error("", "403", "当前用户没有登录!")));
-		}
-		return Boolean.FALSE;
-	}
-
-}
+package com.goafanti.core.shiro.filter;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.shiro.web.filter.AccessControlFilter;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.goafanti.common.bo.Error;
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.utils.LoggerUtils;
+import com.goafanti.core.shiro.token.TokenManager;
+
+public class LoginFilter extends AccessControlFilter {
+	final static Class<LoginFilter>	CLASS	= LoginFilter.class;
+
+	@Autowired
+	private ShiroFilterUtils		shiroFilterUtils;
+
+	@Override
+	protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
+			throws Exception {
+		if (TokenManager.isLogin()) {
+			return Boolean.TRUE;
+		}
+		return Boolean.FALSE;
+	}
+
+	@Override
+	protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
+		// 保存Request和Response 到登录后的链接
+		if (!shiroFilterUtils.isAjax((HttpServletRequest) request)) {
+			saveRequestAndRedirectToLogin(request, response);
+		} else {
+			LoggerUtils.debug(getClass(), "当前用户没有登录,并且是Ajax请求!");
+			shiroFilterUtils.out((HttpServletResponse) response, new Result().error(new Error("", "403", "当前用户没有登录!")));
+		}
+		return Boolean.FALSE;
+	}
+
+}

+ 201 - 211
src/main/java/com/goafanti/core/shiro/session/CustomSessionManager.java

@@ -1,211 +1,201 @@
-package com.goafanti.core.shiro.session;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.shiro.session.Session;
-import org.apache.shiro.subject.SimplePrincipalCollection;
-import org.apache.shiro.subject.support.DefaultSubjectContext;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.goafanti.common.constant.ShiroConstants;
-import com.goafanti.common.model.AftUser;
-import com.goafanti.common.utils.ArrayUtils;
-import com.goafanti.common.utils.LoggerUtils;
-import com.goafanti.core.shiro.CustomShiroSessionDAO;
-
-public class CustomSessionManager {
-
-	/**
-	 * session status
-	 */
-	@Autowired
-	ShiroSessionRepository	shiroSessionRepository;
-
-	@Autowired
-	CustomShiroSessionDAO	customShiroSessionDAO;
-
-	// /**
-	// * 获取所有的有效Session用户
-	// *
-	// * @return
-	// */
-	// public List<UserOnlineBo> getAllUser() {
-	// // 获取所有session
-	// Collection<Session> sessions = customShiroSessionDAO.getActiveSessions();
-	// List<UserOnlineBo> list = new ArrayList<UserOnlineBo>();
-	//
-	// for (Session session : sessions) {
-	// UserOnlineBo bo = getSessionBo(session);
-	// if (null != bo) {
-	// list.add(bo);
-	// }
-	// }
-	// return list;
-	// }
-
-	/**
-	 * 根据ID查询 SimplePrincipalCollection
-	 * 
-	 * @param userIds
-	 *            用户ID
-	 * @return
-	 */
-	@SuppressWarnings("unchecked")
-	public List<SimplePrincipalCollection> getSimplePrincipalCollectionByUserId(String... userIds) {
-		// 把userIds 转成Set,好判断
-		Set<String> idset = (Set<String>) ArrayUtils.array2Set(userIds);
-		// 获取所有session
-		Collection<Session> sessions = customShiroSessionDAO.getActiveSessions();
-		// 定义返回
-		List<SimplePrincipalCollection> list = new ArrayList<SimplePrincipalCollection>();
-		for (Session session : sessions) {
-			// 获取SimplePrincipalCollection
-			Object obj = session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
-			if (null != obj && obj instanceof SimplePrincipalCollection) {
-				// 强转
-				SimplePrincipalCollection spc = (SimplePrincipalCollection) obj;
-				// 判断用户,匹配用户ID。
-				obj = spc.getPrimaryPrincipal();
-				if (null != obj && obj instanceof AftUser) {
-					AftUser user = (AftUser) obj;
-					// 比较用户ID,符合即加入集合
-					if (null != user && idset.contains(user.getId())) {
-						list.add(spc);
-					}
-				}
-			}
-		}
-		return list;
-	}
-
-	// /**
-	// * 获取单个Session
-	// *
-	// * @param sessionId
-	// * @return
-	// */
-	// public UserOnlineBo getSession(String sessionId) {
-	// Session session = shiroSessionRepository.getSession(sessionId);
-	// UserOnlineBo bo = getSessionBo(session);
-	// return bo;
-	// }
-
-	// private UserOnlineBo getSessionBo(Session session) {
-	// // 获取session登录信息。
-	// Object obj =
-	// session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
-	// if (null == obj) {
-	// return null;
-	// }
-	// // 确保是 SimplePrincipalCollection对象。
-	// if (obj instanceof SimplePrincipalCollection) {
-	// SimplePrincipalCollection spc = (SimplePrincipalCollection) obj;
-	// /**
-	// * 获取用户登录的,@link UserRealm.doGetAuthenticationInfo(...)方法中 return
-	// * new SimpleAuthenticationInfo(user,user.getPwd(),
-	// * getName());的user 对象。
-	// */
-	// obj = spc.getPrimaryPrincipal();
-	// if (null != obj && obj instanceof User) {
-	// // 存储session + user 综合信息
-	// UserOnlineBo userBo = new UserOnlineBo((User) obj);
-	// // 最后一次和系统交互的时间
-	// userBo.setLastAccess(session.getLastAccessTime());
-	// // 主机的ip地址
-	// userBo.setHost(session.getHost());
-	// // session ID
-	// userBo.setSessionId(session.getId().toString());
-	// // 回话到期 ttl(ms)
-	// userBo.setTimeout(session.getTimeout());
-	// // session创建时间
-	// userBo.setStartTime(session.getStartTimestamp());
-	// // 是否踢出
-	// SessionStatus sessionStatus = (SessionStatus)
-	// session.getAttribute(ShiroConstants.SESSION_STATUS);
-	// boolean status = Boolean.TRUE;
-	// if (null != sessionStatus) {
-	// status = sessionStatus.getOnlineStatus();
-	// }
-	// userBo.setSessionStatus(status);
-	// return userBo;
-	// }
-	// }
-	// return null;
-	// }
-
-	/**
-	 * 改变Session状态
-	 * 
-	 * @param status
-	 *            {true:踢出,false:激活}
-	 * @param sessionId
-	 * @return
-	 */
-	public Map<String, Object> changeSessionStatus(Boolean status, String sessionIds) {
-		Map<String, Object> map = new HashMap<String, Object>();
-		try {
-			String[] sessionIdArray = null;
-			if (sessionIds.indexOf(",") == -1) {
-				sessionIdArray = new String[] { sessionIds };
-			} else {
-				sessionIdArray = sessionIds.split(",");
-			}
-			for (String id : sessionIdArray) {
-				Session session = shiroSessionRepository.getSession(id);
-				SessionStatus sessionStatus = new SessionStatus();
-				sessionStatus.setOnlineStatus(status);
-				session.setAttribute(ShiroConstants.SESSION_STATUS, sessionStatus);
-				customShiroSessionDAO.update(session);
-			}
-			map.put("status", 200);
-			map.put("sessionStatus", status ? 1 : 0);
-			map.put("sessionStatusText", status ? "踢出" : "激活");
-			map.put("sessionStatusTextTd", status ? "有效" : "已踢出");
-		} catch (Exception e) {
-			LoggerUtils.fmtError(getClass(), e, "改变Session状态错误,sessionId[%s]", sessionIds);
-			map.put("status", 500);
-			map.put("message", "改变失败,有可能Session不存在,请刷新再试!");
-		}
-		return map;
-	}
-
-	// /**
-	// * 查询要禁用的用户是否在线。
-	// *
-	// * @param id
-	// * 用户ID
-	// * @param status
-	// * 用户状态
-	// */
-	// public void forbidUserById(Long id, Integer status) {
-	// // 获取所有在线用户
-	// for (UserOnlineBo bo : getAllUser()) {
-	// Long userId = bo.getId();
-	// // 匹配用户ID
-	// if (userId.equals(id)) {
-	// // 获取用户Session
-	// Session session = shiroSessionRepository.getSession(bo.getSessionId());
-	// // 标记用户Session
-	// SessionStatus sessionStatus = (SessionStatus)
-	// session.getAttribute(ShiroConstants.SESSION_STATUS);
-	// // 是否踢出 true:有效,false:踢出。
-	// sessionStatus.setOnlineStatus(status == 1);
-	// // 更新Session
-	// customShiroSessionDAO.update(session);
-	// }
-	// }
-	// }
-
-	public void setShiroSessionRepository(ShiroSessionRepository shiroSessionRepository) {
-		this.shiroSessionRepository = shiroSessionRepository;
-	}
-
-	public void setCustomShiroSessionDAO(CustomShiroSessionDAO customShiroSessionDAO) {
-		this.customShiroSessionDAO = customShiroSessionDAO;
-	}
-}
+package com.goafanti.core.shiro.session;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Date;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.shiro.session.InvalidSessionException;
+import org.apache.shiro.session.Session;
+import org.apache.shiro.session.UnknownSessionException;
+import org.apache.shiro.session.mgt.SessionContext;
+import org.apache.shiro.session.mgt.SessionKey;
+import org.apache.shiro.session.mgt.SimpleSession;
+import org.apache.shiro.web.servlet.Cookie;
+import org.apache.shiro.web.servlet.ShiroHttpServletRequest;
+import org.apache.shiro.web.servlet.SimpleCookie;
+import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
+import org.apache.shiro.web.util.WebUtils;
+
+import com.goafanti.common.utils.StringUtils;
+
+public class CustomSessionManager extends DefaultWebSessionManager {
+	public CustomSessionManager() {
+		super();
+	}
+
+	@Override
+	protected Serializable getSessionId(ServletRequest request, ServletResponse response) {
+		String sid = request.getParameter("token");
+		if (StringUtils.isNotBlank(sid)) {
+			// 是否将sid保存到cookie,浏览器模式下使用此参数。
+			if (WebUtils.isTrue(request, "AFT_SID")) {
+				HttpServletRequest rq = (HttpServletRequest) request;
+				HttpServletResponse rs = (HttpServletResponse) response;
+				Cookie template = getSessionIdCookie();
+				Cookie cookie = new SimpleCookie(template);
+				cookie.setValue(sid);
+				cookie.saveTo(rq, rs);
+			}
+			// 设置当前session状态
+			request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE, ShiroHttpServletRequest.URL_SESSION_ID_SOURCE);
+			request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID, sid);
+			request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_IS_VALID, Boolean.TRUE);
+			return sid;
+		} else {
+			return super.getSessionId(request, response);
+		}
+	}
+
+	@Override
+	public void validateSessions() {
+		super.validateSessions();
+	}
+
+	protected Session retrieveSession(SessionKey sessionKey) {
+		try {
+			return super.retrieveSession(sessionKey);
+		} catch (UnknownSessionException e) {
+			// 获取不到SESSION不抛出异常
+			return null;
+		}
+	}
+
+	public Date getStartTimestamp(SessionKey key) {
+		try {
+			return super.getStartTimestamp(key);
+		} catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+			return null;
+		}
+	}
+
+	public Date getLastAccessTime(SessionKey key) {
+		try {
+			return super.getLastAccessTime(key);
+		} catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+			return null;
+		}
+	}
+
+	public long getTimeout(SessionKey key) {
+		try {
+			return super.getTimeout(key);
+		} catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+			return 0;
+		}
+	}
+
+	public void setTimeout(SessionKey key, long maxIdleTimeInMillis) {
+		try {
+			super.setTimeout(key, maxIdleTimeInMillis);
+		} catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+		}
+	}
+
+	public void touch(SessionKey key) {
+		try {
+			super.touch(key);
+		} catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+		}
+	}
+
+	public String getHost(SessionKey key) {
+		try {
+			return super.getHost(key);
+		} catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+			return null;
+		}
+	}
+
+	public Collection<Object> getAttributeKeys(SessionKey key) {
+		try {
+			return super.getAttributeKeys(key);
+		} catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+			return null;
+		}
+	}
+
+	public Object getAttribute(SessionKey sessionKey, Object attributeKey) {
+		try {
+			return super.getAttribute(sessionKey, attributeKey);
+		} catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+			return null;
+		}
+	}
+
+	public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) {
+		try {
+			super.setAttribute(sessionKey, attributeKey, value);
+		} catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+		}
+	}
+
+	public Object removeAttribute(SessionKey sessionKey, Object attributeKey) {
+		try {
+			return super.removeAttribute(sessionKey, attributeKey);
+		} catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+			return null;
+		}
+	}
+
+	public void stop(SessionKey key) {
+		try {
+			super.stop(key);
+		} catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+		}
+	}
+
+	public void checkValid(SessionKey key) {
+		try {
+			super.checkValid(key);
+		} catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+		}
+	}
+
+	@Override
+	protected Session doCreateSession(SessionContext context) {
+		try {
+			return super.doCreateSession(context);
+		} catch (IllegalStateException e) {
+			return null;
+		}
+	}
+
+	@Override
+	protected Session newSessionInstance(SessionContext context) {
+		Session session = super.newSessionInstance(context);
+		session.setTimeout(getGlobalSessionTimeout());
+		return session;
+	}
+
+	@Override
+	public Session start(SessionContext context) {
+		try {
+			return super.start(context);
+		} catch (NullPointerException e) {
+			SimpleSession session = new SimpleSession();
+			session.setId(0);
+			return session;
+		}
+	}
+
+	public Session getSession(String sessionId) {
+		return sessionDAO.readSession(sessionId);
+	}
+}

+ 118 - 116
src/main/java/com/goafanti/user/controller/UserLoginController.java

@@ -1,116 +1,118 @@
-package com.goafanti.user.controller;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.shiro.web.util.SavedRequest;
-import org.apache.shiro.web.util.WebUtils;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.servlet.ModelAndView;
-import org.springframework.web.servlet.view.RedirectView;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.goafanti.common.bo.Result;
-import com.goafanti.common.constant.ErrorConstants;
-import com.goafanti.common.controller.BaseController;
-import com.goafanti.common.model.Admin;
-import com.goafanti.common.model.User;
-import com.goafanti.common.utils.TimeUtils;
-import com.goafanti.common.utils.VerifyCodeUtils;
-import com.goafanti.core.shiro.token.TokenManager;
-import com.goafanti.user.service.UserService;
-
-@Controller
-public class UserLoginController extends BaseController {
-	@Resource
-	private UserService userService;
-
-	@RequestMapping(value = "/login", method = RequestMethod.GET)
-	@ResponseBody
-	public Result login(HttpServletRequest request, Model model) {
-		Result res = new Result();
-		TokenManager.logout();
-		return res;
-	}
-
-	@RequestMapping(value = "/login", method = RequestMethod.POST)
-	public ModelAndView doLogin(User user, Boolean rememberMe, HttpServletRequest request, ModelAndView modelview) {
-		TokenManager.login(user, rememberMe);
-		RedirectView rv = new RedirectView();
-		rv.setUrl(request.getContextPath() + "/index");
-		rv.setExposeModelAttributes(false);
-		modelview.setView(rv);
-		return modelview;
-	}
-
-	/**
-	 * 用户登录
-	 * 
-	 * @param user
-	 * @param remember
-	 * @param request
-	 * @return
-	 */
-	@RequestMapping(value = "/signin", method = RequestMethod.POST)
-	@ResponseBody
-	public Result signin(User user, Boolean remember, HttpServletRequest request) {
-		Result res = new Result();
-		JSONObject jo = (JSONObject) JSON.toJSON(TokenManager.login(user, remember));
-		SavedRequest sr = WebUtils.getAndClearSavedRequest(request);
-		if (sr != null) {
-			jo.put("requestURI", sr.getRequestURI());
-			jo.put("queryString", sr.getQueryString());
-		}
-		res.setData(jo);
-		return res;
-	}
-
-	/**
-	 * 管理端登录
-	 * 
-	 * @param user
-	 * @param remember
-	 * @param request
-	 * @return
-	 */
-	@RequestMapping(value = "/managesignin", method = RequestMethod.POST)
-	@ResponseBody
-	public Result managesignin(Admin admin, Boolean remember, HttpServletRequest request) {
-		Result res = new Result();
-		res.setData(TokenManager.manageLogin(admin, remember));
-		return res;
-	}
-
-	/**
-	 * 忘记密码 使用手机号+手机验证码登录
-	 * 
-	 * @param mobile
-	 * @param mobileCode
-	 * @param type
-	 * @return
-	 */
-	@RequestMapping(value = "/mobileSigin", method = RequestMethod.POST)
-	@ResponseBody
-	public Result mobileSignIn(User user, String mobileCode) {
-		Result res = new Result();
-		if (StringUtils.isBlank(user.getMobile())) {
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "必须指定", "手机号"));
-			return res;
-		}
-		if (TimeUtils.checkOverTime("register")) {
-			res.getError().add(buildError(ErrorConstants.MCODE_OVERTIME_ERROR, "手机验证码超时失效"));
-			return res;
-		}
-		if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE).equals(mobileCode)) {
-			res.getError().add(buildError(ErrorConstants.MCODE_ERROR, "手机验证码错误"));
-			return res;
-		}
-		return res;
-	}
-}
+package com.goafanti.user.controller;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.web.util.SavedRequest;
+import org.apache.shiro.web.util.WebUtils;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.view.RedirectView;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.controller.BaseController;
+import com.goafanti.common.model.Admin;
+import com.goafanti.common.model.User;
+import com.goafanti.common.utils.TimeUtils;
+import com.goafanti.common.utils.VerifyCodeUtils;
+import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.user.service.UserService;
+
+@Controller
+public class UserLoginController extends BaseController {
+	@Resource
+	private UserService userService;
+
+	@RequestMapping(value = "/login", method = RequestMethod.GET)
+	@ResponseBody
+	public Result login(HttpServletRequest request, Model model) {
+		Result res = new Result();
+		TokenManager.logout();
+		return res;
+	}
+
+	@RequestMapping(value = "/login", method = RequestMethod.POST)
+	public ModelAndView doLogin(User user, Boolean rememberMe, HttpServletRequest request, ModelAndView modelview) {
+		TokenManager.login(user, rememberMe);
+		RedirectView rv = new RedirectView();
+		rv.setUrl(request.getContextPath() + "/index");
+		rv.setExposeModelAttributes(false);
+		modelview.setView(rv);
+		return modelview;
+	}
+
+	/**
+	 * 用户登录
+	 * 
+	 * @param user
+	 * @param remember
+	 * @param request
+	 * @return
+	 */
+	@RequestMapping(value = "/signin", method = RequestMethod.POST)
+	@ResponseBody
+	public Result signin(User user, Boolean remember, HttpServletRequest request) {
+		Result res = new Result();
+		JSONObject jo = (JSONObject) JSON.toJSON(TokenManager.login(user, remember));
+		SavedRequest sr = WebUtils.getAndClearSavedRequest(request);
+		if (sr != null) {
+			jo.put("requestURI", sr.getRequestURI());
+			jo.put("queryString", sr.getQueryString());
+		}
+		res.setToken(SecurityUtils.getSubject().getSession().getId());
+		res.setData(jo);
+		return res;
+	}
+
+	/**
+	 * 管理端登录
+	 * 
+	 * @param user
+	 * @param remember
+	 * @param request
+	 * @return
+	 */
+	@RequestMapping(value = "/managesignin", method = RequestMethod.POST)
+	@ResponseBody
+	public Result managesignin(Admin admin, Boolean remember, HttpServletRequest request) {
+		Result res = new Result();
+		res.setData(TokenManager.manageLogin(admin, remember));
+		return res;
+	}
+
+	/**
+	 * 忘记密码 使用手机号+手机验证码登录
+	 * 
+	 * @param mobile
+	 * @param mobileCode
+	 * @param type
+	 * @return
+	 */
+	@RequestMapping(value = "/mobileSigin", method = RequestMethod.POST)
+	@ResponseBody
+	public Result mobileSignIn(User user, String mobileCode) {
+		Result res = new Result();
+		if (StringUtils.isBlank(user.getMobile())) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "必须指定", "手机号"));
+			return res;
+		}
+		if (TimeUtils.checkOverTime("register")) {
+			res.getError().add(buildError(ErrorConstants.MCODE_OVERTIME_ERROR, "手机验证码超时失效"));
+			return res;
+		}
+		if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE).equals(mobileCode)) {
+			res.getError().add(buildError(ErrorConstants.MCODE_ERROR, "手机验证码错误"));
+			return res;
+		}
+		return res;
+	}
+}

+ 9 - 2
src/main/java/com/goafanti/user/controller/UserRegisterController.java

@@ -20,6 +20,7 @@ import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseController;
 import com.goafanti.common.enums.UserFields;
+import com.goafanti.common.enums.UserLevel;
 import com.goafanti.common.model.User;
 import com.goafanti.common.utils.PasswordUtil;
 import com.goafanti.common.utils.TimeUtils;
@@ -77,7 +78,7 @@ public class UserRegisterController extends BaseController {
 		} else {
 			User u = userService.selectByMobieAndType(user.getMobile().trim(), user.getType());
 			if (null != u) {
-					res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "用户已存在"));
+					res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "用户已存在"));
 			}
 		}
 		if (res.getError().isEmpty()) {
@@ -89,9 +90,15 @@ public class UserRegisterController extends BaseController {
 			Calendar now = Calendar.getInstance();
 			now.set(Calendar.MILLISECOND, 0);
 			us.setCreateTime(now.getTime());
+			us.setUpdateTime(now.getTime());
 			us.setPassword(passwordUtil.getEncryptPwd(us));
 			us.setLvl(0);
 			us.setSource(AFTConstants.USER_SOURCE_REGISTER);
+			us.setIsMember(AFTConstants.NO);
+			us.setStatus(AFTConstants.USER_STATUS_NORMAL);
+			us.setShareType(AFTConstants.USER_SHARE_PUBLIC);
+			us.setIdentifyName(StringUtils.isBlank(companyName)?"":companyName);
+			us.setLvl(UserLevel.GENERAL.getCode());
 			/*
 			List<Admin> admins = adminService.selectAllAdmin();
 			if (!admins.isEmpty()) {
@@ -100,7 +107,7 @@ public class UserRegisterController extends BaseController {
 			}
 			*/
 			us.setAid("2");//ID为"2"的管理员
-			userService.insertRegister(us, contacts, companyName, user.getUsername());
+			userService.insertRegister(us,companyName,contacts);
 		}
 
 		return res;

+ 1 - 1
src/main/java/com/goafanti/user/service/UserService.java

@@ -26,7 +26,7 @@ public interface UserService {
 
 	User selectByMobieAndType(String mobile, Integer type);
 
-	User insertRegister(User user, String companyName, String contacts, String username);
+	User insertRegister(User user, String unitName, String contacts);
 
 	UserPageHomeBo selectUserPageHomeBoByUserId(String userId);
 

+ 2 - 2
src/main/java/com/goafanti/user/service/impl/UserServiceImpl.java

@@ -56,7 +56,7 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 	private OrgIntellectualPropertyMapper	orgIntellectualPropertyMapper;
 
 	@Override
-	public User insertRegister(User user, String contacts, String unitName, String username) {
+	public User insertRegister(User user, String unitName, String contacts) {
 		userMapper.insert(user);
 		if (null != user.getType() && UserType.ORGANIZATION.getCode().equals(user.getType())) {
 			OrganizationIdentity organizationIdentity = new OrganizationIdentity();
@@ -80,7 +80,7 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 			ui.setAuditStatus(0);
 			ui.setProcess(0);
 			ui.setWrongCount(0);
-			ui.setUsername(StringUtils.isBlank(username) ? "" : username);
+			ui.setUsername(StringUtils.isBlank(unitName) ? "" : unitName);
 			userIdentityMapper.insert(ui);
 		}
 

+ 1 - 1
src/main/resources/props/error.properties

@@ -81,7 +81,7 @@ MCODE_EMPTY_ERROR=\u624B\u673A\u9A8C\u8BC1\u7801\u4E0D\u80FD\u4E3A\u7A7A\uFF01
 
 MCODE_OVERTIME_ERROR=\u624B\u673A\u9A8C\u8BC1\u7801\u8D85\u65F6\u5931\u6548\uFF01
 
-RESET_CODE_ERROR=\u9875\u9762\u5931\u6548,\u8BF7\u91CD\u65B0\u83B7\u53D6\u9A8C\u8BC1\u7801\uFF01
+RESET_CODE_ERROR=\u9A8C\u8BC1\u7801\u9519\u8BEF,\u8BF7\u91CD\u65B0\u83B7\u53D6\u9A8C\u8BC1\u7801\uFF01
 
 RESET_CODE_OVERTIME=\u9875\u9762\u8D85\u65F6\u5931\u6548,\u8BF7\u91CD\u65B0\u83B7\u53D6\u9A8C\u8BC1\u7801\uFF01
 

+ 32 - 32
src/main/resources/shiro_base_auth.ini

@@ -1,32 +1,32 @@
-[base_auth]
-/=anon
-/index=anon
-/login=anon
-/user/subscriberDetail=anon
-/user/subscriberDetail.html=anon
-/user/login.html=anon
-/user/login=anon
-/user/msignIn=anon
-/user/msignIn.html=anon
-/user/login=anon
-/user/signIn.html=anon
-/admin/login=anon
-/admin/login.html=anon
-/admin/set.html=admin
-/admin/index.html=admin
-/signin=anon
-/managesignin=anon
-/register=anon
-/open/**=anon
-/favicon.ico=anon
-/static/**=anon
-/portal/**=anon
-/api/portal/**=anon
-/api/admin/**=admin,permission
-/api/user/partner/**=anon
-/api/user/**=login
-/admin/servicesManage/**=admin
-/admin/**=admin,permission
-/role/**=admin,permission
-/permission/**=admin,permission
-/**=login
+[base_auth]
+/=anon
+/index=anon
+/login=anon
+/user/subscriberDetail=anon
+/user/subscriberDetail.html=anon
+/user/login.html=anon
+/user/login=anon
+/user/msignIn=anon
+/user/msignIn.html=anon
+/user/login=anon
+/user/signIn.html=anon
+/admin/login=anon
+/admin/login.html=anon
+/admin/set.html=admin
+/admin/index.html=admin
+/signin=anon
+/managesignin=anon
+/register=anon
+/open/**=anon
+/favicon.ico=anon
+/static/**=anon
+/portal/**=anon
+/api/portal/**=anon
+/api/admin/**=admin,permission
+/api/user/partner/**=anon
+/api/user/**=login
+/admin/servicesManage/**=admin
+/admin/**=admin,permission
+/role/**=admin,permission
+/permission/**=admin,permission
+/**=login

+ 163 - 163
src/main/resources/spring/spring-shiro.xml

@@ -1,164 +1,164 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
-	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
-	xmlns:context="http://www.springframework.org/schema/context"
-	xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
-       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
-       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
-
-	<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
-		<property name="maxIdle" value="100" />
-		<property name="minIdle" value="10" />
-		<property name="testOnBorrow" value="true" />
-	</bean>
-
-	<bean id="redisConnectionFactory"
-		class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
-		<property name="hostName" value="${jedis.host}" />
-		<property name="port" value="${jedis.port}" />
-		<property name="password" value="${jedis.password}" />
-		<property name="timeout" value="${jedis.timeout}" />
-		<property name="poolConfig" ref="jedisPoolConfig" />
-		<!-- <property name="database" value="${jedis.dbIndex}" /> -->
-	</bean>
-
-	<bean id="redisTemplate" class="com.goafanti.core.cache.template.FastJsonRedisTemplate">
-		<constructor-arg index="0" ref="redisConnectionFactory" />
-	</bean>
-	
-    <bean id="jedisQueueListener" class="com.goafanti.easemob.queue.EasemobRedisQueueListener"/>  
-    
-    
-    <bean id="jedisQueue" class="com.goafanti.easemob.queue.EasemobRedisQueue" destroy-method="destroy">  
-        <property name="redisTemplate" ref="redisTemplate"></property>  
-        <property name="key" value="easemob:queue"></property>  
-        <property name="listener" ref="jedisQueueListener"></property>  
-    </bean> 
-    
-    <bean id="easemobUtils" class="com.goafanti.easemob.EasemobUtils"/>
-      
-
-	<bean id="sessionRedisTemplate" class="com.goafanti.core.shiro.cache.template.SessionRedisTemplate">
-		<constructor-arg index="0" ref="redisConnectionFactory" />
-	</bean>
-
-	<bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager">
-		<constructor-arg index="0" ref="redisTemplate" />
-		<property name="defaultExpiration" value="86400" />		
-	</bean>
-	
-	<bean id="shrioRedisCacheManager" class="com.goafanti.core.shiro.cache.ShiroRedisCacheManager">
-		<property name="redisTemplate" ref="sessionRedisTemplate" />
-		<property name="expire" value="2592000" />
-	</bean>
-
-	<bean id="sessionIdGenerator"
-		class="org.apache.shiro.session.mgt.eis.JavaUuidSessionIdGenerator" />
-
-
-	<bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
-		<constructor-arg value="AFT_SID" />
-		<property name="httpOnly" value="true" />
-		<property name="maxAge" value="2592000" />
-		<!-- <property name="domain" value=""/> -->
-	</bean>
-
-	<bean id="customSessionListener" class="com.goafanti.core.shiro.listener.CustomSessionListener">
-		<property name="redisTemplate" ref="sessionRedisTemplate" />
-	</bean>
-
-	<bean id="enterpriseCacheSessionDAO"
-		class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO">
-		<property name="sessionIdGenerator" ref="sessionIdGenerator" />
-	</bean>
-
-	<!-- -->
-	<bean id="sessionValidationScheduler"
-		class="org.apache.shiro.session.mgt.ExecutorServiceSessionValidationScheduler">
-		<!-- -->
-		<property name="interval" value="${session.validate.timespan}" />
-		<property name="sessionManager" ref="sessionManager" />
-	</bean>
-	<!-- -->
-	<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
-		<property name="realm" ref="userRealm" />
-		<property name="sessionManager" ref="sessionManager" />
-		<property name="cacheManager" ref="shrioRedisCacheManager" />
-	</bean>
-
-	<bean id="authorizationAttributeSourceAdvisor"
-		class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
-		<property name="securityManager" ref="securityManager" />
-	</bean>
-
-	<!-- credential matcher -->
-	<bean id="credentialsMatcher"
-		class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
-		<property name="hashAlgorithmName" value="${pwd.hash_algorithm_name}" />
-		<property name="hashIterations" value="${pwd.hash_iterations}" />
-		<property name="storedCredentialsHexEncoded" value="true" />
-	</bean>
-	<!-- -->
-	<bean id="userRealm" class="com.goafanti.core.shiro.token.UserRealm">
-		<property name="credentialsMatcher" ref="credentialsMatcher" />
-	</bean>
-
-	<!-- Session Manager -->
-	<bean id="sessionManager"
-		class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
-		<property name="sessionIdUrlRewritingEnabled" value="false" />
-		<!-- -->
-		<property name="sessionValidationInterval" value="1800000" />
-		<!-- -->
-		<property name="globalSessionTimeout" value="1800000" />
-		<property name="sessionDAO" ref="enterpriseCacheSessionDAO" />
-		<property name="cacheManager" ref="shrioRedisCacheManager" />
-		<!-- session -->
-		<property name="sessionListeners">
-			<list>
-				<ref bean="customSessionListener" />
-			</list>
-		</property>
-		<!-- -->
-		<property name="sessionValidationScheduler" ref="sessionValidationScheduler" />
-		<!-- -->
-		<property name="sessionValidationSchedulerEnabled" value="true" />
-		<!-- -->
-		<property name="deleteInvalidSessions" value="true" />
-		<!-- -->
-		<property name="sessionIdCookie" ref="sessionIdCookie" />
-	</bean>
-
-	<bean id="shiroManager" class="com.goafanti.core.shiro.service.impl.ShiroManagerImpl" />
-
-	<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
-		<property name="securityManager" ref="securityManager" />
-		<property name="loginUrl" value="/user/login" />
-		<property name="successUrl" value="/" />
-		<property name="unauthorizedUrl" value="/user/login" />
-		<property name="filterChainDefinitions" value="#{shiroManager.loadFilterChainDefinitions()}" />
-		<property name="filters">
-			<util:map>
-				<entry key="login">
-					<bean id="login" class="com.goafanti.core.shiro.filter.LoginFilter" />
-				</entry>
-				<entry key="permission">
-					<bean id="permission" class="com.goafanti.core.shiro.filter.PermissionFilter">
-						<property name="loginUrl" value="/admin/login" />
-					</bean>
-				</entry>
-				<entry key="admin">
-					<bean id="admin" class="com.goafanti.core.shiro.filter.AdminFilter">
-						<property name="loginUrl" value="/admin/login" />
-					</bean>
-				</entry>
-			</util:map>
-		</property>
-	</bean>
-	<!-- -->
-	<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
+	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
+	xmlns:context="http://www.springframework.org/schema/context"
+	xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
+       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
+       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
+
+	<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
+		<property name="maxIdle" value="100" />
+		<property name="minIdle" value="10" />
+		<property name="testOnBorrow" value="true" />
+	</bean>
+
+	<bean id="redisConnectionFactory"
+		class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
+		<property name="hostName" value="${jedis.host}" />
+		<property name="port" value="${jedis.port}" />
+		<property name="password" value="${jedis.password}" />
+		<property name="timeout" value="${jedis.timeout}" />
+		<property name="poolConfig" ref="jedisPoolConfig" />
+		<!-- <property name="database" value="${jedis.dbIndex}" /> -->
+	</bean>
+
+	<bean id="redisTemplate" class="com.goafanti.core.cache.template.FastJsonRedisTemplate">
+		<constructor-arg index="0" ref="redisConnectionFactory" />
+	</bean>
+	
+    <bean id="jedisQueueListener" class="com.goafanti.easemob.queue.EasemobRedisQueueListener"/>  
+    
+    
+    <bean id="jedisQueue" class="com.goafanti.easemob.queue.EasemobRedisQueue" destroy-method="destroy">  
+        <property name="redisTemplate" ref="redisTemplate"></property>  
+        <property name="key" value="easemob:queue"></property>  
+        <property name="listener" ref="jedisQueueListener"></property>  
+    </bean> 
+    
+    <bean id="easemobUtils" class="com.goafanti.easemob.EasemobUtils"/>
+      
+
+	<bean id="sessionRedisTemplate" class="com.goafanti.core.shiro.cache.template.SessionRedisTemplate">
+		<constructor-arg index="0" ref="redisConnectionFactory" />
+	</bean>
+
+	<bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager">
+		<constructor-arg index="0" ref="redisTemplate" />
+		<property name="defaultExpiration" value="86400" />		
+	</bean>
+	
+	<bean id="shrioRedisCacheManager" class="com.goafanti.core.shiro.cache.ShiroRedisCacheManager">
+		<property name="redisTemplate" ref="sessionRedisTemplate" />
+		<property name="expire" value="2592000" />
+	</bean>
+
+	<bean id="sessionIdGenerator"
+		class="org.apache.shiro.session.mgt.eis.JavaUuidSessionIdGenerator" />
+
+
+	<bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
+		<constructor-arg value="AFT_SID" />
+		<property name="httpOnly" value="true" />
+		<property name="maxAge" value="2592000" />
+		<!-- <property name="domain" value=""/> -->
+	</bean>
+
+	<bean id="customSessionListener" class="com.goafanti.core.shiro.listener.CustomSessionListener">
+		<property name="redisTemplate" ref="sessionRedisTemplate" />
+	</bean>
+
+	<bean id="enterpriseCacheSessionDAO"
+		class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO">
+		<property name="sessionIdGenerator" ref="sessionIdGenerator" />
+	</bean>
+
+	<!-- -->
+	<bean id="sessionValidationScheduler"
+		class="org.apache.shiro.session.mgt.ExecutorServiceSessionValidationScheduler">
+		<!-- -->
+		<property name="interval" value="${session.validate.timespan}" />
+		<property name="sessionManager" ref="sessionManager" />
+	</bean>
+	<!-- -->
+	<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
+		<property name="realm" ref="userRealm" />
+		<property name="sessionManager" ref="sessionManager" />
+		<property name="cacheManager" ref="shrioRedisCacheManager" />
+	</bean>
+
+	<bean id="authorizationAttributeSourceAdvisor"
+		class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
+		<property name="securityManager" ref="securityManager" />
+	</bean>
+
+	<!-- credential matcher -->
+	<bean id="credentialsMatcher"
+		class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
+		<property name="hashAlgorithmName" value="${pwd.hash_algorithm_name}" />
+		<property name="hashIterations" value="${pwd.hash_iterations}" />
+		<property name="storedCredentialsHexEncoded" value="true" />
+	</bean>
+	<!-- -->
+	<bean id="userRealm" class="com.goafanti.core.shiro.token.UserRealm">
+		<property name="credentialsMatcher" ref="credentialsMatcher" />
+	</bean>
+
+	<!-- Session Manager -->
+	<bean id="sessionManager" class="com.goafanti.core.shiro.session.CustomSessionManager">
+		<!-- class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager"> -->
+		<property name="sessionIdUrlRewritingEnabled" value="false" />
+		<!-- -->
+		<property name="sessionValidationInterval" value="1800000" />
+		<!-- -->
+		<property name="globalSessionTimeout" value="1800000" />
+		<property name="sessionDAO" ref="enterpriseCacheSessionDAO" />
+		<property name="cacheManager" ref="shrioRedisCacheManager" />
+		<!-- session -->
+		<property name="sessionListeners">
+			<list>
+				<ref bean="customSessionListener" />
+			</list>
+		</property>
+		<!-- -->
+		<property name="sessionValidationScheduler" ref="sessionValidationScheduler" />
+		<!-- -->
+		<property name="sessionValidationSchedulerEnabled" value="true" />
+		<!-- -->
+		<property name="deleteInvalidSessions" value="true" />
+		<!-- -->
+		<property name="sessionIdCookie" ref="sessionIdCookie" />
+	</bean>
+
+	<bean id="shiroManager" class="com.goafanti.core.shiro.service.impl.ShiroManagerImpl" />
+
+	<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
+		<property name="securityManager" ref="securityManager" />
+		<property name="loginUrl" value="/user/login" />
+		<property name="successUrl" value="/" />
+		<property name="unauthorizedUrl" value="/user/login" />
+		<property name="filterChainDefinitions" value="#{shiroManager.loadFilterChainDefinitions()}" />
+		<property name="filters">
+			<util:map>
+				<entry key="login">
+					<bean id="login" class="com.goafanti.core.shiro.filter.LoginFilter" />
+				</entry>
+				<entry key="permission">
+					<bean id="permission" class="com.goafanti.core.shiro.filter.PermissionFilter">
+						<property name="loginUrl" value="/admin/login" />
+					</bean>
+				</entry>
+				<entry key="admin">
+					<bean id="admin" class="com.goafanti.core.shiro.filter.AdminFilter">
+						<property name="loginUrl" value="/admin/login" />
+					</bean>
+				</entry>
+			</util:map>
+		</property>
+	</bean>
+	<!-- -->
+	<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
 </beans>