Java源码示例:org.cloudfoundry.reactor.tokenprovider.PasswordGrantTokenProvider.Builder
示例1
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();
}
示例2
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();
}
示例3
@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();
}
示例4
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();
}