Commit 7d80d85f authored by 周健威's avatar 周健威

添加数据中心验证代码

parent e98f6282
package com.github.wxiaoqi.security.auth.controller;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.auth.feign.IUserService;
import com.github.wxiaoqi.security.auth.service.AuthService;
import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest;
import com.github.wxiaoqi.security.common.constant.RequestTypeConstants;
......@@ -44,6 +46,9 @@ public class AuthController {
@Qualifier("appAuthService")
private AuthService appAuthService;
@Autowired
private IUserService userService;
@RequestMapping(value = "token", method = RequestMethod.POST)
public ObjectRestResponse<String> createAuthenticationToken(
@RequestBody JwtAuthenticationRequest authenticationRequest,
......@@ -54,7 +59,7 @@ public class AuthController {
if (requestType == null || requestType.trim().equals("")) {
requestType = RequestTypeConstants.BASE;
}
final String token;
String token;
if (RequestTypeConstants.APP.equals(requestType)) {
token = appAuthService.login(authenticationRequest);
} else {
......@@ -64,12 +69,28 @@ public class AuthController {
}
@RequestMapping(value = "maxkeyLogin", method = RequestMethod.GET)
public ObjectRestResponse<String> maxkeyLogin() throws Exception {
String callback="https://gdxm.upyuns.com/oauth20callback";
public ObjectRestResponse<String> maxkeyLogin(String callback, String apiKey, String apiSecret) throws Exception {
callback= StrUtil.isBlank(callback) ? "1024011282958778368" : callback;
apiKey= StrUtil.isBlank(apiKey) ? "1024011282958778368" : apiKey;
apiSecret= StrUtil.isBlank(apiSecret) ? "JF17MjIwODIwMjQxNDU2MjA2OTkOJS" : apiSecret;
OAuthService service = new ServiceBuilder()
.provider(MaxkeyApi20.class)
.apiKey(apiKey)
.apiSecret(apiSecret)
.callback(callback)
.build();
Token EMPTY_TOKEN = null;
String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);
return ObjectRestResponse.succ(authorizationUrl+"&approval_prompt=auto");
}
@RequestMapping(value = "maxkeyLoginMgmt", method = RequestMethod.GET)
public ObjectRestResponse<String> maxkeyLoginMgmt() throws Exception {
String callback="https://gdxm.upyuns.com/mgmt/oauth20callback";
OAuthService service = new ServiceBuilder()
.provider(MaxkeyApi20.class)
.apiKey("1024011282958778368")
.apiSecret("JF17MjIwODIwMjQxNDU2MjA2OTkOJS")
.apiKey("1024312362988994560")
.apiSecret("PeVRMjMwODIwMjQxMDUyNDM3NzIwLg")
.callback(callback)
.build();
Token EMPTY_TOKEN = null;
......@@ -90,12 +111,22 @@ public class AuthController {
OAuthService service = (OAuthService)request.getSession().getAttribute("oauthv20service");
if(service==null){
// String callback="https://gdxm.upyuns.com/oauth20callback";
String callback="https://gdxm.upyuns.com/oauth20callback";
String callback;
String apiKey;
String apiSecret;
if (RequestTypeConstants.APP.equals(requestType)) {
callback="https://gdxm.upyuns.com/oauth20callback";
apiKey="1024011282958778368";
apiSecret="JF17MjIwODIwMjQxNDU2MjA2OTkOJS";
} else {
callback="https://gdxm.upyuns.com/mgmt/oauth20callback";
apiKey="1024312362988994560";
apiSecret="PeVRMjMwODIwMjQxMDUyNDM3NzIwLg";
}
service = new ServiceBuilder()
.provider(MaxkeyApi20.class)
.apiKey("1024011282958778368")
.apiSecret("JF17MjIwODIwMjQxNDU2MjA2OTkOJS")
.apiKey(apiKey)
.apiSecret(apiSecret)
.callback(callback)
.build();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment