org.springframework.vault.config.ClientHttpRequestFactoryFactory Java Examples

The following examples show how to use org.springframework.vault.config.ClientHttpRequestFactoryFactory. 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: ClientCertificateAuthenticationStepsIntegrationTests.java    From spring-vault with Apache License 2.0 5 votes vote down vote up
@Test
void authenticationStepsLoginShouldFail() {

	ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory.create(new ClientOptions(),
			Settings.createSslConfiguration());
	RestTemplate restTemplate = VaultClients.createRestTemplate(TestRestTemplateFactory.TEST_VAULT_ENDPOINT,
			clientHttpRequestFactory);

	assertThatExceptionOfType(NestedRuntimeException.class).isThrownBy(
			() -> new AuthenticationStepsExecutor(ClientCertificateAuthentication.createAuthenticationSteps(),
					restTemplate).login());
}
 
Example #2
Source File: TestRestTemplateFactory.java    From spring-cloud-vault with Apache License 2.0 5 votes vote down vote up
private static void initializeClientHttpRequestFactory(
		SslConfiguration sslConfiguration) throws Exception {

	if (factoryCache.get() != null) {
		return;
	}

	final ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory
			.create(new ClientOptions(), sslConfiguration);

	if (factoryCache.compareAndSet(null, clientHttpRequestFactory)) {

		if (clientHttpRequestFactory instanceof InitializingBean) {
			((InitializingBean) clientHttpRequestFactory).afterPropertiesSet();
		}

		if (clientHttpRequestFactory instanceof DisposableBean) {

			Runtime.getRuntime().addShutdownHook(
					new Thread("ClientHttpRequestFactory Shutdown Hook") {

						@Override
						public void run() {
							try {
								((DisposableBean) clientHttpRequestFactory).destroy();
							}
							catch (Exception e) {
								e.printStackTrace();
							}
						}
					});
		}
	}
}
 
Example #3
Source File: HashicorpKeyVaultServiceFactoryUtil.java    From tessera with Apache License 2.0 4 votes vote down vote up
ClientHttpRequestFactory createClientHttpRequestFactory(ClientOptions clientOptions, SslConfiguration sslConfiguration) {
    return ClientHttpRequestFactoryFactory.create(clientOptions, sslConfiguration);
}
 
Example #4
Source File: ClientCertificateAuthenticationStepsIntegrationTests.java    From spring-vault with Apache License 2.0 4 votes vote down vote up
@Test
void authenticationStepsShouldLoginSuccessfully() {

	ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory.create(new ClientOptions(),
			prepareCertAuthenticationMethod());

	RestTemplate restTemplate = VaultClients.createRestTemplate(TestRestTemplateFactory.TEST_VAULT_ENDPOINT,
			clientHttpRequestFactory);

	AuthenticationStepsExecutor executor = new AuthenticationStepsExecutor(
			ClientCertificateAuthentication.createAuthenticationSteps(), restTemplate);

	VaultToken login = executor.login();

	assertThat(login.getToken()).isNotEmpty();
}