-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
33 changed files
with
139 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,54 @@ | ||
package com.sd.common.util; | ||
|
||
import entity.User; | ||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import javax.servlet.*; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @Created with Atom | ||
* @author @author@ | ||
* @time @now@ | ||
* @description | ||
* 权限验证 工具类 | ||
* | ||
**/ | ||
|
||
public class AuthenticationFilter implements Filter { | ||
private static Log log = LogFactory.getLog(AuthenticationFilter.class); | ||
|
||
@Override | ||
public void doFilter(ServletRequest request, ServletResponse response, | ||
FilterChain chain) throws IOException, ServletException { | ||
HttpServletRequest req = (HttpServletRequest) request; | ||
String path = req.getServletPath(); | ||
|
||
if ((path.indexOf(".action") == -1) && (path.indexOf(".jsp") == -1)) { //只拦截action和jsp | ||
chain.doFilter(request, response); | ||
return; | ||
} else { | ||
String uri = path.substring(path.lastIndexOf("/", path.length())); | ||
if (uri.startsWith("/login!") || | ||
path.endsWith("/login.action") || | ||
path.endsWith("/login.jsp") || | ||
path.endsWith("/register.action") || | ||
path.endsWith("/register.jsp")) { //登录无需判断权限 | ||
chain.doFilter(request, response); | ||
return; | ||
} else { | ||
HttpSession session = req.getSession(); | ||
User user = (User) session.getAttribute("loginUser"); | ||
if (user == null) { | ||
log.debug("User doesn't exist in session"); | ||
HttpServletResponse res = (HttpServletResponse) response; | ||
res.sendRedirect(req.getContextPath() + "/login.action"); | ||
} else { | ||
chain.doFilter(request, response); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void init(FilterConfig filterConfig) throws ServletException {} | ||
|
||
@Override | ||
public void destroy() {} | ||
} | ||
package com.sd.packagename.common.util; | ||
|
||
import entity.User; | ||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import javax.servlet. *; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @Created with Atom | ||
* @author @author@ | ||
* @time @now@ | ||
* @description | ||
* 权限验证 工具类 | ||
* | ||
**/ | ||
|
||
public class AuthenticationFilter implements Filter { | ||
private static Log log = LogFactory.getLog(AuthenticationFilter.class); | ||
|
||
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)throws IOException, ServletException { | ||
HttpServletRequest req = (HttpServletRequest)request; | ||
String path = req.getServletPath(); | ||
|
||
if ((path.indexOf(".action") == -1) && (path.indexOf(".jsp") == -1)) { //只拦截action和jsp | ||
chain.doFilter(request, response); | ||
return; | ||
} else { | ||
String uri = path.substring(path.lastIndexOf("/", path.length())); | ||
if (uri.startsWith("/login!") || path.endsWith("/login.action") || path.endsWith("/login.jsp") || path.endsWith("/register.action") || path.endsWith("/register.jsp")) { //登录无需判断权限 | ||
chain.doFilter(request, response); | ||
return; | ||
} else { | ||
HttpSession session = req.getSession(); | ||
User user = (User)session.getAttribute("loginUser"); | ||
if (user == null) { | ||
log.debug("User doesn't exist in session"); | ||
HttpServletResponse res = (HttpServletResponse)response; | ||
res.sendRedirect(req.getContextPath() + "/login.action"); | ||
} else { | ||
chain.doFilter(request, response); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override public void init(FilterConfig filterConfig)throws ServletException {} | ||
|
||
@Override public void destroy() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.sd.common.util; | ||
package com.sd.packagename.common.util; | ||
|
||
/** | ||
* @Created with Atom | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.sd.common.util; | ||
package com.sd.packagename.common.util; | ||
|
||
import java.util.List; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.sd.common.util; | ||
package com.sd.packagename.common.util; | ||
|
||
import java.util.Random; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.sd.common.util; | ||
package com.sd.packagename.common.util; | ||
|
||
/** | ||
* @Created with Atom | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,53 @@ | ||
package com.sd.common.util; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import redis.clients.jedis.JedisCluster; | ||
|
||
/** | ||
* @Created with Atom | ||
* @author @author@ | ||
* @time @now@ | ||
* @description | ||
* JedisClientCluster | ||
* | ||
**/ | ||
|
||
public class JedisClientCluster implements JedisClient { | ||
@Autowired | ||
private JedisCluster jedisCluster; | ||
|
||
@Override | ||
public String set(String key, String value) { | ||
return (jedisCluster.set(key, value)); | ||
} | ||
|
||
@Override | ||
public String get(String key) { | ||
return (jedisCluster.get(key)); | ||
} | ||
|
||
@Override | ||
public Boolean exists(String key) { | ||
return (jedisCluster.exists(key)); | ||
} | ||
|
||
@Override | ||
public Long expire(String key, int seconds) { | ||
return (jedisCluster.expire(key, seconds)); | ||
} | ||
|
||
@Override | ||
public Long ttl(String key) { | ||
return (jedisCluster.ttl(key)); | ||
} | ||
|
||
@Override | ||
public Long incr(String key) { | ||
return (jedisCluster.incr(key)); | ||
} | ||
|
||
@Override | ||
public Long hset(String key, String field, String value) { | ||
return (jedisCluster.hset(key, field, value)); | ||
} | ||
|
||
@Override | ||
public String hget(String key, String field) { | ||
return (jedisCluster.hget(key, field)); | ||
} | ||
|
||
@Override | ||
public Long hdel(String key, String...field) { | ||
return (jedisCluster.hdel(key, field)); | ||
} | ||
} | ||
package com.sd.packagename.common.util; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import redis.clients.jedis.JedisCluster; | ||
|
||
/** | ||
* @Created with Atom | ||
* @author @author@ | ||
* @time @now@ | ||
* @description | ||
* JedisClientCluster | ||
* | ||
**/ | ||
|
||
public class JedisClientCluster implements JedisClient { | ||
@Autowired private JedisCluster jedisCluster; | ||
|
||
@Override public String set(String key, String value) { | ||
return (jedisCluster.set(key, value)); | ||
} | ||
|
||
@Override public String get(String key) { | ||
return (jedisCluster.get(key)); | ||
} | ||
|
||
@Override public Boolean exists(String key) { | ||
return (jedisCluster.exists(key)); | ||
} | ||
|
||
@Override public Long expire(String key, int seconds) { | ||
return (jedisCluster.expire(key, seconds)); | ||
} | ||
|
||
@Override public Long ttl(String key) { | ||
return (jedisCluster.ttl(key)); | ||
} | ||
|
||
@Override public Long incr(String key) { | ||
return (jedisCluster.incr(key)); | ||
} | ||
|
||
@Override public Long hset(String key, String field, String value) { | ||
return (jedisCluster.hset(key, field, value)); | ||
} | ||
|
||
@Override public String hget(String key, String field) { | ||
return (jedisCluster.hget(key, field)); | ||
} | ||
|
||
@Override public Long hdel(String key, String ...field) { | ||
return (jedisCluster.hdel(key, field)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.sd.common.util; | ||
package com.sd.packagename.common.util; | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters