Kaynağa Gözat

西安交通大学测试数据修改

wangliang 2 yıl önce
ebeveyn
işleme
10f3730f10

+ 11 - 1
xjtu-exchange/src/main/java/com/qmth/xjtu/api/OpenApiController.java

@@ -7,6 +7,8 @@ import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.teachcloud.exchange.common.bean.params.OpenParams;
 import com.qmth.teachcloud.exchange.common.contant.SystemConstant;
+import com.qmth.teachcloud.exchange.common.enums.ExceptionResultEnum;
+import com.qmth.teachcloud.exchange.common.service.AuthInfoService;
 import com.qmth.teachcloud.exchange.common.service.CommonService;
 import com.qmth.teachcloud.exchange.common.util.HttpUtil;
 import com.qmth.teachcloud.exchange.common.util.JacksonUtil;
@@ -48,6 +50,9 @@ public class OpenApiController {
     @Resource
     CommonService commonService;
 
+    @Resource
+    AuthInfoService authInfoService;
+
     @ApiOperation(value = "西安交通大学cas鉴权接口")
     @ApiResponses({@ApiResponse(code = 200, message = "返回消息", response = Result.class)})
     @RequestMapping(value = "/authentication", method = RequestMethod.GET)
@@ -57,7 +62,8 @@ public class OpenApiController {
                                @ApiParam(value = "用户类型") @RequestParam(required = false) String userType,
                                @ApiParam(value = "员工工号") @RequestParam(required = false) String employeeNo,
                                @ApiParam(value = "返回url") @RequestParam(required = false) String returnUrl) throws IOException {
-        String schoolCode = "test-school-2";//测试学校code,正式改成xjtu
+        String schoolCode = "xjtu";//测试学校code,正式改成xjtu
+        authInfoService.appHasExpired(schoolCode);
 
         Map<String, Object> accessTokenParams = new LinkedHashMap<>();
         accessTokenParams.put("code", code);
@@ -73,6 +79,8 @@ public class OpenApiController {
             if (Objects.nonNull(object) && Objects.equals(message, "成功")) {
                 accessToken = object.getString("accessToken");
                 gsessionId = object.getString("gsessionId");
+            } else {
+                throw ExceptionResultEnum.ERROR.exception(message);
             }
         }
 
@@ -105,6 +113,8 @@ public class OpenApiController {
                         JSONObject deptInfoJsonArrayJsonObject = deptInfoJsonArray.getJSONObject(0);
                         openParams.setDeptName(deptInfoJsonArrayJsonObject.getString("deptName"));
                     }
+                } else {
+                    throw ExceptionResultEnum.ERROR.exception(message);
                 }
             }
         }

+ 2 - 79
xjtu-exchange/src/main/java/com/qmth/xjtu/auth/XjtuAuthenticationService.java

