org.cloudfoundry.reactor.ConnectionContext Java Examples

The following examples show how to use org.cloudfoundry.reactor.ConnectionContext. 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: AbstractCfTask.java    From ya-cf-app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
protected CloudFoundryOperations getCfOperations() {
    CfProperties cfAppProperties = this.cfPropertiesMapper.getProperties();

    ConnectionContext connectionContext = DefaultConnectionContext.builder()
        .apiHost(cfAppProperties.ccHost())
        .skipSslValidation(true)
        .proxyConfiguration(tryGetProxyConfiguration(cfAppProperties))
        .build();

    TokenProvider tokenProvider = getTokenProvider(cfAppProperties);

    CloudFoundryClient cfClient = ReactorCloudFoundryClient.builder()
        .connectionContext(connectionContext)
        .tokenProvider(tokenProvider)
        .build();

    DefaultCloudFoundryOperations cfOperations = DefaultCloudFoundryOperations.builder()
        .cloudFoundryClient(cfClient)
        .organization(cfAppProperties.org())
        .space(cfAppProperties.space())
        .build();

    return cfOperations;
}
 
Example #2
Source File: CloudFoundryTaskPlatformFactory.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Override
public Launcher createLauncher(String account) {
	ConnectionContext connectionContext = connectionContext(account);
	TokenProvider tokenProvider = tokenProvider(account);
	CloudFoundryClient cloudFoundryClient = cloudFoundryClient(account);
	CloudFoundryOperations cloudFoundryOperations = cloudFoundryOperations(cloudFoundryClient, account);
	CloudFoundryTaskLauncher taskLauncher = new CloudFoundryTaskLauncher(
			cloudFoundryClient,
			deploymentProperties(account),
			cloudFoundryOperations,
			runtimeEnvironmentInfo(cloudFoundryClient, account));
	Launcher launcher = new Launcher(account, CLOUDFOUNDRY_PLATFORM_TYPE, taskLauncher,
			scheduler(account, taskLauncher, cloudFoundryOperations));
	CloudFoundryConnectionProperties connectionProperties = connectionProperties(account);
	launcher.setDescription(String.format("org = [%s], space = [%s], url = [%s]",
			connectionProperties.getOrg(), connectionProperties.getSpace(),
			connectionProperties.getUrl()));
	return launcher;
}
 
Example #3
Source File: CloudFoundryTestSupport.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
@Bean
public CloudFoundryOperations cloudFoundryOperations(CloudFoundryClient cloudFoundryClient,
													 ConnectionContext connectionContext,
													 TokenProvider tokenProvider,
													 CloudFoundryConnectionProperties properties) {
	ReactorDopplerClient.builder()
		.connectionContext(connectionContext)
		.tokenProvider(tokenProvider)
		.build();

	ReactorUaaClient.builder()
		.connectionContext(connectionContext)
		.tokenProvider(tokenProvider)
		.build();

	return DefaultCloudFoundryOperations.builder()
		.cloudFoundryClient(cloudFoundryClient)
		.organization(properties.getOrg())
		.space(properties.getSpace())
		.build();
}
 
Example #4
Source File: CloudFoundryTestSupport.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
public CloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext,
											 TokenProvider tokenProvider) {
	return ReactorCloudFoundryClient.builder()
			.connectionContext(connectionContext)
			.tokenProvider(tokenProvider)
			.build();
}
 
Example #5
Source File: CloudControllerRestClientFactory.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private OAuthClient createOAuthClient(URL controllerUrl, String origin) {
    Map<String, Object> infoMap = getInfoMap(controllerUrl);
    URL authorizationEndpoint = getAuthorizationEndpoint(infoMap);
    if (StringUtils.isEmpty(origin)) {
        return restUtil.createOAuthClient(authorizationEndpoint, getHttpProxyConfiguration(), shouldTrustSelfSignedCertificates());
    }
    ConnectionContext connectionContext = getCloudFoundryClientFactory().getOrCreateConnectionContext(controllerUrl.getHost());
    return restUtil.createOAuthClient(authorizationEndpoint, getHttpProxyConfiguration(), shouldTrustSelfSignedCertificates(),
                                      connectionContext, origin);
}
 
