use of me.zhyd.oauth.request.AuthWeChatMpRequest in project wumei-smart by kerwincui.
the class AuthRequestFactoryImpl method getAuthRequest.
/**
* 获得对于AUthRequest
*
* @param source 登录方式
* @return 对应AuthRequest
*/
@Override
public AuthRequestWrap getAuthRequest(String source) {
AuthRequestWrap authRequestWrap = new AuthRequestWrap();
AuthRequest authRequest;
try {
SocialPlatformType socialPlatformType = SocialPlatformType.valueOf(source.toUpperCase(Locale.ROOT));
SocialPlatform socialPlatform = iSocialPlatformService.selectSocialPlatformByPlatform(source);
authRequestWrap.setSocialPlatform(socialPlatform);
AuthConfig authConfig = AuthConfig.builder().clientId(socialPlatform.getClientId()).clientSecret(socialPlatform.getSecretKey()).redirectUri(socialPlatform.getRedirectUri()).build();
switch(socialPlatformType) {
case QQ:
{
authRequest = new AuthQqRequest(authConfig, authStateRedisCache);
break;
}
case Wechat:
{
authRequest = new AuthWeChatMpRequest(authConfig, authStateRedisCache);
break;
}
default:
{
throw new ServiceException("source: " + source + ",暂不支持");
}
}
authRequestWrap.setAuthRequest(authRequest);
return authRequestWrap;
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
Aggregations