diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/cas/controller/CasClientController.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/cas/controller/CasClientController.java index efc8044e..8a621e2c 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/cas/controller/CasClientController.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/cas/controller/CasClientController.java @@ -1,17 +1,10 @@ package com.jero.modules.cas.controller; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import cn.hutool.crypto.SecureUtil; -import org.apache.commons.lang.StringUtils; +import com.alibaba.fastjson.JSONObject; import com.jero.common.api.vo.Result; -import com.jero.common.constant.CacheConstant; import com.jero.common.constant.CommonConstant; +import com.jero.common.exception.JeroBootException; import com.jero.common.system.util.JwtUtil; -import com.jero.common.system.vo.LoginUser; import com.jero.common.util.RedisUtil; import com.jero.modules.cas.util.CASServiceUtil; import com.jero.modules.cas.util.XmlUtils; @@ -19,7 +12,8 @@ import com.jero.modules.system.entity.SysDepart; import com.jero.modules.system.entity.SysUser; import com.jero.modules.system.service.ISysDepartService; import com.jero.modules.system.service.ISysUserService; -import org.springframework.beans.BeanUtils; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; @@ -28,9 +22,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.alibaba.fastjson.JSONObject; - -import lombok.extern.slf4j.Slf4j; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** *

@@ -60,9 +54,9 @@ public class CasClientController { public Object validateLogin(@RequestParam(name="ticket") String ticket, @RequestParam(name="service") String service, HttpServletRequest request, - HttpServletResponse response) throws Exception { - String MULTI_DEPART = "multi_depart"; - Result result = new Result(); + HttpServletResponse response) { + String multiDepart = "multi_depart"; + Result result = new Result<>(); log.info("Rest api login."); try { String validateUrl = prefixUrl+"/p3/serviceValidate"; @@ -70,11 +64,11 @@ public class CasClientController { log.info("res."+res); final String error = XmlUtils.getTextForElement(res, "authenticationFailure"); if(StringUtils.isNotEmpty(error)) { - throw new Exception(error); + throw new JeroBootException(error); } final String principal = XmlUtils.getTextForElement(res, "user"); if (StringUtils.isEmpty(principal)) { - throw new Exception("No principal was found in the response from the CAS server."); + throw new JeroBootException("No principal was found in the response from the CAS server."); } log.info("-------token----username---"+principal); //1. 校验用户是否有效 @@ -92,13 +86,13 @@ public class CasClientController { JSONObject obj = new JSONObject(); List departs = sysDepartService.queryUserDeparts(sysUser.getId()); obj.put("departs", departs); - if (departs == null || departs.size() == 0) { - obj.put(MULTI_DEPART, 0); + if (departs == null || departs.isEmpty()) { + obj.put(multiDepart, 0); } else if (departs.size() == 1) { sysUserService.updateUserDepart(principal, departs.get(0).getOrgCode()); - obj.put(MULTI_DEPART, 1); + obj.put(multiDepart, 1); } else { - obj.put(MULTI_DEPART, 2); + obj.put(multiDepart, 2); } obj.put("token", token); obj.put("userInfo", sysUser);