Java Code Examples for org.springframework.vault.client.VaultClients#createRestTemplate()
The following examples show how to use
org.springframework.vault.client.VaultClients#createRestTemplate() .
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: PcfAuthenticationUnitTests.java From spring-vault with Apache License 2.0 | 6 votes |
@BeforeEach void before() { RestTemplate restTemplate = VaultClients.createRestTemplate(); restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler()); this.mockRest = MockRestServiceServer.createServer(restTemplate); this.restTemplate = restTemplate; }
Example 2
Source File: AppRoleAuthenticationUnitTests.java From spring-vault with Apache License 2.0 | 6 votes |
@BeforeEach void before() { RestTemplate restTemplate = VaultClients.createRestTemplate(); restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler()); this.mockRest = MockRestServiceServer.createServer(restTemplate); this.restTemplate = restTemplate; }
Example 3
Source File: ClientCertificateAuthenticationStepsIntegrationTests.java From spring-vault with Apache License 2.0 | 5 votes |
@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 4
Source File: KubernetesHashicorpVaultClientAuthenticationProvider.java From knox with Apache License 2.0 | 5 votes |
private RestOperations getRestOperations(Map<String, String> properties) throws Exception { String vaultAddress = properties.get(HashicorpVaultAliasService.VAULT_ADDRESS_KEY); VaultEndpoint vaultEndpoint = VaultEndpoint.from(new URI(vaultAddress)); VaultEndpointProvider vaultEndpointProvider = SimpleVaultEndpointProvider.of(vaultEndpoint); ClientOptions clientOptions = new ClientOptions(); SslConfiguration sslConfiguration = SslConfiguration.unconfigured(); ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory.create( clientOptions, sslConfiguration); return VaultClients.createRestTemplate(vaultEndpointProvider, clientHttpRequestFactory); }
Example 5
Source File: KubernetesAuthenticationUnitTests.java From spring-vault with Apache License 2.0 | 5 votes |
@BeforeEach void before() { RestTemplate restTemplate = VaultClients.createRestTemplate(); restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler()); this.mockRest = MockRestServiceServer.createServer(restTemplate); this.restTemplate = restTemplate; }
Example 6
Source File: AppIdAuthenticationUnitTests.java From spring-vault with Apache License 2.0 | 5 votes |
@BeforeEach void before() { RestTemplate restTemplate = VaultClients.createRestTemplate(); restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler()); this.mockRest = MockRestServiceServer.createServer(restTemplate); this.restTemplate = restTemplate; }
Example 7
Source File: AwsEc2AuthenticationUnitTests.java From spring-vault with Apache License 2.0 | 5 votes |
@BeforeEach void before() { RestTemplate restTemplate = VaultClients.createRestTemplate(); restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler()); this.mockRest = MockRestServiceServer.createServer(restTemplate); this.restTemplate = restTemplate; }
Example 8
Source File: ClientCertificateAuthenticationUnitTests.java From spring-vault with Apache License 2.0 | 5 votes |
@BeforeEach void before() { RestTemplate restTemplate = VaultClients.createRestTemplate(); restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler()); this.mockRest = MockRestServiceServer.createServer(restTemplate); this.restTemplate = restTemplate; }
Example 9
Source File: AwsIamAuthenticationUnitTests.java From spring-vault with Apache License 2.0 | 5 votes |
@BeforeEach void before() { RestTemplate restTemplate = VaultClients.createRestTemplate(); restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler()); this.mockRest = MockRestServiceServer.createServer(restTemplate); this.restTemplate = restTemplate; }
Example 10
Source File: AzureMsiAuthenticationUnitTests.java From spring-vault with Apache License 2.0 | 5 votes |
@BeforeEach void before() { RestTemplate restTemplate = VaultClients.createRestTemplate(); restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler()); this.mockRest = MockRestServiceServer.createServer(restTemplate); this.restTemplate = restTemplate; }
Example 11
Source File: AuthenticationStepsExecutorUnitTests.java From spring-vault with Apache License 2.0 | 5 votes |
@BeforeEach void before() { RestTemplate restTemplate = VaultClients.createRestTemplate(); restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler()); this.mockRest = MockRestServiceServer.createServer(restTemplate); this.restTemplate = restTemplate; }
Example 12
Source File: ClientCertificateAuthenticationIntegrationTests.java From spring-vault with Apache License 2.0 | 5 votes |
@Test void loginShouldFail() { ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory.create(new ClientOptions(), Settings.createSslConfiguration()); RestTemplate restTemplate = VaultClients.createRestTemplate(TestRestTemplateFactory.TEST_VAULT_ENDPOINT, clientHttpRequestFactory); assertThatExceptionOfType(NestedRuntimeException.class) .isThrownBy(() -> new ClientCertificateAuthentication(restTemplate).login()); }
Example 13
Source File: ClientCertificateAuthenticationIntegrationTests.java From spring-vault with Apache License 2.0 | 5 votes |
@Test void shouldSelectInvalidKey() { ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory.create(new ClientOptions(), prepareCertAuthenticationMethod(SslConfiguration.KeyConfiguration.of("changeit".toCharArray(), "2"))); RestTemplate restTemplate = VaultClients.createRestTemplate(TestRestTemplateFactory.TEST_VAULT_ENDPOINT, clientHttpRequestFactory); ClientCertificateAuthentication authentication = new ClientCertificateAuthentication(restTemplate); assertThatExceptionOfType(NestedRuntimeException.class).isThrownBy(authentication::login); }
Example 14
Source File: ClientCertificateAuthenticationIntegrationTests.java From spring-vault with Apache License 2.0 | 5 votes |
@Test void shouldSelectKey() { ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory.create(new ClientOptions(), prepareCertAuthenticationMethod(SslConfiguration.KeyConfiguration.of("changeit".toCharArray(), "1"))); RestTemplate restTemplate = VaultClients.createRestTemplate(TestRestTemplateFactory.TEST_VAULT_ENDPOINT, clientHttpRequestFactory); ClientCertificateAuthentication authentication = new ClientCertificateAuthentication(restTemplate); VaultToken login = authentication.login(); assertThat(login.getToken()).isNotEmpty(); }
Example 15
Source File: ClientCertificateAuthenticationIntegrationTests.java From spring-vault with Apache License 2.0 | 5 votes |
@Test void shouldLoginSuccessfully() { ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory.create(new ClientOptions(), prepareCertAuthenticationMethod()); RestTemplate restTemplate = VaultClients.createRestTemplate(TestRestTemplateFactory.TEST_VAULT_ENDPOINT, clientHttpRequestFactory); ClientCertificateAuthentication authentication = new ClientCertificateAuthentication(restTemplate); VaultToken login = authentication.login(); assertThat(login.getToken()).isNotEmpty(); }
Example 16
Source File: ClientCertificateAuthenticationStepsIntegrationTests.java From spring-vault with Apache License 2.0 | 4 votes |
@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(); }
Example 17
Source File: HashicorpKeyVaultServiceFactoryUtil.java From tessera with Apache License 2.0 | 3 votes |
ClientAuthentication configureClientAuthentication(KeyVaultConfig keyVaultConfig, EnvironmentVariableProvider envProvider, ClientHttpRequestFactory clientHttpRequestFactory, VaultEndpoint vaultEndpoint) { final String roleId = envProvider.getEnv(HASHICORP_ROLE_ID); final String secretId = envProvider.getEnv(HASHICORP_SECRET_ID); final String authToken = envProvider.getEnv(HASHICORP_TOKEN); if(roleId != null && secretId != null) { AppRoleAuthenticationOptions appRoleAuthenticationOptions = AppRoleAuthenticationOptions.builder() .path(keyVaultConfig.getProperty("approlePath").get()) .roleId(AppRoleAuthenticationOptions.RoleId.provided(roleId)) .secretId(AppRoleAuthenticationOptions.SecretId.provided(secretId)) .build(); RestOperations restOperations = VaultClients.createRestTemplate(vaultEndpoint, clientHttpRequestFactory); return new AppRoleAuthentication(appRoleAuthenticationOptions, restOperations); } else if (Objects.isNull(roleId) != Objects.isNull(secretId)) { throw new HashicorpCredentialNotSetException("Both " + HASHICORP_ROLE_ID + " and " + HASHICORP_SECRET_ID + " environment variables must be set to use the AppRole authentication method"); } else if (authToken == null){ throw new HashicorpCredentialNotSetException("Both " + HASHICORP_ROLE_ID + " and " + HASHICORP_SECRET_ID + " environment variables must be set to use the AppRole authentication method. Alternatively set " + HASHICORP_TOKEN + " to authenticate using the Token method"); } return new TokenAuthentication(authToken); }
Example 18
Source File: TestRestTemplateFactory.java From spring-vault with Apache License 2.0 | 1 votes |
/** * Create a new {@link RestTemplate} using the {@link ClientHttpRequestFactory}. The * {@link RestTemplate} will throw * {@link org.springframework.web.client.HttpStatusCodeException exceptions} in error * cases and behave in that aspect like the regular * {@link org.springframework.web.client.RestTemplate}. * @param requestFactory must not be {@literal null}. * @return */ private static RestTemplate create(ClientHttpRequestFactory requestFactory) { Assert.notNull(requestFactory, "ClientHttpRequestFactory must not be null!"); return VaultClients.createRestTemplate(TEST_VAULT_ENDPOINT, requestFactory); }
Example 19
Source File: TestRestTemplateFactory.java From spring-cloud-vault with Apache License 2.0 | 1 votes |
/** * Create a new {@link RestTemplate} using the {@link ClientHttpRequestFactory}. The * {@link RestTemplate} will throw * {@link org.springframework.web.client.HttpStatusCodeException exceptions} in error * cases and behave in that aspect like the regular {@link RestTemplate}. * @param requestFactory must not be {@literal null}. * @return */ public static RestTemplate create(ClientHttpRequestFactory requestFactory) { Assert.notNull(requestFactory, "ClientHttpRequestFactory must not be null!"); return VaultClients.createRestTemplate(TEST_VAULT_ENDPOINT, requestFactory); }