use of org.craftercms.security.exception.OAuth2Exception in project profile by craftercms.
the class ProviderLoginSupportImpl method completeConnection.
protected Connection<?> completeConnection(ConnectSupport connectSupport, String providerId, HttpServletRequest request) throws OAuth2Exception {
if (StringUtils.isNotEmpty(request.getParameter(PARAM_OAUTH_TOKEN))) {
OAuth1ConnectionFactory<?> connectionFactory = (OAuth1ConnectionFactory<?>) getConnectionFactory(providerId);
ServletWebRequest webRequest = new ServletWebRequest(request);
return connectSupport.completeConnection(connectionFactory, webRequest);
} else if (StringUtils.isNotEmpty(request.getParameter(PARAM_CODE))) {
OAuth2ConnectionFactory<?> connectionFactory = (OAuth2ConnectionFactory<?>) getConnectionFactory(providerId);
ServletWebRequest webRequest = new ServletWebRequest(request);
return connectSupport.completeConnection(connectionFactory, webRequest);
} else if (StringUtils.isNotEmpty(request.getParameter(PARAM_ERROR))) {
String error = request.getParameter(PARAM_ERROR);
String errorDescription = request.getParameter(PARAM_ERROR_DESCRIPTION);
String errorUri = request.getParameter(PARAM_ERROR_URI);
throw new OAuth2Exception(error, errorDescription, errorUri);
} else {
return null;
}
}
Aggregations