org.cloudfoundry.reactor.tokenprovider.PasswordGrantTokenProvider.Builder Java Examples

The following examples show how to use org.cloudfoundry.reactor.tokenprovider.PasswordGrantTokenProvider.Builder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloudFoundryDeployerAutoConfiguration.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
private RuntimeEnvironmentInfo runtimeEnvironmentInfo(Class spiClass, Class implementationClass) {
	CloudFoundryClient client = connectionConfiguration.cloudFoundryClient(
		connectionConfiguration.connectionContext(connectionConfiguration.cloudFoundryConnectionProperties()),
		connectionConfiguration.tokenProvider(connectionConfiguration.cloudFoundryConnectionProperties()));
	Version version = connectionConfiguration.version(client);

	return new CloudFoundryPlatformSpecificInfo(new RuntimeEnvironmentInfo.Builder())
		.apiEndpoint(connectionConfiguration.cloudFoundryConnectionProperties().getUrl().toString())
		.org(connectionConfiguration.cloudFoundryConnectionProperties().getOrg())
		.space(connectionConfiguration.cloudFoundryConnectionProperties().getSpace())
		.builder()
			.implementationName(implementationClass.getSimpleName())
			.spiClass(spiClass)
			.implementationVersion(RuntimeVersionUtils.getVersion(CloudFoundryAppDeployer.class))
			.platformType("Cloud Foundry")
			.platformClientVersion(RuntimeVersionUtils.getVersion(client.getClass()))
			.platformApiVersion(version.toString())
			.platformHostVersion("unknown")
			.build();
}
 
Example #2
Source File: PlatformCloudFoundryOperations.java    From spring-cloud-skipper with Apache License 2.0 5 votes vote down vote up
private CloudFoundryOperations buildCloudFoundryOperations(String platformName) {
	CloudFoundryPlatformProperties.CloudFoundryProperties cloudFoundryProperties = this.cloudFoundryPlatformProperties
			.getAccounts()
			.get(platformName);
	CloudFoundryConnectionProperties connectionProperties = cloudFoundryProperties.getConnection();
	ConnectionContext connectionContext = DefaultConnectionContext.builder()
			.apiHost(connectionProperties.getUrl().getHost())
			.skipSslValidation(connectionProperties.isSkipSslValidation())
			.build();
	Builder tokenProviderBuilder = PasswordGrantTokenProvider.builder()
			.username(connectionProperties.getUsername())
			.password(connectionProperties.getPassword())
			.loginHint(connectionProperties.getLoginHint());
	if (StringUtils.hasText(connectionProperties.getClientId())) {
		tokenProviderBuilder.clientId(connectionProperties.getClientId());
	}
	if (StringUtils.hasText(connectionProperties.getClientSecret())) {
		tokenProviderBuilder.clientSecret(connectionProperties.getClientSecret());
	}
	TokenProvider tokenProvider = tokenProviderBuilder.build();
	CloudFoundryClient cloudFoundryClient = ReactorCloudFoundryClient.builder()
			.connectionContext(connectionContext)
			.tokenProvider(tokenProvider)
			.build();
	return DefaultCloudFoundryOperations
			.builder().cloudFoundryClient(cloudFoundryClient)
			.organization(connectionProperties.getOrg())
			.space(connectionProperties.getSpace()).build();
}
 
Example #3
Source File: CloudFoundryDeployerAutoConfiguration.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public TokenProvider tokenProvider(CloudFoundryConnectionProperties properties) {
	Builder tokenProviderBuilder = PasswordGrantTokenProvider.builder()
			.username(properties.getUsername())
			.password(properties.getPassword())
			.loginHint(properties.getLoginHint());
	if (StringUtils.hasText(properties.getClientId())) {
		tokenProviderBuilder.clientId(properties.getClientId());
	}
	if (StringUtils.hasText(properties.getClientSecret())) {
		tokenProviderBuilder.clientSecret(properties.getClientSecret());
	}
	return tokenProviderBuilder.build();
}
 
Example #4
Source File: CloudFoundryPlatformTokenProvider.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
public TokenProvider tokenProvider(String account) {
	CloudFoundryConnectionProperties connectionProperties = platformProperties.accountProperties(account)
			.getConnection();
	Builder tokenProviderBuilder = PasswordGrantTokenProvider.builder()
			.username(connectionProperties.getUsername())
			.password(connectionProperties.getPassword())
			.loginHint(connectionProperties.getLoginHint());
	if (StringUtils.hasText(connectionProperties.getClientId())) {
		tokenProviderBuilder.clientId(connectionProperties.getClientId());
	}
	if (StringUtils.hasText(connectionProperties.getClientSecret())) {
		tokenProviderBuilder.clientSecret(connectionProperties.getClientSecret());
	}
	return tokenProviderBuilder.build();
}