public void ShouldWriteKey() { var app = new KeyRepositoryApp(new ServiceAuthorizationManager()); try { app.Start(); var proxy = new KeyRepositoryClient(); const string institution = "ShouldWriteKeyInstitution"; const string group = "ShouldWriteKeyGroup"; const string product = "KeyManager"; var keyName = String.Format("{0}__{1}__{2}", institution, group, product); var keyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Physion", "Ovation", "keys", keyName); if(File.Exists(keyPath)) File.Delete(keyPath); proxy.WriteKey(institution, group, product, "some key"); Assert.True(File.Exists(keyPath)); if (File.Exists(keyPath)) File.Delete(keyPath); } finally { app.Stop(); } }
static void Main(string[] args) { Thread.Sleep(1000); var km = new KeyRepositoryClient(); Console.WriteLine("Writing key..."); km.WriteKey("Service", "Client", "Awesome", "some-key"); Console.WriteLine(" Done. Hit 'Return' to exit..."); Console.ReadKey(); }
static void Main(string[] args) { Thread.Sleep(1000); var km = new KeyRepositoryClient(); Console.WriteLine("Writing key..."); km.WriteKey("Service", "Client", "Awesome", "some-key"); Console.WriteLine(" Done. Hit 'Return' to exit..."); Console.ReadKey(); }
public void ShouldWriteKey() { var app = new KeyRepositoryApp(new ServiceAuthorizationManager()); try { app.Start(); var proxy = new KeyRepositoryClient(); const string institution = "ShouldWriteKeyInstitution"; const string group = "ShouldWriteKeyGroup"; const string product = "KeyManager"; var keyName = String.Format("{0}__{1}__{2}", institution, group, product); var keyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Physion", "Ovation", "keys", keyName); if (File.Exists(keyPath)) { File.Delete(keyPath); } proxy.WriteKey(institution, group, product, "some key"); Assert.True(File.Exists(keyPath)); if (File.Exists(keyPath)) { File.Delete(keyPath); } } finally { app.Stop(); } }
static void Main(string[] args) { bool show_help = false; string institution = null; string group = null; const string product = "Ovation"; bool system_key = false; var p = new OptionSet() { { "h|help", "show this message and exit", v => show_help = v != null }, {"i=|institution=", "licensed institution", (string v) => institution = v}, {"g=|group=", "licensed group", (string v) => group = v}, {"s|system", "add key to system query server (requires Administrator role)", v => system_key = v != null} }; List<string> extra; try { extra = p.Parse(args); } catch (OptionException e) { Console.Write("keyconsole: "); Console.WriteLine(e.Message); Console.WriteLine("Try `keyconsole --help' for more information."); return; } if (show_help) { ShowHelp(p); return; } if (institution == null) { Console.Write("keyconsole: "); Console.WriteLine("You must provide the licensed institution."); Console.WriteLine("Try `keyconsole --help' for more information."); return; } if (group == null) { Console.Write("keyconsole: "); Console.WriteLine("You must provide the licensed group."); Console.WriteLine("Try `keyconsole --help' for more information."); return; } if (system_key && !IsUserAdministrator()) { Console.Write("keyconsole: "); Console.WriteLine("Writing a key to the system (query server) key store requires administrator role."); Console.WriteLine("Run keyconsole as Administrator."); return; } var fsManager = new FileSystemKeyRepository(); Console.Write("Shared ecnryption key:"); var keyBuilder = ReadConsoleKey(); Console.WriteLine(""); Console.WriteLine("Re-enter shared encryption key:"); var keyBuilderComp = ReadConsoleKey(); Console.WriteLine(""); if (!keyBuilder.ToString().Equals(keyBuilderComp.ToString())) { Console.Write("keyconsole: "); Console.WriteLine("Keys do not match. Keys have not been modified"); return; } try { fsManager.WriteKey(institution, group, product, keyBuilder.ToString()); if (system_key) { var proxy = new KeyRepositoryClient(); proxy.WriteKey(institution, group, product, keyBuilder.ToString()); } } catch (Exception ex) { Console.Write("keyconsole: "); Console.WriteLine(ex.Message); Console.WriteLine("Try `keyconsole --help' for more information."); } }
static void Main(string[] args) { bool show_help = false; string institution = null; string group = null; const string product = "Ovation"; bool system_key = false; var p = new OptionSet() { { "h|help", "show this message and exit", v => show_help = v != null }, { "i=|institution=", "licensed institution", (string v) => institution = v }, { "g=|group=", "licensed group", (string v) => group = v }, { "s|system", "add key to system query server (requires Administrator role)", v => system_key = v != null } }; List <string> extra; try { extra = p.Parse(args); } catch (OptionException e) { Console.Write("keyconsole: "); Console.WriteLine(e.Message); Console.WriteLine("Try `keyconsole --help' for more information."); return; } if (show_help) { ShowHelp(p); return; } if (institution == null) { Console.Write("keyconsole: "); Console.WriteLine("You must provide the licensed institution."); Console.WriteLine("Try `keyconsole --help' for more information."); return; } if (group == null) { Console.Write("keyconsole: "); Console.WriteLine("You must provide the licensed group."); Console.WriteLine("Try `keyconsole --help' for more information."); return; } if (system_key && !IsUserAdministrator()) { Console.Write("keyconsole: "); Console.WriteLine("Writing a key to the system (query server) key store requires administrator role."); Console.WriteLine("Run keyconsole as Administrator."); return; } var fsManager = new FileSystemKeyRepository(); Console.Write("Shared ecnryption key:"); var keyBuilder = ReadConsoleKey(); Console.WriteLine(""); Console.WriteLine("Re-enter shared encryption key:"); var keyBuilderComp = ReadConsoleKey(); Console.WriteLine(""); if (!keyBuilder.ToString().Equals(keyBuilderComp.ToString())) { Console.Write("keyconsole: "); Console.WriteLine("Keys do not match. Keys have not been modified"); return; } try { fsManager.WriteKey(institution, group, product, keyBuilder.ToString()); if (system_key) { var proxy = new KeyRepositoryClient(); proxy.WriteKey(institution, group, product, keyBuilder.ToString()); } } catch (Exception ex) { Console.Write("keyconsole: "); Console.WriteLine(ex.Message); Console.WriteLine("Try `keyconsole --help' for more information."); } }