org.springframework.vault.authentication.ClientCertificateAuthentication Java Examples

The following examples show how to use org.springframework.vault.authentication.ClientCertificateAuthentication. 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: EnvironmentVaultConfiguration.java    From spring-vault with Apache License 2.0 5 votes vote down vote up
@Override
public ClientAuthentication clientAuthentication() {

	String authentication = getProperty("vault.authentication", AuthenticationMethod.TOKEN.name()).toUpperCase()
			.replace('-', '_');

	AuthenticationMethod authenticationMethod = AuthenticationMethod.valueOf(authentication);

	switch (authenticationMethod) {

	case TOKEN:
		return tokenAuthentication();
	case APPID:
		return appIdAuthentication();
	case APPROLE:
		return appRoleAuthentication();
	case AWS_EC2:
		return awsEc2Authentication();
	case AZURE:
		return azureMsiAuthentication();
	case CERT:
		return new ClientCertificateAuthentication(restOperations());
	case CUBBYHOLE:
		return cubbyholeAuthentication();
	case KUBERNETES:
		return kubeAuthentication();
	default:
		throw new IllegalStateException(String.format("Vault authentication method %s is not supported with %s",
				authenticationMethod, getClass().getSimpleName()));
	}
}
 
Example #2
Source File: CertificateClientAuthenticationProvider.java    From spring-cloud-config with Apache License 2.0 5 votes vote down vote up
@Override
public ClientAuthentication getClientAuthentication(
		VaultEnvironmentProperties vaultProperties,
		RestOperations vaultRestOperations, RestOperations externalRestOperations) {

	return new ClientCertificateAuthentication(vaultRestOperations);
}
 
Example #3
Source File: SpringVaultClientConfigurationTests.java    From spring-cloud-config with Apache License 2.0 5 votes vote down vote up
@Test
public void clientCertificateAuthentication() {
	properties.setAuthentication(CERT);

	assertClientAuthenticationOfType(properties,
			ClientCertificateAuthentication.class);
}
 
Example #4
Source File: ClientAuthenticationFactory.java    From spring-cloud-vault with Apache License 2.0 4 votes vote down vote up
/**
 * @return a new {@link ClientAuthentication}.
 */
ClientAuthentication createClientAuthentication() {

	switch (this.vaultProperties.getAuthentication()) {

	case APPID:
		return appIdAuthentication(this.vaultProperties);

	case APPROLE:
		return appRoleAuthentication(this.vaultProperties);

	case AWS_EC2:
		return awsEc2Authentication(this.vaultProperties);

	case AWS_IAM:
		return awsIamAuthentication(this.vaultProperties);

	case AZURE_MSI:
		return azureMsiAuthentication(this.vaultProperties);

	case CERT:
		return new ClientCertificateAuthentication(this.restOperations);

	case CUBBYHOLE:
		return cubbyholeAuthentication();

	case GCP_GCE:
		return gcpGceAuthentication(this.vaultProperties);

	case GCP_IAM:
		return gcpIamAuthentication(this.vaultProperties);

	case KUBERNETES:
		return kubernetesAuthentication(this.vaultProperties);

	case PCF:
		return pcfAuthentication(this.vaultProperties);

	case TOKEN:
		Assert.hasText(this.vaultProperties.getToken(),
				"Token (spring.cloud.vault.token) must not be empty");
		return new TokenAuthentication(this.vaultProperties.getToken());
	}

	throw new UnsupportedOperationException(
			String.format("Client authentication %s not supported",
					this.vaultProperties.getAuthentication()));
}
 
Example #5
Source File: EnvironmentVaultConfigurationClientCertAuthenticationUnitTests.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(ClientCertificateAuthentication.class);
}