|
|
|
@ -1,7 +1,10 @@ |
|
|
|
package org.springblade.auth.granter; |
|
|
|
package org.springblade.auth.granter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.yawei.pso.DateHelper; |
|
|
|
|
|
|
|
import com.yawei.pso.PSORequest; |
|
|
|
import com.yawei.pso.SSOResponse; |
|
|
|
import com.yawei.pso.SSOResponse; |
|
|
|
import com.yawei.pso.TicketManager; |
|
|
|
import com.yawei.pso.TicketManager; |
|
|
|
|
|
|
|
import com.yawei.pso.security.Encrypter; |
|
|
|
import org.springblade.auth.constant.AuthConstant; |
|
|
|
import org.springblade.auth.constant.AuthConstant; |
|
|
|
import org.springblade.auth.service.BladeUserDetails; |
|
|
|
import org.springblade.auth.service.BladeUserDetails; |
|
|
|
import org.springblade.auth.utils.TokenUtil; |
|
|
|
import org.springblade.auth.utils.TokenUtil; |
|
|
|
@ -22,6 +25,7 @@ import org.springframework.security.oauth2.provider.token.AbstractTokenGranter; |
|
|
|
import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices; |
|
|
|
import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
@ -55,7 +59,6 @@ public class YaweiTokenGranter extends AbstractTokenGranter { |
|
|
|
Map<String, String> parameters = new LinkedHashMap<>(tokenRequest.getRequestParameters()); |
|
|
|
Map<String, String> parameters = new LinkedHashMap<>(tokenRequest.getRequestParameters()); |
|
|
|
// 金宏来源
|
|
|
|
// 金宏来源
|
|
|
|
String ssoToken = parameters.get("SSOToken"); |
|
|
|
String ssoToken = parameters.get("SSOToken"); |
|
|
|
ssoToken = "3JORfctchfvnMgitTjT7g2NWNZJNMaFTy6GLppUSBy7W1ga5b2BsC4RlnHplxDd8DxBKW9Ep0uBzqzm9YK3ioSHUIHI63dQb9qT31PPJLUIAG4Z25dVKPYEfGY3J1xQVqo+5NudKeSmPmAilF4oDLTJTQsW5IuVjrQk4K+ILX+xvkZSsS1fkDvQQVq2hj/rl2YnlCad18sK4azKwPbpzdKCpox55/kmeUJpm0hi5k3+Gg8lx42OrY+74/R/1kZqG"; |
|
|
|
|
|
|
|
R<UserInfo> result; |
|
|
|
R<UserInfo> result; |
|
|
|
BladeUserDetails bladeUserDetails; |
|
|
|
BladeUserDetails bladeUserDetails; |
|
|
|
|
|
|
|
|
|
|
|
@ -69,6 +72,18 @@ public class YaweiTokenGranter extends AbstractTokenGranter { |
|
|
|
redirectAddr = bizResult.getData(); |
|
|
|
redirectAddr = bizResult.getData(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取回调地址
|
|
|
|
|
|
|
|
String fallbackUrl = parameters.get("fallbackUrl"); |
|
|
|
|
|
|
|
fallbackUrl = Func.isBlank(fallbackUrl) ? "http://10.133.191.105/#/login" : fallbackUrl; |
|
|
|
|
|
|
|
Encrypter en = new Encrypter("qP70966AcZCQyXR+3P1mfjmqqxdkagom", "FnZ+19kJbQ8="); |
|
|
|
|
|
|
|
String posStr = "PSOSite$" + en.EncryptString(DateHelper.getCurrentStrTime() + "|" + fallbackUrl + "|" + null + "|"); |
|
|
|
|
|
|
|
// PSORequest psoRequest = new PSORequest(request);
|
|
|
|
|
|
|
|
// String requeststr = psoRequest.CreateHash();
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
redirectAddr = redirectAddr + "?SSOToken=" + URLEncoder.encode(posStr, "UTF-8"); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
throw new InvalidGrantException("回调地址加密失败!"); |
|
|
|
|
|
|
|
} |
|
|
|
throw new InvalidRequestException(redirectAddr); |
|
|
|
throw new InvalidRequestException(redirectAddr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -81,7 +96,6 @@ public class YaweiTokenGranter extends AbstractTokenGranter { |
|
|
|
tm = ssoResp.CreatePSOTicket(); |
|
|
|
tm = ssoResp.CreatePSOTicket(); |
|
|
|
result = userClient.userInfo(StringPool.EMPTY, tm.getUserID()); |
|
|
|
result = userClient.userInfo(StringPool.EMPTY, tm.getUserID()); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
// result = userClient.userInfo(StringPool.EMPTY, "jiangzx");
|
|
|
|
|
|
|
|
throw new InvalidGrantException("SSOToken解析失败!"); |
|
|
|
throw new InvalidGrantException("SSOToken解析失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|