use of com.azure.security.keyvault.secrets.models.SecretProperties in project lowkey-vault by nagyesta.
the class SecretsStepDefs method theLastVersionOfTheSecretIsPreparedForAnUpdate.
@When("the last version of the secret is prepared for an update")
public void theLastVersionOfTheSecretIsPreparedForAnUpdate() {
final KeyVaultSecret lastResult = context.getLastResult();
final SecretProperties updatedProperties = context.getClient(context.getSecretServiceVersion()).getSecret(lastResult.getName(), lastResult.getProperties().getVersion()).getProperties();
context.setUpdateProperties(updatedProperties);
}
use of com.azure.security.keyvault.secrets.models.SecretProperties in project azure-keyvault-plugin by jenkinsci.
the class AzureCredentialsProvider method fetchCredentials.
private static Collection<IdCredentials> fetchCredentials() {
AzureKeyVaultGlobalConfiguration azureKeyVaultGlobalConfiguration = GlobalConfiguration.all().get(AzureKeyVaultGlobalConfiguration.class);
if (azureKeyVaultGlobalConfiguration == null) {
throw new AzureKeyVaultException("No global key vault url configured.");
}
String credentialID = azureKeyVaultGlobalConfiguration.getCredentialID();
try {
SecretClient client = SecretClientCache.get(credentialID, azureKeyVaultGlobalConfiguration.getKeyVaultURL());
List<IdCredentials> credentials = new ArrayList<>();
for (SecretProperties secretItem : client.listPropertiesOfSecrets()) {
String id = secretItem.getId();
Map<String, String> tags = secretItem.getTags();
if (tags == null) {
tags = new HashMap<>();
}
String type = tags.getOrDefault("type", DEFAULT_TYPE);
// initial implementation didn't require a type
if (tags.containsKey("username") && type.equals(DEFAULT_TYPE)) {
type = "username";
}
switch(type) {
case "string":
{
AzureSecretStringCredentials cred = new AzureSecretStringCredentials(getSecretName(id), "", new KeyVaultSecretRetriever(client, id));
credentials.add(cred);
}
break;
case "username":
{
AzureUsernamePasswordCredentials cred = new AzureUsernamePasswordCredentials(getSecretName(id), tags.get("username"), "", new KeyVaultSecretRetriever(client, id));
credentials.add(cred);
}
break;
default:
{
throw new IllegalStateException("Unknown type: " + type);
}
}
}
return credentials;
} catch (Exception e) {
LOG.log(Level.WARNING, "Error retrieving secrets from Azure KeyVault: " + e.getMessage(), e);
return Collections.emptyList();
}
}
use of com.azure.security.keyvault.secrets.models.SecretProperties in project lowkey-vault by nagyesta.
the class SecretsStepDefs method theUpdateRequestIsSent.
@When("the secret update request is sent")
public void theUpdateRequestIsSent() {
final SecretProperties properties = context.getClient(context.getSecretServiceVersion()).updateSecretProperties(context.getUpdateProperties());
fetchLatestSecretVersion(properties.getName());
}
Aggregations