From 7f5f81e4e66657b543e2e62c78a037c7c5223b02 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期三, 13 九月 2023 09:01:33 +0800
Subject: [PATCH] 代码提交

---
 Source/UBCS/ubcs-auth/src/main/java/com/vci/ubcs/auth/endpoint/PwdFreeLoginEndpoint.java |  190 +++++++++++++++++++++++-----------------------
 1 files changed, 95 insertions(+), 95 deletions(-)

diff --git a/Source/UBCS/ubcs-auth/src/main/java/com/vci/ubcs/auth/endpoint/PwdFreeLoginEndpoint.java b/Source/UBCS/ubcs-auth/src/main/java/com/vci/ubcs/auth/endpoint/PwdFreeLoginEndpoint.java
index 8c9565f..33f2850 100644
--- a/Source/UBCS/ubcs-auth/src/main/java/com/vci/ubcs/auth/endpoint/PwdFreeLoginEndpoint.java
+++ b/Source/UBCS/ubcs-auth/src/main/java/com/vci/ubcs/auth/endpoint/PwdFreeLoginEndpoint.java
@@ -1,95 +1,95 @@
-package com.vci.ubcs.auth.endpoint;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.oauth2.common.OAuth2AccessToken;
-import org.springframework.security.oauth2.provider.ClientDetailsService;
-import org.springframework.security.oauth2.provider.OAuth2RequestFactory;
-import org.springframework.security.oauth2.provider.TokenGranter;
-import org.springframework.security.oauth2.provider.TokenRequest;
-import org.springframework.security.oauth2.provider.endpoint.TokenEndpoint;
-import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
-import org.springframework.stereotype.Component;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
-import org.springframework.web.HttpRequestMethodNotSupportedException;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-import java.util.Map;
-
-/**
- * 鍏嶅瘑鐧诲綍
- * @author ludc
- * @date 2023/9/12 18:03
- */
-@Component
-public class PwdFreeLoginEndpoint extends TokenEndpoint {
-
-
-	@Autowired
-	private AuthorizationServerTokenServices tokenServices;
-
-	@Autowired
-	private ClientDetailsService clientDetailsService;
-
-	/*@Autowired
-	private OAuth2RequestFactory requestFactory;
-
-	@Autowired
-	private TokenGranter tokenGranter;*/
-
-	@RequestMapping(value = "/oauth/password-free-login",method = RequestMethod.GET)
-	public ResponseEntity<OAuth2AccessToken> getPasswordFreeLogin(@RequestParam Map<String, String> parameters) throws HttpRequestMethodNotSupportedException {
-		return postPasswordFreeLogin(parameters);
-	}
-
-	@RequestMapping(value = "/oauth/password-free-login",method = RequestMethod.POST)
-	public ResponseEntity<OAuth2AccessToken> postPasswordFreeLogin(@RequestParam Map<String, String> parameters) throws HttpRequestMethodNotSupportedException {
-		// 鍒ゆ柇鏄惁婊¤冻鍏嶅瘑鐧诲綍鐨勬潯浠�
-		if (isSkipLogin(parameters)) {
-			// 鐢熸垚璁块棶浠ょ墝
-			OAuth2AccessToken accessToken = createAccessToken(parameters);
-			// 杩斿洖璁块棶浠ょ墝
-			return ResponseEntity.ok(accessToken);
-		}
-
-		// 涓嶆弧瓒冲厤瀵嗙櫥褰曟潯浠讹紝杩斿洖閿欒淇℃伅
-		return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
-	}
-
-	private boolean isSkipLogin(Map<String, String> parameters) {
-		// 鏍规嵁鍏蜂綋闇�姹傚垽鏂槸鍚︽弧瓒冲厤瀵嗙櫥褰曠殑鏉′欢
-		// 渚嬪锛屽垽鏂姹傚弬鏁颁腑鏄惁鍖呭惈鏌愪釜鐗瑰畾鐨勬爣璇嗙
-		return parameters.containsKey("skipLogin");
-	}
-
-	private OAuth2AccessToken createAccessToken(Map<String, String> parameters) throws HttpRequestMethodNotSupportedException {
-		// 鏋勯�犺姹傚弬鏁�
-		MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
-		for (Map.Entry<String, String> entry : parameters.entrySet()) {
-			params.add(entry.getKey(), entry.getValue());
-		}
-
-		// 璋冪敤TokenEndpoint鐨刾ostAccessToken鏂规硶鐢熸垚璁块棶浠ょ墝
-		//return postAccessToken(PrincipalUtils.getPrincipal(), params).getBody();
-		return null;
-	}
-
-	private ResponseEntity<OAuth2AccessToken> postAccessToken(Authentication authentication, MultiValueMap<String, String> parameters) throws HttpRequestMethodNotSupportedException {
-		// 鏋勯�犺姹�
-		// TokenRequest tokenRequest = requestFactory.createTokenRequest(parameters, clientDetailsService.loadClientByClientId("your-client-id"));
-
-		// 鐢熸垚璁块棶浠ょ墝
-		// OAuth2AccessToken accessToken = tokenGranter.grant("password", tokenRequest);
-
-		// 杩斿洖璁块棶浠ょ墝
-		//return ResponseEntity.ok(accessToken);
-		return null;
-	}
-
-}
+//package com.vci.ubcs.auth.endpoint;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.http.HttpStatus;
+//import org.springframework.http.ResponseEntity;
+//import org.springframework.security.core.Authentication;
+//import org.springframework.security.oauth2.common.OAuth2AccessToken;
+//import org.springframework.security.oauth2.provider.ClientDetailsService;
+//import org.springframework.security.oauth2.provider.OAuth2RequestFactory;
+//import org.springframework.security.oauth2.provider.TokenGranter;
+//import org.springframework.security.oauth2.provider.TokenRequest;
+//import org.springframework.security.oauth2.provider.endpoint.TokenEndpoint;
+//import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
+//import org.springframework.stereotype.Component;
+//import org.springframework.util.LinkedMultiValueMap;
+//import org.springframework.util.MultiValueMap;
+//import org.springframework.web.HttpRequestMethodNotSupportedException;
+//import org.springframework.web.bind.annotation.PostMapping;
+//import org.springframework.web.bind.annotation.RequestMapping;
+//import org.springframework.web.bind.annotation.RequestMethod;
+//import org.springframework.web.bind.annotation.RequestParam;
+//
+//import java.util.Map;
+//
+///**
+// * 鍏嶅瘑鐧诲綍
+// * @author ludc
+// * @date 2023/9/12 18:03
+// */
+//@Component
+//public class PwdFreeLoginEndpoint extends TokenEndpoint {
+//
+//
+//	@Autowired
+//	private AuthorizationServerTokenServices tokenServices;
+//
+//	@Autowired
+//	private ClientDetailsService clientDetailsService;
+//
+//	/*@Autowired
+//	private OAuth2RequestFactory requestFactory;
+//
+//	@Autowired
+//	private TokenGranter tokenGranter;*/
+//
+//	@RequestMapping(value = "/oauth/password-free-login",method = RequestMethod.GET)
+//	public ResponseEntity<OAuth2AccessToken> getPasswordFreeLogin(@RequestParam Map<String, String> parameters) throws HttpRequestMethodNotSupportedException {
+//		return postPasswordFreeLogin(parameters);
+//	}
+//
+//	@RequestMapping(value = "/oauth/password-free-login",method = RequestMethod.POST)
+//	public ResponseEntity<OAuth2AccessToken> postPasswordFreeLogin(@RequestParam Map<String, String> parameters) throws HttpRequestMethodNotSupportedException {
+//		// 鍒ゆ柇鏄惁婊¤冻鍏嶅瘑鐧诲綍鐨勬潯浠�
+//		if (isSkipLogin(parameters)) {
+//			// 鐢熸垚璁块棶浠ょ墝
+//			OAuth2AccessToken accessToken = createAccessToken(parameters);
+//			// 杩斿洖璁块棶浠ょ墝
+//			return ResponseEntity.ok(accessToken);
+//		}
+//
+//		// 涓嶆弧瓒冲厤瀵嗙櫥褰曟潯浠讹紝杩斿洖閿欒淇℃伅
+//		return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
+//	}
+//
+//	private boolean isSkipLogin(Map<String, String> parameters) {
+//		// 鏍规嵁鍏蜂綋闇�姹傚垽鏂槸鍚︽弧瓒冲厤瀵嗙櫥褰曠殑鏉′欢
+//		// 渚嬪锛屽垽鏂姹傚弬鏁颁腑鏄惁鍖呭惈鏌愪釜鐗瑰畾鐨勬爣璇嗙
+//		return parameters.containsKey("skipLogin");
+//	}
+//
+//	private OAuth2AccessToken createAccessToken(Map<String, String> parameters) throws HttpRequestMethodNotSupportedException {
+//		// 鏋勯�犺姹傚弬鏁�
+//		MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+//		for (Map.Entry<String, String> entry : parameters.entrySet()) {
+//			params.add(entry.getKey(), entry.getValue());
+//		}
+//
+//		// 璋冪敤TokenEndpoint鐨刾ostAccessToken鏂规硶鐢熸垚璁块棶浠ょ墝
+//		//return postAccessToken(PrincipalUtils.getPrincipal(), params).getBody();
+//		return null;
+//	}
+//
+//	private ResponseEntity<OAuth2AccessToken> postAccessToken(Authentication authentication, MultiValueMap<String, String> parameters) throws HttpRequestMethodNotSupportedException {
+//		// 鏋勯�犺姹�
+//		// TokenRequest tokenRequest = requestFactory.createTokenRequest(parameters, clientDetailsService.loadClientByClientId("your-client-id"));
+//
+//		// 鐢熸垚璁块棶浠ょ墝
+//		// OAuth2AccessToken accessToken = tokenGranter.grant("password", tokenRequest);
+//
+//		// 杩斿洖璁块棶浠ょ墝
+//		//return ResponseEntity.ok(accessToken);
+//		return null;
+//	}
+//
+//}

--
Gitblit v1.9.3