// Path: src/main/java/org/springframework/social/salesforce/config/support/SalesforceApiHelper.java
// public class SalesforceApiHelper implements ApiHelper<Salesforce>
// {
//     private final UsersConnectionRepository usersConnectionRepository;
// 
//     private final UserIdSource userIdSource;
// 
//     private SalesforceApiHelper(UsersConnectionRepository usersConnectionRepository, UserIdSource userIdSource) {
//         this.usersConnectionRepository = usersConnectionRepository;
//         this.userIdSource = userIdSource;       
//     }
//     
//     
//     @Override
//     public Salesforce getApi()
//     {
//         Connection<Salesforce> connection = usersConnectionRepository.createConnectionRepository(userIdSource.getUserId()).findPrimaryConnection(Salesforce.class);
//         if (logger.isDebugEnabled() && connection == null) {
//             logger.debug("No current connection; Returning default TwitterTemplate instance.");
//         }
//         return connection != null ? connection.getApi() : null;
//     }
// 
//     private final static Log logger = LogFactory.getLog(SalesforceApiHelper.class);
//     
// }
// 
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceConnectionFactory.java
// public class SalesforceConnectionFactory extends OAuth2ConnectionFactory<Salesforce> {
// 
//     public SalesforceConnectionFactory(String clientId, String clientSecret) {
//         super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
//                 new SalesforceAdapter());
//     }
//     
//     public SalesforceConnectionFactory(String clientId, String clientSecret, boolean sandbox) {
//         super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
//                 sandbox ? new SalesforceAdapter(sandbox) : new SalesforceAdapter());
//     }
// 
//     public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl) {
//         super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
//               new SalesforceAdapter(instanceUrl));
//     }
//     
//     public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl, boolean sandbox) {
//         super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
//               sandbox ? new SalesforceAdapter(instanceUrl, sandbox) : new SalesforceAdapter(instanceUrl));
//     }
// 
//     @Deprecated
//     public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
//         super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
//                 authorizeUrl, tokenUrl), new SalesforceAdapter());
//     }
// 
//     @Deprecated
//     public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl) {
//         super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
//                                                           authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl));
//     }
//     
//     @Deprecated
//     public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl, String gatewayUrl) {
//         super("salesforce", new SalesforceServiceProvider(clientId, clientSecret,
//                                                           authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl, gatewayUrl));
//     }
// 
// }
// 
// Path: src/main/java/org/springframework/social/salesforce/security/SalesforceAuthenticationService.java
// public class SalesforceAuthenticationService extends OAuth2AuthenticationService<Salesforce>
// {
//     public SalesforceAuthenticationService(String consumerKey, String consumerSecret)
//     {
//         super(new SalesforceConnectionFactory(consumerKey, consumerSecret));
//     }
//     
//     public SalesforceAuthenticationService(String consumerKey, String consumerSecret, boolean sandbox)
//     {
//         super(new SalesforceConnectionFactory(consumerKey, consumerSecret, sandbox));
//     }
// }


import org.springframework.social.config.xml.AbstractProviderConfigBeanDefinitionParser;
import org.springframework.social.salesforce.config.support.SalesforceApiHelper;
import org.springframework.social.salesforce.connect.SalesforceConnectionFactory;
import org.springframework.social.salesforce.security.SalesforceAuthenticationService;
import org.springframework.social.security.provider.SocialAuthenticationService;
/**
 * Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.social.salesforce.config.xml;


/**
 * 
 * @author Jared Ottley
 *
 */
public class SalesforceConfigBeanDefinitionParser extends AbstractProviderConfigBeanDefinitionParser
{
    public SalesforceConfigBeanDefinitionParser() {
        super(SalesforceConnectionFactory.class, SalesforceApiHelper.class);
    }

    @Override
    protected Class<? extends SocialAuthenticationService<?>> getAuthenticationServiceClass() {
// Path: src/main/java/org/springframework/social/salesforce/config/support/SalesforceApiHelper.java
// public class SalesforceApiHelper implements ApiHelper<Salesforce>
// {
//     private final UsersConnectionRepository usersConnectionRepository;
// 
//     private final UserIdSource userIdSource;
// 
//     private SalesforceApiHelper(UsersConnectionRepository usersConnectionRepository, UserIdSource userIdSource) {
//         this.usersConnectionRepository = usersConnectionRepository;
//         this.userIdSource = userIdSource;       
//     }
//     
//     
//     @Override
//     public Salesforce getApi()
//     {
//         Connection<Salesforce> connection = usersConnectionRepository.createConnectionRepository(userIdSource.getUserId()).findPrimaryConnection(Salesforce.class);
//         if (logger.isDebugEnabled() && connection == null) {
//             logger.debug("No current connection; Returning default TwitterTemplate instance.");
//         }
//         return connection != null ? connection.getApi() : null;
//     }
// 
//     private final static Log logger = LogFactory.getLog(SalesforceApiHelper.class);
//     
// }
// 
// Path: src/main/java/org/springframework/social/salesforce/connect/SalesforceConnectionFactory.java
// public class SalesforceConnectionFactory extends OAuth2ConnectionFactory<Salesforce> {
// 
//     public SalesforceConnectionFactory(String clientId, String clientSecret) {
//         super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
//                 new SalesforceAdapter());
//     }
//     
//     public SalesforceConnectionFactory(String clientId, String clientSecret, boolean sandbox) {
//         super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
//                 sandbox ? new SalesforceAdapter(sandbox) : new SalesforceAdapter());
//     }
// 
//     public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl) {
//         super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret),
//               new SalesforceAdapter(instanceUrl));
//     }
//     
//     public SalesforceConnectionFactory(String clientId, String clientSecret, String instanceUrl, boolean sandbox) {
//         super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret, sandbox),
//               sandbox ? new SalesforceAdapter(instanceUrl, sandbox) : new SalesforceAdapter(instanceUrl));
//     }
// 
//     @Deprecated
//     public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl) {
//         super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
//                 authorizeUrl, tokenUrl), new SalesforceAdapter());
//     }
// 
//     @Deprecated
//     public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl) {
//         super(SalesforceServiceProvider.ID, new SalesforceServiceProvider(clientId, clientSecret,
//                                                           authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl));
//     }
//     
//     @Deprecated
//     public SalesforceConnectionFactory(String clientId, String clientSecret, String authorizeUrl, String tokenUrl, String instanceUrl, String gatewayUrl) {
//         super("salesforce", new SalesforceServiceProvider(clientId, clientSecret,
//                                                           authorizeUrl, tokenUrl), new SalesforceAdapter(instanceUrl, gatewayUrl));
//     }
// 
// }
// 
// Path: src/main/java/org/springframework/social/salesforce/security/SalesforceAuthenticationService.java
// public class SalesforceAuthenticationService extends OAuth2AuthenticationService<Salesforce>
// {
//     public SalesforceAuthenticationService(String consumerKey, String consumerSecret)
//     {
//         super(new SalesforceConnectionFactory(consumerKey, consumerSecret));
//     }
//     
//     public SalesforceAuthenticationService(String consumerKey, String consumerSecret, boolean sandbox)
//     {
//         super(new SalesforceConnectionFactory(consumerKey, consumerSecret, sandbox));
//     }
// }


// Path: src/main/java/org/springframework/social/salesforce/config/xml/SalesforceConfigBeanDefinitionParser.java
import org.springframework.social.config.xml.AbstractProviderConfigBeanDefinitionParser;
import org.springframework.social.salesforce.config.support.SalesforceApiHelper;
import org.springframework.social.salesforce.connect.SalesforceConnectionFactory;
import org.springframework.social.salesforce.security.SalesforceAuthenticationService;
import org.springframework.social.security.provider.SocialAuthenticationService;

/**
 * Copyright (C) 2017 https://github.com/jottley/spring-social-salesforce
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.social.salesforce.config.xml;


/**
 * 
 * @author Jared Ottley
 *
 */
public class SalesforceConfigBeanDefinitionParser extends AbstractProviderConfigBeanDefinitionParser
{
    public SalesforceConfigBeanDefinitionParser() {
        super(SalesforceConnectionFactory.class, SalesforceApiHelper.class);
    }

    @Override
    protected Class<? extends SocialAuthenticationService<?>> getAuthenticationServiceClass() {
        return SalesforceAuthenticationService.class;