Example #6
Source File: RestUtil.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
public OAuthClient createOAuthClient(URL authorizationUrl, HttpProxyConfiguration httpProxyConfiguration, boolean trustSelfSignedCerts,
                                     ConnectionContext connectionContext, String origin) {
    return new OAuthClientWithLoginHint(authorizationUrl,
                                        createRestTemplate(httpProxyConfiguration, trustSelfSignedCerts),
                                        connectionContext,
                                        origin);
}
 
Example #7
Source File: PcfDevIntegrationTests.java    From ya-cf-app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@Test
    public void getAppDetailTests() {
        ConnectionContext connectionContext = DefaultConnectionContext.builder()
            .apiHost("api.local.pcfdev.io")
            .skipSslValidation(true)
            .build();

        TokenProvider tokenProvider = PasswordGrantTokenProvider.builder()
            .password("admin")
            .username("admin")
            .build();

        CloudFoundryClient cfClient = ReactorCloudFoundryClient.builder()
            .connectionContext(connectionContext)
            .tokenProvider(tokenProvider)
            .build();

        CloudFoundryOperations cfOperations = DefaultCloudFoundryOperations.builder()
            .cloudFoundryClient(cfClient)
            .organization("pcfdev-org")
            .space("pcfdev-space")
            .build();

        CfAppDetailsDelegate appDetailsTaskDelegate = new CfAppDetailsDelegate();
        CfProperties cfAppProps = envDetails();
        Mono<Optional<ApplicationDetail>> applicationDetailMono = appDetailsTaskDelegate
            .getAppDetails(cfOperations, cfAppProps);


//		Mono<Void> resp = applicationDetailMono.then(applicationDetail -> Mono.fromSupplier(() -> {
//			return 1;
//		})).then();
//
//		resp.block();
//		ApplicationDetail applicationDetail = applicationDetailMono.block(Duration.ofMillis(5000));
//		System.out.println("applicationDetail = " + applicationDetail);
    }
 
Example #8
Source File: CloudFoundryDeployerAutoConfiguration.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public CloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
	return ReactorCloudFoundryClient.builder()
		.connectionContext(connectionContext)
		.tokenProvider(tokenProvider)
		.build();
}
 
Example #9
Source File: CloudFoundryDeployerAutoConfiguration.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public ConnectionContext connectionContext(CloudFoundryConnectionProperties properties) {
	return DefaultConnectionContext.builder()
		.apiHost(properties.getUrl().getHost())
		.skipSslValidation(properties.isSkipSslValidation())
		.build();
}
 
Example #10
Source File: SpringCloudSchedulerIntegrationTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public ReactorSchedulerClient reactorSchedulerClient(ConnectionContext context,
		TokenProvider passwordGrantTokenProvider,
		CloudFoundrySchedulerProperties properties) {
	return ReactorSchedulerClient.builder()
			.connectionContext(context)
			.tokenProvider(passwordGrantTokenProvider)
			.root(Mono.just(properties.getSchedulerUrl()))
			.build();
}
 
Example #11
Source File: CloudFoundryTestSupport.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
public ConnectionContext connectionContext(CloudFoundryConnectionProperties properties) {
	return DefaultConnectionContext.builder()
			.apiHost(properties.getUrl().getHost())
			.skipSslValidation(properties.isSkipSslValidation())
			.build();
}
 
Example #12
Source File: ButlerConfig.java    From cf-butler with Apache License 2.0 5 votes vote down vote up
@Bean
public ReactorDopplerClient dopplerClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
    return ReactorDopplerClient
            .builder()
                .connectionContext(connectionContext)
                .tokenProvider(tokenProvider)
                .build();
}
 
Example #13
Source File: CloudFoundryPlatformConnectionContextProvider.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
public ConnectionContext connectionContext(String account) {
	CloudFoundryConnectionProperties connectionProperties =
		this.platformProperties.accountProperties(account).getConnection();
	this.connectionContexts.putIfAbsent(account, DefaultConnectionContext.builder()
		.apiHost(connectionProperties.getUrl().getHost())
		.skipSslValidation(connectionProperties.isSkipSslValidation())
		.build());
	return connectionContexts.get(account);
}
 
