Search in sources :

Example 1 with OAuth1ConnectionFactory

use of org.springframework.social.connect.support.OAuth1ConnectionFactory 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;
    }
}
Also used : OAuth1ConnectionFactory(org.springframework.social.connect.support.OAuth1ConnectionFactory) OAuth2ConnectionFactory(org.springframework.social.connect.support.OAuth2ConnectionFactory) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest) OAuth2Exception(org.craftercms.security.exception.OAuth2Exception)

Aggregations

OAuth2Exception (org.craftercms.security.exception.OAuth2Exception)1 OAuth1ConnectionFactory (org.springframework.social.connect.support.OAuth1ConnectionFactory)1 OAuth2ConnectionFactory (org.springframework.social.connect.support.OAuth2ConnectionFactory)1 ServletWebRequest (org.springframework.web.context.request.ServletWebRequest)1