LoginController.java
2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package com.neotel.smf.login;
import com.alibaba.fastjson.JSON;
import com.neotel.smf.login.config.LoginConfiguration;
import com.neotel.smf.login.method.ParseJwtTokeMethod;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.util.Map;
@Controller
@Slf4j
public class LoginController {
@Autowired
private LoginConfiguration loginConfiguration;
/**
* 登录页跳转
*
* @return
*/
@RequestMapping("/login")
public String login() {
return "login";
}
/**
* 登录成功页
*
* @return
*/
@RequestMapping("/loginSuccess")
public String loginSuccess() {
return "loginSuccess";
}
/**
* 确认登录页
*
* @return
*/
@RequestMapping("/confirm")
public String confirm() {
return "confirm";
}
@RequestMapping("/oauth2/authorize")
public String authorize(){
return confirm();
}
/**
* 一键登录重定向地址
*
* @return
*/
@RequestMapping("/loginRedirect")
@ResponseBody
public String loginRedirect() {
String redirectUrl = loginConfiguration.getAdfsBaseAddress()
+ "/oauth2/authorize"
+ "?"
+ "resource=" + loginConfiguration.getClientId()
+ "&client_id=" + loginConfiguration.getClientId()
+ "&response_type=code"
+ "&haschrome=1"
+ "&redirect_uri="+loginConfiguration.getRedirectUri()
+ "&code_challenge=jbxg31yfKmRhuBVutV-DtfoKsvEsDGKbDF_mEudl2a4"
+ "&code_challenge_method=S256"
+ "&state=15d57431-f939-4e4a-8006-fab1358cafee9507c217-d512-4f28-a8bf-c16928db80ce"
+ "&response_mode=form_post"
+ "&client-request-id=69ea5a4a-c0db-48c6-ad0e-feb9cee43301"
+ "&x-client-SKU=PCL.Desktop"
+ "&x-client-Ver=5.2.9.0"
+ "&x-client-CPU=x64"
+ "&x-client-OS=Microsoft+Windows+NT+6.2.9200.0";
log.info("一键登录重定向地址为:{}", redirectUrl);
return redirectUrl;
}
/**
* 确认登录
*
* @return
*/
@RequestMapping("/confirmLogin")
public ModelAndView confirmLogin(String token) {
log.info("方法{}请求参数为{}", "confirmLogin", token);
Map map = ParseJwtTokeMethod.parseJwtTokenMap(token);
ModelAndView modelAndView = new ModelAndView("redirect:" + loginConfiguration.getSuccessHtml());
modelAndView.addObject(JSON.toJSONString(map));
return modelAndView;
}
}