/// <exception cref="System.Exception"/> public KeyProvider.KeyVersion Run() { KeyProvider.Options opt = TestKeyAuthorizationKeyProvider.NewOptions(conf); IDictionary <string, string> m = new Dictionary <string, string>(); m["key.acl.name"] = "testKey"; opt.SetAttributes(m); try { KeyProvider.KeyVersion kv = kpExt.CreateKey("foo", SecureRandom.GetSeed(16), opt); kpExt.RollNewVersion(kv.GetName()); kpExt.RollNewVersion(kv.GetName(), SecureRandom.GetSeed(16)); kpExt.DeleteKey(kv.GetName()); } catch (IOException) { NUnit.Framework.Assert.Fail("User should be Authorized !!"); } KeyProvider.KeyVersion retkv = null; try { retkv = kpExt.CreateKey("bar", SecureRandom.GetSeed(16), opt); kpExt.GenerateEncryptedKey(retkv.GetName()); NUnit.Framework.Assert.Fail("User should NOT be Authorized to generate EEK !!"); } catch (IOException) { } NUnit.Framework.Assert.IsNotNull(retkv); return(retkv); }
/// <exception cref="System.Exception"/> public Void Run() { try { kpExt.CreateKey("foo", SecureRandom.GetSeed(16), TestKeyAuthorizationKeyProvider. NewOptions(conf)); NUnit.Framework.Assert.Fail("User should NOT be Authorized !!"); } catch (IOException) { } // Ignore return(null); }
/// <exception cref="System.Exception"/> public Void Run() { KeyProvider.Options opt = TestKeyAuthorizationKeyProvider.NewOptions(conf); IDictionary <string, string> m = new Dictionary <string, string>(); m["key.acl.name"] = "testKey"; opt.SetAttributes(m); KeyProvider.KeyVersion kv = kpExt.CreateKey("foo", SecureRandom.GetSeed(16), opt); kpExt.RollNewVersion(kv.GetName()); kpExt.RollNewVersion(kv.GetName(), SecureRandom.GetSeed(16)); KeyProviderCryptoExtension.EncryptedKeyVersion ekv = kpExt.GenerateEncryptedKey(kv .GetName()); ekv = KeyProviderCryptoExtension.EncryptedKeyVersion.CreateForDecryption(ekv.GetEncryptionKeyName () + "x", ekv.GetEncryptionKeyVersionName(), ekv.GetEncryptedKeyIv(), ekv.GetEncryptedKeyVersion ().GetMaterial()); kpExt.DecryptEncryptedKey(ekv); return(null); }
/// <exception cref="System.Exception"/> public Void Run() { KeyProvider.Options opt = TestKeyAuthorizationKeyProvider.NewOptions(conf); IDictionary <string, string> m = new Dictionary <string, string>(); m["key.acl.name"] = "testKey"; opt.SetAttributes(m); try { KeyProvider.KeyVersion kv = kpExt.CreateKey("foo", SecureRandom.GetSeed(16), opt); kpExt.RollNewVersion(kv.GetName()); kpExt.RollNewVersion(kv.GetName(), SecureRandom.GetSeed(16)); KeyProviderCryptoExtension.EncryptedKeyVersion ekv = kpExt.GenerateEncryptedKey(kv .GetName()); kpExt.DecryptEncryptedKey(ekv); kpExt.DeleteKey(kv.GetName()); } catch (IOException) { NUnit.Framework.Assert.Fail("User should be Allowed to do everything !!"); } return(null); }