All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.social.partnercenter.connect.PartnerCenterConnectionFactory Maven / Gradle / Ivy

Go to download

A provider extension for Spring Social to enable connectivity with Microsoft and an API binding for Microsoft's Partner Center API.

There is a newer version: 10.11.0
Show newest version
package org.springframework.social.partnercenter.connect;

import java.util.Collection;

import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.retry.support.RetryTemplate;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionData;
import org.springframework.social.oauth2.AccessGrant;
import org.springframework.social.partnercenter.PartnerCenter;
import org.springframework.social.partnercenter.oauth2.PartnerCenterAuthorizationTemplate;

public class PartnerCenterConnectionFactory extends BasePartnerCenterConnectionFactory {

	public PartnerCenterConnectionFactory(String applicationId, String applicationSecret, String tenant){
		this(PartnerCenter.PROVIDER_ID, new PartnerCenterServiceProvider(applicationId, applicationSecret, tenant), new PartnerCenterApiAdapter());
	}
	public PartnerCenterConnectionFactory(String applicationId, String applicationSecret, String tenant, RetryTemplate retryTemplate){
		this(PartnerCenter.PROVIDER_ID, new PartnerCenterServiceProvider(applicationId, applicationSecret, tenant, retryTemplate), new PartnerCenterApiAdapter());
	}

	public PartnerCenterConnectionFactory(String applicationId, String applicationSecret, String tenant, String apiVersion){
		this(PartnerCenter.PROVIDER_ID, new PartnerCenterServiceProvider(applicationId, applicationSecret, tenant, apiVersion), new PartnerCenterApiAdapter());
	}

	public PartnerCenterConnectionFactory(String applicationId, String applicationSecret, String tenant, String apiVersion, RetryTemplate retryTemplate){
		this(PartnerCenter.PROVIDER_ID, new PartnerCenterServiceProvider(applicationId, applicationSecret, tenant, apiVersion, retryTemplate), new PartnerCenterApiAdapter());
	}

	public PartnerCenterConnectionFactory(String applicationId, String applicationSecret, String tenant, String apiVersion, Collection interceptors){
		this(PartnerCenter.PROVIDER_ID, new PartnerCenterServiceProvider(applicationId, applicationSecret, tenant, apiVersion, interceptors), new PartnerCenterApiAdapter());
	}

	public PartnerCenterConnectionFactory(String applicationId, String applicationSecret, String tenant, String apiVersion, Collection interceptors, RetryTemplate retryTemplate){
		this(PartnerCenter.PROVIDER_ID, new PartnerCenterServiceProvider(applicationId, applicationSecret, tenant, apiVersion, interceptors, retryTemplate), new PartnerCenterApiAdapter());
	}

	public PartnerCenterConnectionFactory(String applicationId, String applicationSecret, String tenant, Collection interceptors){
		this(PartnerCenter.PROVIDER_ID, new PartnerCenterServiceProvider(applicationId, applicationSecret, tenant, interceptors), new PartnerCenterApiAdapter());
	}

	public PartnerCenterConnectionFactory(String applicationId, String applicationSecret, String tenant, Collection interceptors, RetryTemplate retryTemplate){
		this(PartnerCenter.PROVIDER_ID, new PartnerCenterServiceProvider(applicationId, applicationSecret, tenant, interceptors, retryTemplate), new PartnerCenterApiAdapter());
	}

	private PartnerCenterConnectionFactory(String providerId, PartnerCenterServiceProvider serviceProvider, ApiAdapter apiAdapter) {
		super(providerId, serviceProvider, apiAdapter);
	}

	public PartnerCenterConnection createConnection(){
		AccessGrant accessGrant = getPartnerCenterOAuth2Operations().exchangeForAccess();
		return (PartnerCenterConnection) createConnection(accessGrant);
	}

	@Override
	public Connection createConnection(AccessGrant accessGrant) {
		return super.createConnection(accessGrant);
	}

	@Override
	public Connection createConnection(ConnectionData data) {
		return super.createConnection(data);
	}

	private PartnerCenterAuthorizationTemplate getPartnerCenterOAuth2Operations() {
		return (PartnerCenterAuthorizationTemplate) getOAuthOperations();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy