• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java FixedCredentialsProvider类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.google.api.gax.core.FixedCredentialsProvider的典型用法代码示例。如果您正苦于以下问题:Java FixedCredentialsProvider类的具体用法?Java FixedCredentialsProvider怎么用?Java FixedCredentialsProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

FixedCredentialsProvider类属于com.google.api.gax.core包,在下文中一共展示了FixedCredentialsProvider类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: GcpPubSubAutoConfiguration

点赞 3

import com.google.api.gax.core.FixedCredentialsProvider; //导入依赖的package包/类
public GcpPubSubAutoConfiguration(GcpPubSubProperties gcpPubSubProperties,
		GcpProjectIdProvider gcpProjectIdProvider,
		CredentialsProvider credentialsProvider) throws IOException {
	this.gcpPubSubProperties = gcpPubSubProperties;
	this.finalProjectIdProvider = gcpPubSubProperties.getProjectId() != null
			? gcpPubSubProperties::getProjectId
			: gcpProjectIdProvider;
	this.finalCredentialsProvider = gcpPubSubProperties.getCredentials().getLocation() != null
			? FixedCredentialsProvider.create(
					GoogleCredentials.fromStream(
							gcpPubSubProperties.getCredentials().getLocation().getInputStream())
							.createScoped(gcpPubSubProperties.getCredentials().getScopes()))
			: credentialsProvider;
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-gcp,
代码行数:15,
代码来源:GcpPubSubAutoConfiguration.java

示例2: StackdriverTraceAutoConfiguration

点赞 2

import com.google.api.gax.core.FixedCredentialsProvider; //导入依赖的package包/类
public StackdriverTraceAutoConfiguration(GcpProjectIdProvider gcpProjectIdProvider,
		CredentialsProvider credentialsProvider,
		GcpTraceProperties gcpTraceProperties) throws IOException {
	this.finalProjectIdProvider = gcpTraceProperties.getProjectId() != null
			? gcpTraceProperties::getProjectId
			: gcpProjectIdProvider;
	this.finalCredentialsProvider = gcpTraceProperties.getCredentials().getLocation() != null
			? FixedCredentialsProvider.create(GoogleCredentials.fromStream(
					gcpTraceProperties.getCredentials().getLocation().getInputStream())
			.createScoped(gcpTraceProperties.getCredentials().getScopes()))
			: credentialsProvider;
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-gcp,
代码行数:13,
代码来源:StackdriverTraceAutoConfiguration.java

示例3: createInternal

点赞 2

import com.google.api.gax.core.FixedCredentialsProvider; //导入依赖的package包/类
private static void createInternal(
    @Nullable Credentials credentials,
    @Nullable String projectId,
    @Nullable Duration exportInterval,
    @Nullable MonitoredResource monitoredResource)
    throws IOException {
  projectId = projectId == null ? ServiceOptions.getDefaultProjectId() : projectId;
  exportInterval = exportInterval == null ? DEFAULT_INTERVAL : exportInterval;
  monitoredResource = monitoredResource == null ? DEFAULT_RESOURCE : monitoredResource;
  synchronized (monitor) {
    checkState(exporter == null, "Stackdriver stats exporter is already created.");
    MetricServiceClient metricServiceClient;
    // Initialize MetricServiceClient inside lock to avoid creating multiple clients.
    if (credentials == null) {
      metricServiceClient = MetricServiceClient.create();
    } else {
      metricServiceClient =
          MetricServiceClient.create(
              MetricServiceSettings.newBuilder()
                  .setCredentialsProvider(FixedCredentialsProvider.create(credentials))
                  .build());
    }
    exporter =
        new StackdriverStatsExporter(
            projectId,
            metricServiceClient,
            exportInterval,
            Stats.getViewManager(),
            monitoredResource);
    exporter.workerThread.start();
  }
}
 

开发者ID:census-instrumentation,
项目名称:opencensus-java
代码行数:33,
代码来源:StackdriverStatsExporter.java

示例4: createWithCredentials

点赞 2

import com.google.api.gax.core.FixedCredentialsProvider; //导入依赖的package包/类
static StackdriverV2ExporterHandler createWithCredentials(
    Credentials credentials, String projectId) throws IOException {
  checkNotNull(credentials, "credentials");
  TraceServiceSettings traceServiceSettings =
      TraceServiceSettings.newBuilder()
          .setCredentialsProvider(FixedCredentialsProvider.create(credentials))
          .build();
  return new StackdriverV2ExporterHandler(
      projectId, TraceServiceClient.create(traceServiceSettings));
}
 

开发者ID:census-instrumentation,
项目名称:opencensus-java
代码行数:11,
代码来源:StackdriverV2ExporterHandler.java

示例5: create

点赞 2

import com.google.api.gax.core.FixedCredentialsProvider; //导入依赖的package包/类
/**
 * @deprecated Use {@link #createWithCredentials(Credentials)}.
 * @param apiHost a string containing the API host name.
 * @param credentials a credentials used to authenticate API calls.
 */
@Deprecated
public static GrpcTraceConsumer create(String apiHost, Credentials credentials)
    throws IOException {
  TraceServiceSettings traceServiceSettings =
      TraceServiceSettings.newBuilder()
          .setCredentialsProvider(FixedCredentialsProvider.create(credentials))
          .setTransportChannelProvider(TraceServiceSettings.defaultGrpcTransportProviderBuilder()
              .setEndpoint(apiHost)
              .build())
          .build();

  return new GrpcTraceConsumer(TraceServiceClient.create(traceServiceSettings));
}
 

开发者ID:GoogleCloudPlatform,
项目名称:cloud-trace-java
代码行数:19,
代码来源:GrpcTraceConsumer.java

示例6: createWithCredentials

点赞 2

import com.google.api.gax.core.FixedCredentialsProvider; //导入依赖的package包/类
/**
 * Creates a trace consumer that sends trace messages to the Stackdriver Trace API via gRPC.
 *
 * @param credentials a credentials used to authenticate API calls.
 */
public static GrpcTraceConsumer createWithCredentials(Credentials credentials)
    throws IOException {
  TraceServiceSettings traceServiceSettings =
      TraceServiceSettings.newBuilder()
          .setCredentialsProvider(FixedCredentialsProvider.create(credentials))
          .build();

  return new GrpcTraceConsumer(TraceServiceClient.create(traceServiceSettings));
}
 

开发者ID:GoogleCloudPlatform,
项目名称:cloud-trace-java
代码行数:15,
代码来源:GrpcTraceConsumer.java

示例7: googleCredentials

点赞 2

import com.google.api.gax.core.FixedCredentialsProvider; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public CredentialsProvider googleCredentials() throws Exception {
	CredentialsProvider credentialsProvider;

	Credentials propertyCredentials = this.gcpProperties.getCredentials();

	List<String> scopes = resolveScopes();

	if (!StringUtils.isEmpty(propertyCredentials.getLocation())) {
		credentialsProvider = FixedCredentialsProvider
				.create(GoogleCredentials.fromStream(
						propertyCredentials.getLocation().getInputStream())
				.createScoped(scopes));
	}
	else {
		credentialsProvider = GoogleCredentialsProvider.newBuilder()
				.setScopesToApply(scopes)
				.build();
	}

	try {
		com.google.auth.Credentials credentials = credentialsProvider.getCredentials();

		if (LOGGER.isInfoEnabled()) {
			if (credentials instanceof UserCredentials) {
				LOGGER.info("Default credentials provider for user "
						+ ((UserCredentials) credentials).getClientId());
			}
			else if (credentials instanceof ServiceAccountCredentials) {
				LOGGER.info("Default credentials provider for service account "
						+ ((ServiceAccountCredentials) credentials).getClientEmail());
			}
			else if (credentials instanceof ComputeEngineCredentials) {
				LOGGER.info("Default credentials provider for Google Compute Engine.");
			}
			LOGGER.info("Scopes in use by default credentials: " + scopes.toString());
		}
	}
	catch (IOException ioe) {
		LOGGER.error("No credentials were found.", ioe);
	}

	return credentialsProvider;
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-gcp,
代码行数:46,
代码来源:GcpContextAutoConfiguration.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)