|
|
@@ -8,7 +8,6 @@ import com.uas.platform.b2bManage.support.SecurityConstant;
|
|
|
import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
import com.uas.sso.SSOHelper;
|
|
|
import com.uas.sso.SSOToken;
|
|
|
-import org.apache.http.protocol.HTTP;
|
|
|
import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
@@ -23,6 +22,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -51,7 +51,8 @@ public class SSOInterceptor extends HandlerInterceptorAdapter {
|
|
|
HttpServletRequest httpRequest = (HttpServletRequest) request;
|
|
|
logSession(httpRequest);
|
|
|
User user = SystemSession.getUser();
|
|
|
- if (user == null) {// 未登录则要求登录
|
|
|
+ // 未登录则要求登录
|
|
|
+ if (user == null) {
|
|
|
logoutSession();
|
|
|
if(!this.onAuthenticateFailed(request, response)) {
|
|
|
return false;
|
|
|
@@ -70,13 +71,14 @@ public class SSOInterceptor extends HandlerInterceptorAdapter {
|
|
|
* @param request
|
|
|
*/
|
|
|
private void logSession(HttpServletRequest request) throws UnsupportedEncodingException {
|
|
|
- Cookie[] cookies = request.getCookies();//这样便可以获取一个cookie数组
|
|
|
+ //这样便可以获取一个cookie数组
|
|
|
+ Cookie[] cookies = request.getCookies();
|
|
|
if (!StringUtils.isEmpty(cookies)) {
|
|
|
for (Cookie cookie : cookies){
|
|
|
if (null != cookie && cookie.getName().equals("user")) {
|
|
|
Object jsonStr = cookie.getValue();
|
|
|
if (jsonStr != null) {
|
|
|
- String str = URLDecoder.decode(jsonStr.toString(), HTTP.UTF_8);
|
|
|
+ String str = URLDecoder.decode(jsonStr.toString(), String.valueOf(StandardCharsets.UTF_8));
|
|
|
User user = JSONObject.parseObject(str, User.class);
|
|
|
SystemSession.setUser(user);
|
|
|
}
|