@@ -14,18 +14,6 @@ import javax.servlet.http.HttpServletResponse;
 public class XjtuAuthenticationService implements AuthorizationService {
     private final static Logger log = LoggerFactory.getLogger(XjtuAuthenticationService.class);
 
-//    @Resource
-//    CommonCacheService commonCacheService;
-//
-//    @Resource
-//    RedisUtil redisUtil;
-//
-//    @Resource
-//    DictionaryConfig dictionaryConfig;
-//
-//    @Resource
-//    AuthInfoService authInfoService;
-
     @Override
     public AccessEntity findByIdentity(String identity, SignatureType signatureType, String path) {
         return new XjuSession(identity, SignatureType.TOKEN);
@@ -33,47 +21,7 @@ public class XjtuAuthenticationService implements AuthorizationService {
 
     @Override
     public boolean hasPermission(AccessEntity accessEntity, String path) {
-//        if (Objects.nonNull(accessEntity) && Objects.nonNull(accessEntity.getIdentity())) {
-//            TBSession tbSession = (TBSession) redisUtil.getUserSession(accessEntity.getIdentity());
-//            if (Objects.isNull(tbSession)) {
-//                log.warn("Authorization faile: session id not exists: {}", accessEntity.getIdentity());
-//                throw ExceptionResultEnum.NOT_LOGIN.exception();
-//            }
-//            if (tbSession.getExpireTime() <= System.currentTimeMillis()) {
-//                log.warn("Authorization faile: session has expired, expire time={}", tbSession.getExpireTime());
-//                throw ExceptionResultEnum.NOT_LOGIN.exception();
-//            }
-//            Platform platform = ServletUtil.getRequestPlatform();
-//            String deviceId = ServletUtil.getRequestDeviceId();
-//            if (!tbSession.getPlatform().equalsIgnoreCase(platform.name())) {
-//                log.warn("Authorization faile: platform invalid, session platform is {}", tbSession.getPlatform());
-//                throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-//            }
-//            if (!tbSession.getDeviceId().equalsIgnoreCase(deviceId)) {
-//                log.warn("Authorization faile: deviceId invalid, session deviceId is {} ", tbSession.getDeviceId());
-//                throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-//            }
-//            Long userId = Long.parseLong(tbSession.getIdentity());
-//            SysUser sysUser = commonCacheService.userCache(userId);
-//            HttpServletRequest request = ServletUtil.getRequest();
-//            HttpServletResponse response = ServletUtil.getResponse();
-//            request.setAttribute(SystemConstant.SESSION, tbSession);
-//            request.setAttribute(SystemConstant.USER, sysUser);
-//            boolean auth = authFootCommon(userId, SystemConstant.USER_OAUTH_CACHE, path, request, response);
-//            if (auth) {
-//                Long expireTime = redisUtil.getUserSessionExpire(accessEntity.getIdentity());
-//                if (Objects.nonNull(expireTime) && expireTime.longValue() > -1L) {
-//                    if (Objects.nonNull(tbSession.getLastAccessTime()) && (System.currentTimeMillis() - tbSession.getLastAccessTime()) / 1000 > dictionaryConfig.sysDomain().getSessionActive().getSeconds()) {
-//                        log.warn("Authorization faile: session active, session active is {}", dictionaryConfig.sysDomain().getSessionActive().getSeconds());
-//                        throw ExceptionResultEnum.NOT_LOGIN.exception();
-//                    }
-//                    tbSession.setLastInfo();
-//                    redisUtil.setUserSession(accessEntity.getIdentity(), tbSession, expireTime);
-//                }
-//            }
-//            return auth;
-//        }
-        return false;
+        return true;
     }
 
     /**
@@ -91,35 +39,10 @@ public class XjtuAuthenticationService implements AuthorizationService {
                                   String path,
                                   HttpServletRequest request,
                                   HttpServletResponse response) {
-        //验证权限
-//        AuthBean authBean = type.contains(SystemConstant.USER_OAUTH_CACHE) ? authBean = commonCacheService.userAuthCache(userId) : null;
-//        if (Objects.isNull(authBean)) {
-//            throw ExceptionResultEnum.ROLE_ENABLE_AUTHORIZATION.exception();
-//        }
-//        request.setAttribute(SystemConstant.SCHOOL, authBean.getSchool());
-//        request.setAttribute(SystemConstant.ORG, authBean.getOrg());
-//
-//        //超级系统管理员拥有所有权限
-//        int count = Objects.nonNull(authBean) ? (int) authBean.getRoleList().stream().filter(s -> Objects.equals(s.getName(), RoleTypeEnum.ADMIN.getDesc())).count() : 0;
-//        if (count > 0) {
-//            return true;
-//        }
+
 //        if (Objects.nonNull(authBean.getSchool())) {
 //            authInfoService.appHasExpired(authBean.getSchool().getCode());
 //        }
-//        //系统公用接口不拦截
-//        Set<String> sysUrls = commonCacheService.privilegeUrlCache(PrivilegePropertyEnum.SYS, SystemConstant.getHeadOrUserSchoolId());
-//        int sysCount = Objects.nonNull(sysUrls) ? (int) sysUrls.stream().filter(s -> s.equalsIgnoreCase(path)).count() : 0;
-//        if (sysCount > 0) {
-//            return true;
-//        }
-//        Set<String> urls = authBean.getUrls();
-//        int privilegeCount = Objects.nonNull(urls) ? (int) urls.stream().filter(s -> s.equalsIgnoreCase(path)).count() : 0;
-//        if (privilegeCount == 0) {
-//            log.warn("Authorization faile: url cannot access");
-//            throw ExceptionResultEnum.UN_AUTHORIZATION.exception();
-//        }
-//        response.setStatus(ExceptionResultEnum.SUCCESS.getCode());
         return true;
     }
 }

+ 0 - 3
xjtu-exchange/src/main/java/com/qmth/xjtu/auth/XjuSession.java

@@ -27,9 +27,6 @@ public class XjuSession implements AccessEntity {
 
     @Override
     public String getSecret() {
-//        RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);
-//        TBSession tbSession = (TBSession) redisUtil.getUserSession(identity);
-//        return Objects.nonNull(tbSession) ? tbSession.getAccessToken() : null;
         return null;
     }
 

+ 2 - 3
xjtu-exchange/src/main/resources/application-dev.properties

@@ -74,6 +74,5 @@ com.qmth.solar.access-key=274f823e5f59410f8b3bb6edcd8e2b6e
 com.qmth.solar.access-secret=y7AO6W0TOdTF8HpWBwGHbp3wfIHsmUKr
 #com.qmth.solar.license=/Volumes/extend/\u542F\u660E/\u5206\u5E03\u5F0F\u5370\u5237/\u5206\u5E03\u5F0F\u5370\u5237&\u6559\u7814\u5206\u6790v3.1.0/tc-dev-wl.lic
 
-#cas.config.teachcloudPrintLoginUrl=http://*.teach-cloud-test.com/#/login-open
-#cas.config.teachcloudPrintLoginUrl=http://127.0.0.1:7111/#/login-open
-cas.config.teachcloudPrintLoginUrl=http://192.168.10.99:8056/#/login-open
+cas.config.teachcloudPrintLoginUrl=https://*.teach-cloud-test.com/#/login-open
+#cas.config.teachcloudPrintLoginUrl=http://192.168.10.99:8056/#/login-open

+ 2 - 3
xjtu-exchange/src/main/resources/application-prod.properties

@@ -74,6 +74,5 @@ com.qmth.solar.access-key=918d0878ee7944beb448980b011ff804
 com.qmth.solar.access-secret=IY3NB9FXtd7OQHWH5YHl6mbrU9ch33QC
 #com.qmth.solar.license=/Volumes/extend/\u542F\u660E/\u5206\u5E03\u5F0F\u5370\u5237/\u5206\u5E03\u5F0F\u5370\u5237&\u6559\u7814\u5206\u6790v3.1.0/tc-dev-wl.lic
 
-#cas.config.teachcloudPrintLoginUrl=http://*.teach-cloud-test.com/#/login-open
-#cas.config.teachcloudPrintLoginUrl=http://127.0.0.1:7111/#/login-open
-cas.config.teachcloudPrintLoginUrl=http://192.168.10.99:8056/#/login-open
+cas.config.teachcloudPrintLoginUrl=https://*.teach-cloud.com/#/login-open
+#cas.config.teachcloudPrintLoginUrl=http://192.168.10.99:8056/#/login-open

+ 2 - 3
xjtu-exchange/src/main/resources/application-test.properties

@@ -74,6 +74,5 @@ com.qmth.solar.access-key=918d0878ee7944beb448980b011ff804
 com.qmth.solar.access-secret=IY3NB9FXtd7OQHWH5YHl6mbrU9ch33QC
 #com.qmth.solar.license=/Volumes/extend/\u542F\u660E/\u5206\u5E03\u5F0F\u5370\u5237/\u5206\u5E03\u5F0F\u5370\u5237&\u6559\u7814\u5206\u6790v3.1.0/tc-dev-wl.lic
 
-#cas.config.teachcloudPrintLoginUrl=http://*.teach-cloud-test.com/#/login-open
-#cas.config.teachcloudPrintLoginUrl=http://127.0.0.1:7111/#/login-open
-cas.config.teachcloudPrintLoginUrl=http://192.168.10.99:8056/#/login-open
+cas.config.teachcloudPrintLoginUrl=https://*.teach-cloud-test.com/#/login-open
+#cas.config.teachcloudPrintLoginUrl=http://192.168.10.99:8056/#/login-open