use of com.easy.cloud.core.oauth.client.base.pojo.dto.EcBaseOauthResourceDTO in project dq-easy-cloud by dq-open-cloud.
the class EcOauthManager method getOauthResourceDTO.
/**
* <p>
* 获取授权资源数据传输对象
* </p>
*
* @param oauth2Token
* @return com.easy.cloud.core.oauth.client.base.pojo.dto.EcBaseOauthUserDTO
* @author daiqi
* @date 2018/7/16 16:07
*/
@Transactional(rollbackFor = Exception.class)
public EcBaseOauthResourceDTO getOauthResourceDTO(EcBaseOauthToken oauth2Token) {
try {
// 获取授权token
Map<String, Object> oAuthResponseParam = getAccessToken(oauth2Token);
EcBaseOauthResourceDTO oauthResourceDTO = oauth2Token.doGetOauthResource(oAuthResponseParam);
oauthService.saveOauthResource(oauthResourceDTO);
return oauthResourceDTO;
} catch (Exception e) {
e.printStackTrace();
throw new AuthenticationException(e);
}
}
use of com.easy.cloud.core.oauth.client.base.pojo.dto.EcBaseOauthResourceDTO in project dq-easy-cloud by dq-open-cloud.
the class EcBaseOauthToken method doGetOauthResource.
/**
* <p>
* 执行获取授权资源信息
* </p>
* <pre>
* 子类可以通过重写该方法实现自己的获取授权资源数据传输对象的数据
* </pre>
*
* @param oAuthResponseParam
* @return com.easy.cloud.core.oauth.client.base.pojo.dto.EcBaseOauthResourceDTO
* @author daiqi
* @date 2018/7/18 11:54
*/
public EcBaseOauthResourceDTO doGetOauthResource(Map<String, Object> oAuthResponseParam) throws Exception {
// 获取资源请求构建者
EcBaseResourceRequestBuilder resourceRequestBuilder = getResourceRequestBuilder();
// 构建客户端请求参数
OAuthClientRequest resourceRequest = resourceRequestBuilder.buildClientRequest(oAuthResponseParam);
// 执行请求资源
EcBaseOauthResourceResponse resourceResponse = oAuthClient.resource(resourceRequest, OAuth.HttpMethod.GET, resourceRequestBuilder.getResourceResponseClass());
// 从资源响应对象中获取资源数据传输对象
EcBaseOauthResourceDTO resourceDTO = resourceResponse.getResourceObj(resourceResponse.getResourceDTOClass());
EcLogUtils.info("授权获取到的用户信息", resourceDTO, logger);
return resourceDTO;
}
use of com.easy.cloud.core.oauth.client.base.pojo.dto.EcBaseOauthResourceDTO in project dq-easy-cloud by dq-open-cloud.
the class EcZfbOauthToken method doGetOauthResource.
@Override
public EcBaseOauthResourceDTO doGetOauthResource(Map<String, Object> oAuthResponseParam) throws Exception {
AlipayUserInfoShareRequest userInfoShareRequest = new AlipayUserInfoShareRequest();
String accessToken = EcMapUtils.getString(oAuthResponseParam, EcOauthAccessToken.ACCESS_TOKEN);
AlipayUserInfoShareResponse shareResponse = alipayClient.execute(userInfoShareRequest, accessToken);
EcAssert.verifyObjNull(shareResponse, "shareResponse");
if (shareResponse != null && shareResponse.isSuccess()) {
EcBaseOauthResourceResponse resourceResponse = EcBeanFactory.newInstance(getResourceRequestBuilder().getResourceResponseClass());
EcBaseOauthResourceDTO resourceDTO = EcJSONUtils.parseObject(shareResponse, resourceResponse.getResourceDTOClass());
EcLogUtils.info("授权获取到的用户信息", resourceDTO, logger);
return resourceDTO;
} else {
throw new EcBaseBusinessException(shareResponse.getCode(), shareResponse.getMsg()).buildExceptionDetail(shareResponse);
}
}
Aggregations