| | |
| | | /* |
| | | package com.vci.ubcs.auth.endpoint; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import java.util.Map; |
| | | |
| | | */ |
| | | /** |
| | | * 免密登录 |
| | | * @author ludc |
| | | * @date 2023/9/12 18:03 |
| | | *//* |
| | | |
| | | */ |
| | | @Component |
| | | public class PwdFreeLoginEndpoint extends TokenEndpoint { |
| | | |
| | |
| | | @Autowired |
| | | private ClientDetailsService clientDetailsService; |
| | | |
| | | @Autowired |
| | | /*@Autowired |
| | | private OAuth2RequestFactory requestFactory; |
| | | |
| | | @Autowired |
| | | private TokenGranter tokenGranter; |
| | | private TokenGranter tokenGranter;*/ |
| | | |
| | | @RequestMapping(value = "/oauth/password-free-login",method = RequestMethod.GET) |
| | | public ResponseEntity<OAuth2AccessToken> getPasswordFreeLogin(@RequestParam Map<String, String> parameters) throws HttpRequestMethodNotSupportedException { |
| | |
| | | } |
| | | |
| | | // 调用TokenEndpoint的postAccessToken方法生成访问令牌 |
| | | return postAccessToken(PrincipalUtils.getPrincipal(), params).getBody(); |
| | | //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")); |
| | | // TokenRequest tokenRequest = requestFactory.createTokenRequest(parameters, clientDetailsService.loadClientByClientId("your-client-id")); |
| | | |
| | | // 生成访问令牌 |
| | | OAuth2AccessToken accessToken = tokenGranter.grant("password", tokenRequest); |
| | | // OAuth2AccessToken accessToken = tokenGranter.grant("password", tokenRequest); |
| | | |
| | | // 返回访问令牌 |
| | | return ResponseEntity.ok(accessToken); |
| | | //return ResponseEntity.ok(accessToken); |
| | | return null; |
| | | } |
| | | |
| | | } |
| | | */ |