Search in sources :

Example 1 with SecurityExtension

use of org.datatransferproject.spi.transfer.security.SecurityExtension in project data-transfer-project by google.

the class WorkerMain method initialize.

public void initialize() {
    Monitor monitor = loadMonitor();
    SettingsExtension settingsExtension = getSettingsExtension();
    settingsExtension.initialize();
    WorkerExtensionContext extensionContext = new WorkerExtensionContext(settingsExtension, monitor);
    // TODO this should be moved into a service extension
    extensionContext.registerService(HttpTransport.class, new NetHttpTransport());
    extensionContext.registerService(OkHttpClient.class, new OkHttpClient.Builder().build());
    extensionContext.registerService(JsonFactory.class, new JacksonFactory());
    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);
    monitor.info(() -> "Using CloudExtension: " + cloudExtension.getClass().getName());
    JobStore jobStore = cloudExtension.getJobStore();
    extensionContext.registerService(JobStore.class, jobStore);
    extensionContext.registerService(TemporaryPerJobDataStore.class, jobStore);
    AppCredentialStore appCredentialStore = cloudExtension.getAppCredentialStore();
    extensionContext.registerService(AppCredentialStore.class, appCredentialStore);
    List<TransferExtension> transferExtensions = getTransferExtensions(monitor);
    // Load security extension and services
    SecurityExtension securityExtension = SecurityExtensionLoader.getSecurityExtension(extensionContext);
    monitor.info(() -> "Using SecurityExtension: " + securityExtension.getClass().getName());
    IdempotentImportExecutor idempotentImportExecutor = IdempotentImportExecutorLoader.load(extensionContext);
    monitor.info(() -> "Using IdempotentImportExecutor: " + idempotentImportExecutor.getClass().getName());
    // TODO: make configurable
    SymmetricKeyGenerator symmetricKeyGenerator = new AesSymmetricKeyGenerator(monitor);
    JobHooks jobHooks = loadJobHooks();
    Injector injector = null;
    try {
        injector = Guice.createInjector(new WorkerModule(extensionContext, cloudExtension, transferExtensions, securityExtension, idempotentImportExecutor, symmetricKeyGenerator, jobHooks));
    } catch (Exception e) {
        monitor.severe(() -> "Unable to initialize Guice in Worker", e);
        throw e;
    }
    worker = injector.getInstance(Worker.class);
    // Reset the JobMetadata in case set previously when running SingleVMMain
    JobMetadata.reset();
}
Also used : AppCredentialStore(org.datatransferproject.spi.cloud.storage.AppCredentialStore) JobHooks(org.datatransferproject.spi.transfer.hooks.JobHooks) JobHooksLoader.loadJobHooks(org.datatransferproject.spi.transfer.hooks.JobHooksLoader.loadJobHooks) JobStore(org.datatransferproject.spi.cloud.storage.JobStore) SecurityExtension(org.datatransferproject.spi.transfer.security.SecurityExtension) JacksonFactory(com.google.api.client.json.jackson2.JacksonFactory) IdempotentImportExecutor(org.datatransferproject.spi.transfer.idempotentexecutor.IdempotentImportExecutor) SettingsExtension(org.datatransferproject.config.extension.SettingsExtension) SettingsExtensionLoader.getSettingsExtension(org.datatransferproject.config.extension.SettingsExtensionLoader.getSettingsExtension) MonitorLoader.loadMonitor(org.datatransferproject.launcher.monitor.MonitorLoader.loadMonitor) Monitor(org.datatransferproject.api.launcher.Monitor) CloudExtension(org.datatransferproject.spi.cloud.extension.CloudExtension) CloudExtensionLoader.getCloudExtension(org.datatransferproject.spi.cloud.extension.CloudExtensionLoader.getCloudExtension) NetHttpTransport(com.google.api.client.http.javanet.NetHttpTransport) SymmetricKeyGenerator(org.datatransferproject.security.SymmetricKeyGenerator) AesSymmetricKeyGenerator(org.datatransferproject.security.AesSymmetricKeyGenerator) Injector(com.google.inject.Injector) TransferExtension(org.datatransferproject.spi.transfer.extension.TransferExtension) AesSymmetricKeyGenerator(org.datatransferproject.security.AesSymmetricKeyGenerator)

Aggregations

NetHttpTransport (com.google.api.client.http.javanet.NetHttpTransport)1 JacksonFactory (com.google.api.client.json.jackson2.JacksonFactory)1 Injector (com.google.inject.Injector)1 Monitor (org.datatransferproject.api.launcher.Monitor)1 SettingsExtension (org.datatransferproject.config.extension.SettingsExtension)1 SettingsExtensionLoader.getSettingsExtension (org.datatransferproject.config.extension.SettingsExtensionLoader.getSettingsExtension)1 MonitorLoader.loadMonitor (org.datatransferproject.launcher.monitor.MonitorLoader.loadMonitor)1 AesSymmetricKeyGenerator (org.datatransferproject.security.AesSymmetricKeyGenerator)1 SymmetricKeyGenerator (org.datatransferproject.security.SymmetricKeyGenerator)1 CloudExtension (org.datatransferproject.spi.cloud.extension.CloudExtension)1 CloudExtensionLoader.getCloudExtension (org.datatransferproject.spi.cloud.extension.CloudExtensionLoader.getCloudExtension)1 AppCredentialStore (org.datatransferproject.spi.cloud.storage.AppCredentialStore)1 JobStore (org.datatransferproject.spi.cloud.storage.JobStore)1 TransferExtension (org.datatransferproject.spi.transfer.extension.TransferExtension)1 JobHooks (org.datatransferproject.spi.transfer.hooks.JobHooks)1 JobHooksLoader.loadJobHooks (org.datatransferproject.spi.transfer.hooks.JobHooksLoader.loadJobHooks)1 IdempotentImportExecutor (org.datatransferproject.spi.transfer.idempotentexecutor.IdempotentImportExecutor)1 SecurityExtension (org.datatransferproject.spi.transfer.security.SecurityExtension)1