Example #14
Source File: CloudFoundrySchedulerConfiguration.java    From spring-cloud-dataflow-server-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public ReactorSchedulerClient reactorSchedulerClient(ConnectionContext context,
		TokenProvider passwordGrantTokenProvider,
		CloudFoundrySchedulerProperties properties) {
	return ReactorSchedulerClient.builder()
			.connectionContext(context)
			.tokenProvider(passwordGrantTokenProvider)
			.root(Mono.just(properties.getSchedulerUrl()))
			.build();
}
 
Example #15
Source File: CloudFoundryClientAutoConfiguration.java    From spring-cloud-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@Lazy
@ConditionalOnMissingBean
public ReactorCloudFoundryClient cloudFoundryClient(
		ConnectionContext connectionContext, TokenProvider tokenProvider) {
	return ReactorCloudFoundryClient.builder().connectionContext(connectionContext)
			.tokenProvider(tokenProvider).build();
}
 
Example #16
Source File: CloudFoundryClientAutoConfiguration.java    From spring-cloud-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@Lazy
@ConditionalOnMissingBean
public DopplerClient dopplerClient(ConnectionContext connectionContext,
		TokenProvider tokenProvider) {
	return ReactorDopplerClient.builder().connectionContext(connectionContext)
			.tokenProvider(tokenProvider).build();
}
 
Example #17
Source File: CloudFoundryClientAutoConfiguration.java    From spring-cloud-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@Lazy
@ConditionalOnMissingBean
public RoutingClient routingClient(ConnectionContext connectionContext,
		TokenProvider tokenProvider) {
	return ReactorRoutingClient.builder().connectionContext(connectionContext)
			.tokenProvider(tokenProvider).build();
}
 
Example #18
Source File: CloudFoundryClientAutoConfiguration.java    From spring-cloud-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Bean
@Lazy
@ConditionalOnMissingBean
public ReactorUaaClient uaaClient(ConnectionContext connectionContext,
		TokenProvider tokenProvider) {
	return ReactorUaaClient.builder().connectionContext(connectionContext)
			.tokenProvider(tokenProvider).build();
}
 
Example #19
Source File: CloudFoundryClientConfiguration.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
@Bean
protected ConnectionContext connectionContext(CloudFoundryProperties properties) {
	return DefaultConnectionContext.builder()
		.apiHost(properties.getApiHost())
		.port(Optional.ofNullable(properties.getApiPort()))
		.skipSslValidation(properties.isSkipSslValidation())
		.secure(properties.isSecure())
		.build();
}
 
Example #20
Source File: ButlerConfig.java    From cf-butler with Apache License 2.0 5 votes vote down vote up
@Bean
    public ReactorCloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
        return ReactorCloudFoundryClient
                .builder()
                    .connectionContext(connectionContext)
                    .tokenProvider(tokenProvider)
                    .build();
}
 
Example #21
Source File: ButlerConfig.java    From cf-butler with Apache License 2.0 5 votes vote down vote up
@Bean
public ReactorUaaClient uaaClient(ConnectionContext connectionContext, TokenProvider tokenProvider) {
    return ReactorUaaClient
            .builder()
                .connectionContext(connectionContext)
                .tokenProvider(tokenProvider)
                .build();
}
 
Example #22
Source File: CloudFoundryClientConfiguration.java    From bootiful-testing-online-training with Apache License 2.0 5 votes vote down vote up
@Bean
ReactorCloudFoundryClient cloudFoundryClient(
	ConnectionContext connectionContext,
	TokenProvider tokenProvider) {
	return ReactorCloudFoundryClient
		.builder()
		.connectionContext(connectionContext)
		.tokenProvider(tokenProvider).build();
}
 
Example #23
Source File: CloudFoundryClientConfiguration.java    From bootiful-testing-online-training with Apache License 2.0 5 votes vote down vote up
@Bean
ReactorDopplerClient dopplerClient(ConnectionContext connectionContext,
																																			TokenProvider tokenProvider) {
	return ReactorDopplerClient
		.builder()
		.connectionContext(connectionContext)
		.tokenProvider(tokenProvider)
		.build();
}
 
