org.springframework.vault.authentication.CubbyholeAuthentication Java Examples

The following examples show how to use org.springframework.vault.authentication.CubbyholeAuthentication. 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: CubbyholeClientAuthenticationProvider.java    From spring-cloud-config with Apache License 2.0 6 votes vote down vote up
@Override
public ClientAuthentication getClientAuthentication(
		VaultEnvironmentProperties vaultProperties,
		RestOperations vaultRestOperations, RestOperations externalRestOperations) {

	String token = vaultProperties.getToken();

	Assert.hasText(token,
			missingPropertyForAuthMethod("token", AuthenticationMethod.CUBBYHOLE));

	CubbyholeAuthenticationOptions options = CubbyholeAuthenticationOptions.builder() //
			.wrapped() //
			.initialToken(VaultToken.of(token)) //
			.build();

	return new CubbyholeAuthentication(options, vaultRestOperations);
}
 
Example #2
Source File: ClientAuthenticationFactory.java    From spring-cloud-vault with Apache License 2.0 5 votes vote down vote up
private ClientAuthentication cubbyholeAuthentication() {

		Assert.hasText(this.vaultProperties.getToken(),
				"Initial Token (spring.cloud.vault.token) for Cubbyhole authentication must not be empty");

		CubbyholeAuthenticationOptions options = CubbyholeAuthenticationOptions.builder() //
				.wrapped() //
				.initialToken(VaultToken.of(this.vaultProperties.getToken())) //
				.build();

		return new CubbyholeAuthentication(options, this.restOperations);
	}
 
Example #3
Source File: SpringVaultClientConfigurationTests.java    From spring-cloud-config with Apache License 2.0 5 votes vote down vote up
@Test
public void cubbyholeAuthentication() {
	properties.setAuthentication(CUBBYHOLE);
	properties.setToken("token");

	assertClientAuthenticationOfType(properties, CubbyholeAuthentication.class);
}
 
Example #4
Source File: EnvironmentVaultConfiguration.java    From spring-vault with Apache License 2.0 3 votes vote down vote up
protected ClientAuthentication cubbyholeAuthentication() {

		String token = getProperty("vault.token");
		Assert.hasText(token, "Vault Cubbyhole authentication: Initial token (vault.token) must not be empty");

		CubbyholeAuthenticationOptionsBuilder builder = CubbyholeAuthenticationOptions.builder().wrapped()
				.initialToken(VaultToken.of(token));

		return new CubbyholeAuthentication(builder.build(), restOperations());
	}
 
Example #5
Source File: EnvironmentVaultConfigurationCubbyholeAuthenticationUnitTests.java    From spring-vault with Apache License 2.0 3 votes vote down vote up
@Test
void shouldConfigureAuthentication() {

	ClientAuthentication clientAuthentication = this.configuration.clientAuthentication();

	assertThat(clientAuthentication).isInstanceOf(CubbyholeAuthentication.class);
}