修改蒙速办对接逻辑
This commit is contained in:
parent
9dcc9ba7de
commit
4e10289a23
@ -1,8 +1,11 @@
|
||||
package com.cm.common.inspurmsbh5auth.icity;
|
||||
|
||||
import ink.wgink.util.ResourceUtil;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author xwangs
|
||||
* @create 2022-02-17 9:21
|
||||
@ -31,7 +34,7 @@ public class InspurAuthConfig {
|
||||
this.redirectUri = redirectUri;
|
||||
}
|
||||
|
||||
/*public String getPrivateKey() {
|
||||
public String getPrivateKey() {
|
||||
String s = "";
|
||||
try {
|
||||
InputStream in = ResourceUtil.getJarResourceInputStream("privateKey.txt");
|
||||
@ -51,5 +54,5 @@ public class InspurAuthConfig {
|
||||
System.out.println("3{{{{{{{{{{{{{{{ERROR: privateKey.txt 文件为找到!}}}}}}}}}}}}}}}}}");
|
||||
return "";
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
package com.cm.common.inspurmsbh5auth.inspurfilter;
|
||||
|
||||
import com.cm.common.inspurmsbh5auth.icity.AuthUtil;
|
||||
import com.cm.common.inspurmsbh5auth.icity.InspurAuthConfig;
|
||||
import com.cm.common.inspurmsbh5auth.icity.InspurUserInfo;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.util.date.DateUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
@ -10,6 +14,8 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xwangs
|
||||
@ -28,6 +34,7 @@ public class InspurAuthFilter implements Filter {
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletResponse resp = (HttpServletResponse) response;
|
||||
String appId = inspurAuthConfig.getAppId();
|
||||
String privateKey = inspurAuthConfig.getPrivateKey();
|
||||
String redirectUri = inspurAuthConfig.getRedirectUri();
|
||||
String openId = req.getParameter("open_id");
|
||||
String code = req.getParameter("code");
|
||||
@ -43,6 +50,26 @@ public class InspurAuthFilter implements Filter {
|
||||
resp.sendRedirect(authUrl);
|
||||
return;
|
||||
}
|
||||
if(code != null) {
|
||||
try {
|
||||
AuthUtil.AuthToken token = AuthUtil.getTokenByCodeV2(appId, code, privateKey);
|
||||
AuthUtil.UserAuthInfo userAuthInfo = AuthUtil.getUserAuthInfoV2(appId, token.getToken(), privateKey);
|
||||
InspurUserInfo inspurUser = new InspurUserInfo();
|
||||
try {
|
||||
inspurUser.setRealName(userAuthInfo.getRealName());
|
||||
inspurUser.setOpenId(userAuthInfo.getOpenId());
|
||||
inspurUser.setIdCard(userAuthInfo.getIdCard());
|
||||
inspurUser.setCheckPhone(userAuthInfo.getCheckPhone());
|
||||
inspurUser.setMobilePhone(userAuthInfo.getMobilePhone());
|
||||
req.getSession().setAttribute("inspurUser", inspurUser);
|
||||
} catch (Exception e2){
|
||||
req.getSession().setAttribute("inspurUser", inspurUser);
|
||||
e2.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
chain.doFilter(request,response);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user