소스 검색

单点登录测试日志

caozixuan 3 년 전
부모
커밋
af6a492fff
1개의 변경된 파일34개의 추가작업 그리고 9개의 파일을 삭제
  1. 34 9
      teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/WudaOpenApiController.java

+ 34 - 9
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/WudaOpenApiController.java

@@ -1,5 +1,6 @@
 package com.qmth.teachcloud.report.api;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.BOOL;
@@ -75,7 +76,21 @@ public class WudaOpenApiController {
         if (Objects.isNull(uid)) {
             throw ExceptionResultEnum.NOT_LOGIN.exception();
         }
+        // 测试用代码 --- 开始 ---
+        Principal principal = request.getUserPrincipal();
+        String cn = "";
+        if (principal != null && principal instanceof AttributePrincipal) {
+            AttributePrincipal aPrincipal = (AttributePrincipal) principal;
+            //获取用户信息中公开的Attributes部分
+            Map<String, Object> map = aPrincipal.getAttributes();
+            // 获取姓名,可以根据属性名称获取其他属性
+            cn = (String) map.get("cn");
+            log.info("test-stu-map:{}", JSON.toJSONString(map));
+            log.info("test-stu-cn:{}", cn);
+        }
         BasicSchool basicSchool = cacheService.schoolCache(SystemConstant.SCHOOL_CODE);
+        String testUrl = dictionaryConfig.sysDomain().getReportUrl() + basicSchool.getId() + "/" + uid + "/" + cn;
+        log.info("test-stu-testUrl:{}", testUrl);
         response.setHeader("Access-Control-Allow-Origin", "*");
         response.sendRedirect(dictionaryConfig.sysDomain().getReportUrl() + basicSchool.getId() + "/" + uid);
     }
@@ -98,19 +113,29 @@ public class WudaOpenApiController {
         if (Objects.isNull(uid)) {
             throw ExceptionResultEnum.NOT_LOGIN.exception();
         }
-//        Principal principal = request.getUserPrincipal();
-//        if (principal != null && principal instanceof AttributePrincipal) {
-//            AttributePrincipal aPrincipal = (AttributePrincipal) principal;
-//            //获取用户信息中公开的Attributes部分
-//            Map<String, Object> map = aPrincipal.getAttributes();
-//            // 获取姓名,可以根据属性名称获取其他属性
-//            String cn = (String) map.get("cn");
-//            log.info("cn:{}", cn);
-//        }
+        // 测试用代码 --- 开始 ---
+        Principal principal = request.getUserPrincipal();
+        String cn = "";
+        if (principal != null && principal instanceof AttributePrincipal) {
+            AttributePrincipal aPrincipal = (AttributePrincipal) principal;
+            //获取用户信息中公开的Attributes部分
+            Map<String, Object> map = aPrincipal.getAttributes();
+            // 获取姓名,可以根据属性名称获取其他属性
+            cn = (String) map.get("cn");
+            log.info("test-tea-map:{}", JSON.toJSONString(map));
+            log.info("test-tea-cn:{}", cn);
+        }
+        // 测试结束
         UserAuthenticationDto userAuthenticationDto = new UserAuthenticationDto(uid, SystemConstant.getUuid());
         WhuUserAuthCacheUtil.setAuthCode(userAuthenticationDto);
         String pattern = "{0}{1}{2}";
         String code = URLEncoder.encode(MessageFormat.format(pattern, userAuthenticationDto.getUid(), SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(userAuthenticationDto.getCode())), SystemConstant.CHARSET_NAME);
+        // 测试开始
+        String testPattern = "{0}{1}{2}{3}";
+        String testCode = URLEncoder.encode(MessageFormat.format(testPattern, userAuthenticationDto.getUid() + "/" + cn, SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(userAuthenticationDto.getCode())), SystemConstant.CHARSET_NAME);
+        log.info("test-tea-code:{}",testCode);
+        log.info("test-tea-url:{}",dictionaryConfig.sysDomain().getLoginAuthenUrl() + testCode);
+        // 测试结束
         log.info("code:{}", code);
         response.setHeader("Access-Control-Allow-Origin", "*");
         response.sendRedirect(dictionaryConfig.sysDomain().getLoginAuthenUrl() + code);