Search in sources :

Example 1 with AppCredentialStore

use of org.dataportabilityproject.spi.cloud.storage.AppCredentialStore in project data-transfer-project by google.

the class MicrosoftAuthServiceExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    mapper = context.getTypeManager().getMapper();
    OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
    okHttpClient = clientBuilder.build();
    AppCredentialStore appCredentialStore = context.getService(AppCredentialStore.class);
    try {
        AppCredentials credentials = appCredentialStore.getAppCredentials("MICROSOFT_KEY", "MICROSOFT_SECRET");
        if (credentials == null) {
            throw new IllegalStateException("Microsoft Graph API credentials not found");
        }
    } catch (IOException e) {
        throw new IllegalStateException("Error retrieving Microsoft Graph API credentials - Were they set?", e);
    }
    importAuthDataGenerators = new HashMap<>();
    exportAuthDataGenerators = new HashMap<>();
    initialized = true;
}
Also used : OkHttpClient(okhttp3.OkHttpClient) AppCredentialStore(org.dataportabilityproject.spi.cloud.storage.AppCredentialStore) AppCredentials(org.dataportabilityproject.types.transfer.auth.AppCredentials) IOException(java.io.IOException)

Example 2 with AppCredentialStore

use of org.dataportabilityproject.spi.cloud.storage.AppCredentialStore in project data-transfer-project by google.

the class FlickrAuthServiceExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    AppCredentialStore appCredentialStore = context.getService(AppCredentialStore.class);
    try {
        flickrAuthDataGenerator = new FlickrAuthDataGenerator(appCredentialStore.getAppCredentials(FLICKR_KEY, FLICKR_SECRET));
        initialized = true;
    } catch (IOException e) {
        logger.debug("Error retrieving Flickr Credentials. Did you set {} and {}?", FLICKR_KEY, FLICKR_SECRET);
    }
}
Also used : AppCredentialStore(org.dataportabilityproject.spi.cloud.storage.AppCredentialStore) IOException(java.io.IOException)

Example 3 with AppCredentialStore

use of org.dataportabilityproject.spi.cloud.storage.AppCredentialStore in project data-transfer-project by google.

the class WorkerMain method initialize.

public void initialize() {
    SettingsExtension settingsExtension = getSettingsExtension();
    settingsExtension.initialize(null);
    WorkerExtensionContext extensionContext = new WorkerExtensionContext(settingsExtension);
    // TODO this should be moved into a service extension
    extensionContext.registerService(HttpTransport.class, new NetHttpTransport());
    ServiceLoader.load(ServiceExtension.class).iterator().forEachRemaining(serviceExtension -> serviceExtension.initialize(extensionContext));
    // TODO: verify that this is the cloud extension that is specified in the configuration
    CloudExtension cloudExtension = getCloudExtension();
    cloudExtension.initialize(extensionContext);
    logger.info("Using CloudExtension: {} ", cloudExtension.getClass().getName());
    JobStore jobStore = cloudExtension.getJobStore();
    extensionContext.registerService(JobStore.class, jobStore);
    AppCredentialStore appCredentialStore = cloudExtension.getAppCredentialStore();
    extensionContext.registerService(AppCredentialStore.class, appCredentialStore);
    List<TransferExtension> transferExtensions = getTransferExtensions();
    // TODO: make configurable
    SymmetricKeyGenerator symmetricKeyGenerator = new AesSymmetricKeyGenerator();
    AsymmetricKeyGenerator asymmetricKeyGenerator = new RsaSymmetricKeyGenerator();
    Injector injector = Guice.createInjector(new WorkerModule(extensionContext, cloudExtension, transferExtensions, symmetricKeyGenerator, asymmetricKeyGenerator));
    worker = injector.getInstance(Worker.class);
}
Also used : AppCredentialStore(org.dataportabilityproject.spi.cloud.storage.AppCredentialStore) JobStore(org.dataportabilityproject.spi.cloud.storage.JobStore) SettingsExtension(org.dataportabilityproject.config.extension.SettingsExtension) CloudExtension(org.dataportabilityproject.spi.cloud.extension.CloudExtension) NetHttpTransport(com.google.api.client.http.javanet.NetHttpTransport) SymmetricKeyGenerator(org.dataportabilityproject.security.SymmetricKeyGenerator) RsaSymmetricKeyGenerator(org.dataportabilityproject.security.RsaSymmetricKeyGenerator) AesSymmetricKeyGenerator(org.dataportabilityproject.security.AesSymmetricKeyGenerator) Injector(com.google.inject.Injector) TransferExtension(org.dataportabilityproject.spi.transfer.extension.TransferExtension) AsymmetricKeyGenerator(org.dataportabilityproject.security.AsymmetricKeyGenerator) AesSymmetricKeyGenerator(org.dataportabilityproject.security.AesSymmetricKeyGenerator) RsaSymmetricKeyGenerator(org.dataportabilityproject.security.RsaSymmetricKeyGenerator)

Aggregations

AppCredentialStore (org.dataportabilityproject.spi.cloud.storage.AppCredentialStore)3 IOException (java.io.IOException)2 NetHttpTransport (com.google.api.client.http.javanet.NetHttpTransport)1 Injector (com.google.inject.Injector)1 OkHttpClient (okhttp3.OkHttpClient)1 SettingsExtension (org.dataportabilityproject.config.extension.SettingsExtension)1 AesSymmetricKeyGenerator (org.dataportabilityproject.security.AesSymmetricKeyGenerator)1 AsymmetricKeyGenerator (org.dataportabilityproject.security.AsymmetricKeyGenerator)1 RsaSymmetricKeyGenerator (org.dataportabilityproject.security.RsaSymmetricKeyGenerator)1 SymmetricKeyGenerator (org.dataportabilityproject.security.SymmetricKeyGenerator)1 CloudExtension (org.dataportabilityproject.spi.cloud.extension.CloudExtension)1 JobStore (org.dataportabilityproject.spi.cloud.storage.JobStore)1 TransferExtension (org.dataportabilityproject.spi.transfer.extension.TransferExtension)1 AppCredentials (org.dataportabilityproject.types.transfer.auth.AppCredentials)1