use of org.datatransferproject.types.transfer.auth.AppCredentials in project data-transfer-project by google.
the class AzureKeyVaultStore method getAppCredentials.
@Override
public AppCredentials getAppCredentials(String keyName, String secretName) throws IOException {
String normalizedKey = normalize(keyName);
SecretBundle keyBundle = vaultClient.getSecret(vaultUrl, normalizedKey);
if (keyBundle == null) {
throw new IOException(("Key not found: " + secretName));
}
String keyValue = keyBundle.value();
String normalizedSecret = normalize(secretName);
SecretBundle secretBundle = vaultClient.getSecret(vaultUrl, normalizedSecret);
if (secretBundle == null) {
throw new IOException(("Key not found: " + secretName));
}
String secretValue = secretBundle.value();
return new AppCredentials(keyValue, secretValue);
}
use of org.datatransferproject.types.transfer.auth.AppCredentials in project data-transfer-project by google.
the class TwitterTransferExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
Monitor monitor = context.getMonitor();
monitor.debug(() -> "Starting Twitter initialization");
if (initialized) {
monitor.severe(() -> "TwitterTransferExtension already initialized.");
return;
}
AppCredentials appCredentials;
try {
appCredentials = context.getService(AppCredentialStore.class).getAppCredentials(TWITTER_KEY, TWITTER_SECRET);
} catch (IOException e) {
monitor.info(() -> format("Unable to retrieve Twitter AppCredentials. Did you set %s and %s?", TWITTER_KEY, TWITTER_SECRET), e);
return;
}
exporter = new TwitterPhotosExporter(appCredentials, monitor);
importer = new TwitterPhotosImporter(appCredentials, monitor);
initialized = true;
}
use of org.datatransferproject.types.transfer.auth.AppCredentials in project data-transfer-project by google.
the class GoogleAppCredentialStore method getAppCredentials.
public AppCredentials getAppCredentials(String keyName, String secretName) throws IOException {
String key;
String secret;
try {
key = keys.get(keyName);
} catch (ExecutionException e) {
throw new IOException("Couldn't lookup key: " + keyName, e);
}
try {
secret = secrets.get(secretName);
} catch (ExecutionException e) {
throw new IOException("Couldn't lookup secret: " + secretName, e);
}
return new AppCredentials(key, secret);
}
use of org.datatransferproject.types.transfer.auth.AppCredentials in project data-transfer-project by google.
the class SmugMugTransferExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
Monitor monitor = context.getMonitor();
if (initialized) {
monitor.severe(() -> "SmugMugTransferExtension already initailized.");
return;
}
TemporaryPerJobDataStore jobStore = context.getService(TemporaryPerJobDataStore.class);
AppCredentials appCredentials;
try {
appCredentials = context.getService(AppCredentialStore.class).getAppCredentials(SMUGMUG_KEY, SMUGMUG_SECRET);
} catch (IOException e) {
monitor.info(() -> format("Unable to retrieve SmugMug AppCredentials. Did you set %s and %s?", SMUGMUG_KEY, SMUGMUG_SECRET), e);
return;
}
ObjectMapper mapper = context.getService(TypeManager.class).getMapper();
exporter = new SmugMugPhotosExporter(appCredentials, mapper, jobStore, monitor);
importer = new SmugMugPhotosImporter(jobStore, appCredentials, mapper, monitor);
initialized = true;
}
use of org.datatransferproject.types.transfer.auth.AppCredentials in project data-transfer-project by google.
the class BloggerTransferExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
// times.
if (initialized) {
return;
}
Monitor monitor = context.getMonitor();
AppCredentials appCredentials;
try {
appCredentials = context.getService(AppCredentialStore.class).getAppCredentials("GOOGLEBLOGGER_KEY", "GOOGLEBLOGGER_SECRET");
} catch (IOException e) {
monitor.info(() -> "Unable to retrieve Google AppCredentials. " + "Did you set GOOGLEBLOGGER_KEY and GOOGLEBLOGGER_SECRET?");
return;
}
HttpTransport httpTransport = context.getService(HttpTransport.class);
JsonFactory jsonFactory = context.getService(JsonFactory.class);
// Create the GoogleCredentialFactory with the given {@link AppCredentials}.
GoogleCredentialFactory credentialFactory = new GoogleCredentialFactory(httpTransport, jsonFactory, appCredentials, monitor);
ImmutableMap.Builder<String, Importer> importerBuilder = ImmutableMap.builder();
importerBuilder.put("SOCIAL-POSTS", new GoogleBloggerImporter(credentialFactory));
importerMap = importerBuilder.build();
ImmutableMap.Builder<String, Exporter> exporterBuilder = ImmutableMap.builder();
exporterMap = exporterBuilder.build();
initialized = true;
}
Aggregations