Example #24
Source File: CloudFoundryClientConfiguration.java    From bootiful-testing-online-training with Apache License 2.0 5 votes vote down vote up
@Bean
ReactorUaaClient uaaClient(ConnectionContext ctx, TokenProvider tokenProvider) {
	return ReactorUaaClient
		.builder()
		.connectionContext(ctx)
		.tokenProvider(tokenProvider)
		.build();
}
 
Example #25
Source File: CloudFoundryAppDeployerAutoConfiguration.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
/**
 * Provide a {@link ReactorCloudFoundryClient} bean
 *
 * @param connectionContext the ConnectionContext bean
 * @param tokenProvider the TokenProvider bean
 * @return the bean
 */
@Bean
public ReactorCloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext,
	@TokenQualifier TokenProvider tokenProvider) {
	return ReactorCloudFoundryClient.builder()
		.connectionContext(connectionContext)
		.tokenProvider(tokenProvider)
		.build();
}
 
Example #26
Source File: CloudFoundryAppDeployerAutoConfiguration.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
/**
 * Provide a {@link ReactorDopplerClient} bean
 *
 * @param connectionContext the ConnectionContext bean
 * @param tokenProvider the TokenProvider bean
 * @return the bean
 */
@Bean
public ReactorDopplerClient dopplerClient(ConnectionContext connectionContext,
	@TokenQualifier TokenProvider tokenProvider) {
	return ReactorDopplerClient.builder()
		.connectionContext(connectionContext)
		.tokenProvider(tokenProvider)
		.build();
}
 
Example #27
Source File: CloudFoundryAppDeployerAutoConfiguration.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
/**
 * Provide a {@link ReactorUaaClient} bean
 *
 * @param connectionContext the ConnectionContext bean
 * @param tokenProvider the TokenProvider bean
 * @return the bean
 */
@UaaClientQualifier
@Bean
public ReactorUaaClient uaaClient(ConnectionContext connectionContext,
	@TokenQualifier TokenProvider tokenProvider) {
	return ReactorUaaClient.builder()
		.connectionContext(connectionContext)
		.tokenProvider(tokenProvider)
		.build();
}
 
Example #28
Source File: CloudFoundryAppDeployerAutoConfigurationTest.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
@Test
void clientIsNotCreatedWithoutConfiguration() {
	this.contextRunner
		.run((context) -> {
			assertThat(context).doesNotHaveBean(CloudFoundryTargetProperties.class);
			assertThat(context).doesNotHaveBean(CloudFoundryDeploymentProperties.class);
			assertThat(context).doesNotHaveBean(ReactorCloudFoundryClient.class);
			assertThat(context).doesNotHaveBean(ReactorDopplerClient.class);
			assertThat(context).doesNotHaveBean(ReactorUaaClient.class);
			assertThat(context).doesNotHaveBean(CloudFoundryOperations.class);
			assertThat(context).doesNotHaveBean(CloudFoundryOperationsUtils.class);
			assertThat(context).doesNotHaveBean(ConnectionContext.class);
			assertThat(context).doesNotHaveBean(TokenProvider.class);
		});
}
 
Example #29
Source File: CloudFoundryClientConfiguration.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
@Bean
protected CloudFoundryClient cloudFoundryClient(ConnectionContext connectionContext,
	@Qualifier("userCredentials") TokenProvider tokenProvider) {
	return ReactorCloudFoundryClient.builder()
		.connectionContext(connectionContext)
		.tokenProvider(tokenProvider)
		.build();
}
 
Example #30
Source File: CloudFoundryClientFactory.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
private ConnectionContext createConnectionContext(String controllerApiHost) {
    DefaultConnectionContext.Builder builder = DefaultConnectionContext.builder()
                                                                       .apiHost(controllerApiHost);
    getSslHandshakeTimeout().ifPresent(builder::sslHandshakeTimeout);
    getConnectTimeout().ifPresent(builder::connectTimeout);
    getConnectionPoolSize().ifPresent(builder::connectionPoolSize);
    getThreadPoolSize().ifPresent(builder::threadPoolSize);
    builder.additionalHttpClientConfiguration(client -> client.metrics(true));
    return builder.build();
}