From f1338e26eaf421a1e5f90d406af093f3616861b6 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期一, 25 九月 2023 09:47:08 +0800
Subject: [PATCH] 代码打包
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/PasswordFreeLoginController.java | 51 +++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/PasswordFreeLoginController.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/PasswordFreeLoginController.java
index d0cd358..75a3427 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/PasswordFreeLoginController.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/PasswordFreeLoginController.java
@@ -5,12 +5,21 @@
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+import org.springframework.web.servlet.view.RedirectView;
import javax.annotation.Resource;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import java.io.IOException;
import static com.vci.ubcs.starter.util.AESUtils.aesDecrypt;
import static com.vci.ubcs.starter.util.AESUtils.aesEncrypt;
@@ -24,6 +33,16 @@
@Api(value = "鍏嶅瘑鐧诲綍鎺ュ彛", tags = "鍏嶅瘑鐧诲綍鎺ュ彛")
@Slf4j
public class PasswordFreeLoginController {
+
+ // 鍒汉璋冪敤鎴戜滑鐨勫崟鐐归噸瀹氬悜鐨勫湴鍧�
+ @Value("${password-free.sso-redirect-addr}")
+ private String ssoRedirectAddr;
+
+ @Value("${password-free.client-id:a104c4fd2f0e4958}")
+ private String clientId;//搴旂敤ID
+
+ @Value("${password-free.secret-key:9fbd170bd83eb869}")
+ private String secretKey;//搴旂敤绉橀挜
@Resource
private IPasswordFreeLoginService passwordFreeLoginService;
@@ -41,21 +60,41 @@
/**
* 鍗曠偣鐧诲綍
- * @param request
+ * @param empCode
* @return
* @throws Exception
*/
@GetMapping("/ssoLogin")
- public ModelAndView oaSsoLogin(HttpServletRequest request, ModelAndView model){
+ public String oaSsoLogin(@RequestParam("empCode") String empCode){
String token;
try {
- token = passwordFreeLoginService.ssoFreeLogin(request);
+ token = passwordFreeLoginService.ssoFreeLogin(empCode);
}catch (Exception e){
throw new ServiceException("鍗曠偣鐧诲綍鑾峰彇token澶辫触:"+e.getMessage());
}
- model.addObject("token",token);
- model.setViewName("sso");
- return model;
+ return token;
+ }
+
+ /**
+ * 鍗曠偣鐧诲綍
+ * @param empCode
+ * @return
+ * @throws Exception
+ */
+ @GetMapping("/test")
+ public String test(@RequestParam("empCode") String empCode){
+ String enStr2;
+ try {
+ // 鍔犲瘑
+ String pwdfree = aesEncrypt("pwdfree", secretKey);
+ String pwdfree2 = aesEncrypt(pwdfree, clientId);
+ // 瑙e瘑
+ String enStr1 = aesDecrypt(empCode, secretKey);
+ enStr2 = aesDecrypt(enStr1, clientId);
+ }catch (Exception e){
+ throw new ServiceException("鍗曠偣鐧诲綍鑾峰彇token澶辫触:"+e.getMessage());
+ }
+ return enStr2;
}
}
--
Gitblit v1.9.3