wanghui 7 éve%!(EXTRA string=óta)
szülő
commit
976dec1bc0

+ 8 - 1
src/main/java/com/goafanti/core/shiro/filter/PermissionFilter.java

@@ -10,6 +10,7 @@ import org.apache.shiro.util.StringUtils;
 import org.apache.shiro.web.filter.AccessControlFilter;
 import org.apache.shiro.web.util.WebUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 
 import com.goafanti.common.bo.Error;
 import com.goafanti.common.bo.Result;
@@ -20,6 +21,9 @@ public class PermissionFilter extends AccessControlFilter {
 
 	@Autowired
 	private ShiroFilterUtils shiroFilterUtils;
+	
+	@Value("app.mobile.website")
+	private String mobileWebsite;
 
 	@Override
 	protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
@@ -44,7 +48,10 @@ public class PermissionFilter extends AccessControlFilter {
 	@Override
 	protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
 		Subject subject = getSubject(request, response);
-		if (shiroFilterUtils.isAjax((HttpServletRequest) request)) {
+		if (shiroFilterUtils.isMobileDevice((HttpServletRequest)request)){
+			LoggerUtils.debug(getClass(), "当前访问为移动设备");
+			WebUtils.issueRedirect(request, response, mobileWebsite);
+		}else if (shiroFilterUtils.isAjax((HttpServletRequest) request)) {
 			LoggerUtils.debug(getClass(), "当前用户权限不够,并且是Ajax请求!");
 			shiroFilterUtils.out((HttpServletResponse) response, new Result().error(new Error("", "403", "当前用户权限不够!")));
 		} else if (null == subject.getPrincipal()) {

+ 18 - 0
src/main/java/com/goafanti/core/shiro/filter/ShiroFilterUtils.java

@@ -33,6 +33,24 @@ public class ShiroFilterUtils {
 	}
 
 	/**
+	 * 判断是否来自移动设备
+	 * @param request
+	 * @return
+	 */
+	public boolean isMobileDevice(HttpServletRequest request) {
+		String[] deviceArray = new String[]{"android","mac os","windows phone"};
+        if(request.getHeader("User-Agent") != null){
+        	String agent = request.getHeader("User-Agent");
+        	for(int i = 0; i<deviceArray.length; i++){
+        		if(agent.indexOf(deviceArray[i]) >0 ){
+        			return true;
+        		}
+        	} 	
+        }
+       return false;
+	}
+	
+	/**
 	 * 
 	 * @param request
 	 * @return true if App request

+ 3 - 1
src/main/resources/props/config_local.properties

@@ -52,6 +52,7 @@ session.timeout=12000000
 session.validate.timespan=18000000
 
 app.name=AFT
+app.mobile.website=m.jishutao.com
 template.cacheable=false
 
 static.host=//sclient.jishutao.com/client/1.0.0
@@ -75,4 +76,5 @@ easemob.client.secret=YXA61NHE0renI5N8gEgizoI5ivM9SYE
 
 jiguang.appKey=dbcea43366e038073452a04e
 jiguang.masterSecret=59792298288e4f635c737def
-jiguang.pushUrl=https://api.jpush.cn/v3/push
+jiguang.pushUrl=https://api.jpush.cn/v3/push
+

+ 1 - 0
src/main/resources/props/config_test.properties

@@ -53,6 +53,7 @@ session.timeout=12000000
 session.validate.timespan=18000000
 
 app.name=AFT
+app.mobile.website=m.jishutao.com
 template.cacheable=false
 
 static.host=//statics.jishutao.com/client/1.0.0

+ 1 - 1
src/main/webapp/WEB-INF/views/common.html

@@ -283,7 +283,7 @@
 					<div class="text_top">
 						<a th:href="@{/portal/aboutUs}">关于公司/</a>
 						<a th:href="@{/portal/contactUs}">联系我们</a>
-						<p> Copyright &copy 2016-2017 科德 版权所有 湘ICP备15019731号
+						<p> Copyright &copy 2016-2017 科德 版权所有 <a href="http://www.miitbeian.gov.cn/" target="_blank">湘ICP备15019731号</a>
 							-2 技术支持:湖南阿凡提科技有限公司</p>
 					</div>
 					<div class="text_center">