|
@ -25,10 +25,7 @@ import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
|
|
|
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
|
|
|
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
|
|
|
import com.yihu.jw.security.service.*;
|
|
|
import com.yihu.jw.security.utils.AES;
|
|
|
import com.yihu.jw.security.utils.DateUtil;
|
|
|
import com.yihu.jw.security.utils.IdCardUtil;
|
|
|
import com.yihu.jw.security.utils.SerializeUtil;
|
|
|
import com.yihu.jw.security.utils.*;
|
|
|
import com.yihu.jw.sms.service.YkyyINSMSService;
|
|
|
import com.yihu.jw.sms.service.ZBSmsService;
|
|
|
import com.yihu.jw.sms.service.ZhongShanSMSService;
|
|
@ -1185,6 +1182,75 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 医联康护授权登录
|
|
|
* @param authCode
|
|
|
* @param client_id
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/oauth/ylkhLogin", method = RequestMethod.POST)
|
|
|
public ObjEnvelop getYlkhDecrypt(String authCode,String client_id) {
|
|
|
|
|
|
if (StringUtils.isEmpty(client_id)) {
|
|
|
throw new InvalidRequestException("client_id is null");
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
logger.info("authCode :"+authCode);
|
|
|
|
|
|
//固定秘钥解密
|
|
|
String key = "FEA5049E4CCD16A9";
|
|
|
String result = AesEncryptUtils.decrypt(authCode,key);
|
|
|
logger.info("wjwLogin :"+result);
|
|
|
|
|
|
BasePatientDO patientDO = oauthWjwConfigService.savePatient(result);
|
|
|
if(patientDO == null){
|
|
|
return ObjEnvelop.getError("授权登录失败!");
|
|
|
}
|
|
|
|
|
|
ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
|
|
|
|
|
|
Map<String, String> parameters = new HashedMap();
|
|
|
|
|
|
parameters.put("username",patientDO.getIdcard());
|
|
|
parameters.put("grant_type", "ihealthCode");
|
|
|
parameters.put("login_type","4");
|
|
|
|
|
|
TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
|
|
|
if (authenticatedClient != null) {
|
|
|
oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
|
|
|
}
|
|
|
OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
|
|
|
if (token == null) {
|
|
|
throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
|
|
|
}
|
|
|
|
|
|
WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
|
|
|
wlyyUserSimple.setAccessToken(token.getValue());
|
|
|
wlyyUserSimple.setTokenType(token.getTokenType());
|
|
|
wlyyUserSimple.setExpiresIn(token.getExpiresIn());
|
|
|
wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
|
|
|
wlyyUserSimple.setUser(parameters.get("username"));
|
|
|
String loginType = parameters.get("login_type");
|
|
|
|
|
|
BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
|
|
|
userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
|
|
|
|
|
|
baseLoginLogDO.setUserId(wlyyUserSimple.getId());
|
|
|
baseLoginLogDO.setCreateTime(new Date());
|
|
|
String userAgent = JSONObject.toJSONString(wlyyUserSimple);
|
|
|
baseLoginLogDO.setUserAgent(userAgent);
|
|
|
baseLoginLogDO.setLoginType(loginType);
|
|
|
baseLoginLogService.save(baseLoginLogDO);
|
|
|
|
|
|
return ObjEnvelop.getSuccess("success",wlyyUserSimple);
|
|
|
|
|
|
}catch (Exception e){
|
|
|
logger.error(e);
|
|
|
}
|
|
|
return ObjEnvelop.getError("登录失败!");
|
|
|
}
|
|
|
|
|
|
// /**
|
|
|
// * 获取易联众授权码
|
|
|
// * @return
|