All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.version1.secretsmanagement.SecretsManagement Maven / Gradle / Ivy

Go to download

A simple Selenium framework offering externalised configuration, a good selection of libraries for supporting test data, simple WebDriver browser binary resolution and an opinionated approach for WebDriver test design.

There is a newer version: 2.0.1
Show newest version
package com.version1.secretsmanagement;

import com.azure.core.util.polling.SyncPoller;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.security.keyvault.secrets.SecretClient;
import com.azure.security.keyvault.secrets.SecretClientBuilder;
import com.azure.security.keyvault.secrets.models.DeletedSecret;
import com.azure.security.keyvault.secrets.models.KeyVaultSecret;

public class SecretsManagement {
	public static SecretClient secretBuilder(String keyVaultName) throws InterruptedException, IllegalArgumentException {
	   String keyVaultUri = "https://" + keyVaultName + ".vault.azure.net";
       SecretClient secretClient = new SecretClientBuilder()
           .vaultUrl(keyVaultUri)
           .credential(new DefaultAzureCredentialBuilder().build())
           .buildClient();
       return secretClient;
	}
	
	public static void setSecret(String keyVaultName,String secretName,String secretValue) throws InterruptedException, IllegalArgumentException {
	   secretBuilder(keyVaultName).setSecret(new KeyVaultSecret(secretName, secretValue));
	    }
	
	public static String getSecret(String keyVaultName,String secretName) throws InterruptedException, IllegalArgumentException {
       KeyVaultSecret retrievedSecret = secretBuilder(keyVaultName).getSecret(secretName);
	   return retrievedSecret.getValue();
    }
	
	public static void deleteSecret(String keyVaultName,String secretName) throws InterruptedException, IllegalArgumentException {
       SyncPoller deletionPoller = secretBuilder(keyVaultName).beginDeleteSecret(secretName);
       deletionPoller.waitForCompletion();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy