|
@@ -17,6 +17,7 @@ import com.uas.platform.b2b.support.SecurityConstant;
|
|
|
import com.uas.platform.b2b.support.SysConf;
|
|
import com.uas.platform.b2b.support.SysConf;
|
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
|
import com.uas.platform.b2b.support.UserCreater;
|
|
import com.uas.platform.b2b.support.UserCreater;
|
|
|
|
|
+import com.uas.platform.b2b.support.exception.IllegalUserInfoException;
|
|
|
import com.uas.platform.core.model.Constant;
|
|
import com.uas.platform.core.model.Constant;
|
|
|
import com.uas.platform.core.util.AgentUtils;
|
|
import com.uas.platform.core.util.AgentUtils;
|
|
|
import com.uas.platform.core.util.encry.Md5Utils;
|
|
import com.uas.platform.core.util.encry.Md5Utils;
|
|
@@ -67,7 +68,7 @@ import java.util.stream.Collectors;
|
|
|
* @date 2018-07-18 19:21
|
|
* @date 2018-07-18 19:21
|
|
|
*/
|
|
*/
|
|
|
@SuppressWarnings("deprecation")
|
|
@SuppressWarnings("deprecation")
|
|
|
-public class SSOInterceptor extends AbstractSSOInterceptor {
|
|
|
|
|
|
|
+public class SSOInterceptor extends B2bAbstractSSOInterceptor {
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(SSOInterceptor.class);
|
|
private static final Logger logger = LoggerFactory.getLogger(SSOInterceptor.class);
|
|
|
|
|
|
|
@@ -175,7 +176,15 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (user != null) {
|
|
if (user != null) {
|
|
|
- checkIsPersonal(user);
|
|
|
|
|
|
|
+ // 个人用户,跳转至提示页面
|
|
|
|
|
+ if (checkIsPersonal(user)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ response.sendRedirect("/error_personal");
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
// 登录之前判断在当前企业的角色信息
|
|
// 登录之前判断在当前企业的角色信息
|
|
|
if (null != user.getEnterprise() && user.getEnterprise().getEnAdminuu().equals(user.getUserUU())) {
|
|
if (null != user.getEnterprise() && user.getEnterprise().getEnAdminuu().equals(user.getUserUU())) {
|
|
|
Enterprise enterprise = user.getEnterprise();
|
|
Enterprise enterprise = user.getEnterprise();
|
|
@@ -294,7 +303,7 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
|
|
|
* @param response response
|
|
* @param response response
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- protected void onAuthenticateSuccess(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
|
|
+ protected boolean onAuthenticateSuccess(HttpServletRequest request, HttpServletResponse response) {
|
|
|
User user = (User) request.getSession().getAttribute("user");
|
|
User user = (User) request.getSession().getAttribute("user");
|
|
|
SSOToken token = SSOHelper.attrToken(request);
|
|
SSOToken token = SSOHelper.attrToken(request);
|
|
|
// cookie变化的情况下,session可能还未变化
|
|
// cookie变化的情况下,session可能还未变化
|
|
@@ -312,7 +321,13 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
|
|
|
if (token.getData() != null) {
|
|
if (token.getData() != null) {
|
|
|
UserAccount tokenUser = FlexJsonUtils.fromJson(token.getData(), UserAccount.class);
|
|
UserAccount tokenUser = FlexJsonUtils.fromJson(token.getData(), UserAccount.class);
|
|
|
if (StringUtils.isEmpty(tokenUser.getBusinessCode()) || StringUtils.isEmpty(tokenUser.getSpaceUU())) {
|
|
if (StringUtils.isEmpty(tokenUser.getBusinessCode()) || StringUtils.isEmpty(tokenUser.getSpaceUU())) {
|
|
|
- throw new IllegalAccessError("个人用户无法使用B2B商务平台");
|
|
|
|
|
|
|
+ // 如果个人用户跳转至提示页面
|
|
|
|
|
+ try {
|
|
|
|
|
+ response.sendRedirect("/error_personal");
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
// 如果是从个人用户切换或者当前企业切换
|
|
// 如果是从个人用户切换或者当前企业切换
|
|
|
boolean flag = null == user.getEnterprise() || !user.getEnterprise().getUu().equals(tokenUser.getSpaceUU());
|
|
boolean flag = null == user.getEnterprise() || !user.getEnterprise().getUu().equals(tokenUser.getSpaceUU());
|
|
@@ -324,8 +339,15 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (user != null) {
|
|
if (user != null) {
|
|
|
- // 判断是否个人用户
|
|
|
|
|
- checkIsPersonal(user);
|
|
|
|
|
|
|
+ // 判断是否个人用户,如果个人用户跳转至提示页面
|
|
|
|
|
+ if (checkIsPersonal(user)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ response.sendRedirect("/error_personal");
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
// 登录之前判断在当前企业的角色信息
|
|
// 登录之前判断在当前企业的角色信息
|
|
|
if (null != user.getEnterprise() && user.getEnterprise().getEnAdminuu().equals(user.getUserUU())) {
|
|
if (null != user.getEnterprise() && user.getEnterprise().getEnAdminuu().equals(user.getUserUU())) {
|
|
|
Enterprise enterprise = user.getEnterprise();
|
|
Enterprise enterprise = user.getEnterprise();
|
|
@@ -340,6 +362,7 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -371,11 +394,9 @@ public class SSOInterceptor extends AbstractSSOInterceptor {
|
|
|
*
|
|
*
|
|
|
* @param user 用户信息
|
|
* @param user 用户信息
|
|
|
*/
|
|
*/
|
|
|
- private void checkIsPersonal(User user) {
|
|
|
|
|
|
|
+ private boolean checkIsPersonal(User user) {
|
|
|
boolean personalAccount = null == user.getEnterprise() || (null != user.getEnterprise() && null == user.getEnterprise().getUu());
|
|
boolean personalAccount = null == user.getEnterprise() || (null != user.getEnterprise() && null == user.getEnterprise().getUu());
|
|
|
- if (personalAccount) {
|
|
|
|
|
- throw new IllegalAccessError("个人用户无法使用B2B商务平台");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return personalAccount;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|