private void CreateInvalidVenue(VenueList venues, VenueService.Venue v) { eventLog.WriteEntry(string.Format("Invalid venue: {0}", v.Name), EventLogEntryType.Warning, ConferenceEventLog.ID.Error); venues.Add(new ConferenceXP.Venue(v.Name, new IPEndPoint(IPAddress.Any, 0), VenueType.Invalid, Utilities.ByteToBitmap(v.Icon))); }
internal Venue(VenueService.Venue v) { identifier = v.Identifier; name = v.Name; icon = Utilities.ByteToBitmap(v.Icon); // Trim the IPAddress, because whitespace isn't handled in .NET 2.0, but was in .NET 1.1 string trimmedIP = v.IPAddress.Trim(); endPoint = new IPEndPoint(IPAddress.Parse(trimmedIP), v.Port); }
public Venue ResolvePassword(String venueID, String password) { byte[] passwordHash = PasswordHasher.getInstance().HashPassword(password); VenueService.Venue retVal = service.GetVenueWithPassword(venueID, passwordHash); if (retVal == null || retVal.IPAddress == null || retVal.IPAddress.Equals(IPAddress.None)) { throw new InvalidPasswordException(); } else { return(new Venue(retVal)); } }
public VenueEditor(Venue venueToEdit) { // // Required for Windows Form Designer support // InitializeComponent(); iconInput.DefaultIcon = defaultVenueIcon; // Show the venue information in the UI this.nameInput.Text = venueToEdit.Name; this.ownerInput.Text = venueToEdit.Identifier; this.ipInput.Text = venueToEdit.IPAddress; this.portInput.Text = venueToEdit.Port.ToString(); this.iconInput.IconAsBytes = venueToEdit.Icon; this.newAccessList = venueToEdit.AccessList; this.original = venueToEdit; }
public VenueEditor(VenueState venueState) { // // Required for Windows Form Designer support // InitializeComponent(); iconInput.DefaultIcon = defaultVenueIcon; // Show the venue information in the UI Venue venueToEdit = venueState.Venue; this.nameInput.Text = venueToEdit.Name; this.ownerInput.Text = venueToEdit.Identifier; this.ipInput.Text = venueToEdit.IPAddress; this.portInput.Text = venueToEdit.Port.ToString(CultureInfo.InvariantCulture); this.iconInput.IconAsBytes = venueToEdit.Icon; this.newAccessList = venueToEdit.AccessList; this.original = venueToEdit; this.privateVenueState = venueState.PrivateVenueState; this.passwordStatus = venueToEdit.PWStatus; }
public VenueState(Venue venue, PrivateVenueState pvs) { this.privateVenueState = pvs; this.venue = venue; }
public VenueState() { venue = new Venue(); privateVenueState = new PrivateVenueState(); }
public void AddVenue(Venue venue, PrivateVenueState privateVenueState) { AddVenue(new VenueState(venue, privateVenueState)); }
/// <summary> /// Hide the IP Address for venues with password protection. Make a new object /// so we don't destroy the true state. /// </summary> /// <param name="venue"></param> /// <returns></returns> private Venue RemoveSensitiveState(Venue venue) { if (venue.PWStatus == PasswordStatus.NO_PASSWORD) return venue; else { Venue newVenue = new Venue(venue.Identifier, "0.0.0.0", 1, venue.Name, venue.Icon, venue.AccessList); newVenue.PWStatus = venue.PWStatus; return newVenue; } }
public Venue[] GetVenues() { this.UpdateFromFile(); ICollection vals = venues.Values; Venue[] venueArray = new Venue[vals.Count]; vals.CopyTo(venueArray, 0); return venueArray; }
static void Main(string[] args) { string message; VenueService_Sample VenueService_Sample = null; try { // Start by getting the venue service storage (use the app.config as an override) string filePath = ConfigurationManager.AppSettings["FilePath"]; if (filePath == null || filePath == String.Empty) { // Use the registry key using (RegistryKey key = Registry.LocalMachine.OpenSubKey(StorageInstaller.LocalMachineSubkey)) { filePath = (string)key.GetValue("DataFile"); } } FileStorage storage = new FileStorage(filePath); VenueService_Sample = new VenueService_Sample(); message = "VenueService_Sample started successfully"; VenueService_Sample.WriteToLog(message, EventLogEntryType.Information); // Create a reference to the VenueService web service Console.WriteLine("Create a reference to the VenueService web service"); MSR.LST.ConferenceXP.VenueService.VenueService.VenueService vs = new MSR.LST.ConferenceXP.VenueService.VenueService.VenueService(); // Cleanup - remove venues and particpants in case the sample was cancelled before it finished // Will fail silently if not present try { storage.DeleteVenue("*****@*****.**"); } catch {} try { storage.DeleteVenue("*****@*****.**"); } catch {} try { storage.DeleteParticipant("*****@*****.**"); } catch {} try { storage.DeleteParticipant("*****@*****.**"); } catch {} Console.WriteLine("Create venues called v1 and v2, and set venue security"); // Create the first venue called v1, and update the attributes // Create the security so venue1@ms and anyone at hotmail can join Venue v1 = new Venue(); v1.Name = "Test Venue 1"; v1.Identifier = "*****@*****.**"; v1.Icon = null; v1.IPAddress = "233.233.233.10"; v1.Port = 1000; v1.AccessList = new SecurityPatterns(new String[] { @"[\w-]@hotmail.com" }); storage.AddVenue(v1); // Create the second venue called v2, and update the attributes // Create the security so venue2@ms and anyone at msn can join Venue v2 = new Venue(); v2.Name = "Test Venue 2"; v2.Identifier = "*****@*****.**"; v2.Icon = null; v2.IPAddress = "233.233.233.11"; v2.Port = 1000; v2.AccessList = new SecurityPatterns(new String[] { @"[\w-]@msn.com" }); storage.AddVenue(v2); Console.WriteLine("Test venue security"); // Get the list of venues for jav@hotmail and verify which venues he can see VS.Venue[] vList = vs.GetVenues("*****@*****.**"); bool v1Found = false; bool v2Found = false; foreach (VS.Venue v in vList) { if (v.Identifier == v1.Identifier) { v1Found = true; } else if (v.Identifier == v2.Identifier) { v2Found = true; } } // Validate that only allowed people can join v1 // positive case if (!v1Found) { message = "Permission Failed\n [email protected] should have access to V1"; throw new Exception(message); } // negative case if (v2Found) { message = "Failed! Permission Failed\n [email protected] should not have access to V2"; throw new Exception(message); } Console.WriteLine("Update the name attribute of v1"); // Update the name attribute of v1 v1.Name = "Test Venue 1 Updated"; storage.UpdateVenue(v1); // Verify the name change of v1 by retriving the name from the server // and compare against the local name. if (vs.GetVenue(v1.Identifier).Name != v1.Name) { message = "Failed: UpdateVenue() - " + vs.GetVenue(v1.Identifier).Name.ToString() + "!=" + v1.Name.ToString(); throw new Exception(message); } Console.WriteLine("Delete v1 and v2"); // Delete v1 storage.DeleteVenue(v1.Identifier); // Verify v1 is deleted if (vs.GetVenue(v1.Identifier) != null) { message = "Failed: v1 cannot be deleted."; throw new Exception(message); } // Delete v2 storage.DeleteVenue(v2.Identifier); // Verify v2 is deleted if (vs.GetVenue(v2.Identifier) != null) { message = "Failed: v2 cannot be deleted."; throw new Exception(message); } Console.WriteLine("Create participants called p1 and p2"); //Create the first participant called p1, and update the atrributes VS.Participant p1 = new VS.Participant(); p1.Name = "Test Participant 1"; p1.Icon = null; p1.Identifier = "*****@*****.**"; vs.AddParticipant(p1); //Create the second participant called p2, and update the attributes VS.Participant p2 = new VS.Participant(); p2.Name = "Test Participant 2"; p2.Icon = null; p2.Identifier = "*****@*****.**"; vs.AddParticipant(p2); // Verify the participants (p1 and p2) are created by checking the // total number of participants existed // Just check number is >= 2 so that we don't fail on sample venues. VS.Participant[] pList = vs.GetParticipants(); if (pList.Length < 2) { message = "Failed! GetParticipants() - Incorrect number of participants: " + pList.Length + " (should be 2). It may be caused by a participant that is not able to be" + " created or preexisting participant not being cleaned up."; throw new Exception(message); } Console.WriteLine("Update the name attribute of p1"); // Update the name attribute of p1 p1.Name = "Test Participant 1 Updated"; vs.UpdateParticipant(p1); // Verify the name change of p1 by retriving the name from the server // and compare against the local name. if (vs.GetParticipant(p1.Identifier).Name != p1.Name) { message = "Failed: UpdateParticipant() - " + vs.GetParticipant(p1.Identifier).Name.ToString() + "!=" + p1.Name.ToString(); throw new Exception(message); } Console.WriteLine("Delete p1 and p2"); // Delete p1 storage.DeleteParticipant(p1.Identifier); // Verify p1 is deleted if (vs.GetParticipant(p1.Identifier) != null) { message = "Failed! DeleteParticipant() - p1 cannot be deleted"; throw new Exception(message); } // Delete p2 storage.DeleteParticipant(p2.Identifier); // Verify p2 is deleted if (vs.GetParticipant(p2.Identifier) != null) { message = "Failed! DelteParticipant() - p2 cannot be deleted"; throw new Exception(message); } message = "VenueService_Sample ended successfully"; VenueService_Sample.WriteToLog(message, EventLogEntryType.Information); Console.WriteLine("Press a key to continue"); Console.Read(); return; } catch (Exception ex) { message = ex.ToString(); VenueService_Sample.WriteToLog(message, EventLogEntryType.Error); message = "Test ended abnormally"; VenueService_Sample.WriteToLog(message, EventLogEntryType.Information); return; } }
private ListViewItem CreateLvi(Venue venue, int imageIndex) { string[] columns = new string[]{venue.Name, venue.Identifier, venue.IPAddress.ToString(), venue.Port.ToString()}; ListViewItem item = new ListViewItem(columns); item.ImageIndex = imageIndex; item.Tag = venue; return item; }
public Venue[] GetVenues() { SqlConnection conn = new SqlConnection( SQL_CONNECTION_STRING); SqlCommand cmd = new SqlCommand( "GetVenues", conn ); cmd.CommandType = CommandType.StoredProcedure; conn.Open(); SqlDataReader r = cmd.ExecuteReader(CommandBehavior.SingleResult); ArrayList venuesArray = new ArrayList(); while ( r.Read() ) { byte[] icon = null; if ( !r.IsDBNull(vICONLENGTH) ) { icon = new Byte[r.GetInt32(vICONLENGTH)]; r.GetBytes(vICON, 0,icon, 0, icon.Length); } Venue v = new Venue( r.GetString(vIDENTIFIER), r.GetString(vIPADDRESS), r.GetInt32(vPORT), r.GetString(vNAME), icon, null ); venuesArray.Add( v); } r.Close(); conn.Close(); return (Venue[])venuesArray.ToArray(typeof( Venue)); }
/// <summary> /// Compiles all of the data on the screen and returns it as a venue. /// </summary> public Venue GetVenue() { Venue vnu = new Venue(this.ownerInput.Text.Trim(), this.ipInput.Text.Trim(), Int32.Parse(this.portInput.Text.Trim(), CultureInfo.InvariantCulture), this.nameInput.Text.Trim(), this.iconInput.IconAsBytes, this.newAccessList); vnu.PWStatus = this.passwordStatus; return vnu; }
public void AddVenue(Venue v) { this.UpdateFromFile(); venues.Add( v.Identifier, v ); WriteCacheToFile(); }
/// <summary> /// Returns the client-visible portion of venue state. We elide /// the IP address for password-enabled venues. /// </summary> /// <returns></returns> public Venue[] GetVenues() { this.UpdateFromFile(); ICollection vals = venues.Values; Venue[] venueArray = new Venue[vals.Count]; int i = 0; foreach (Venue venue in vals) { //venueArray[i++] = RemoveSensitiveState(venue); venueArray[i++] = venue; } return venueArray; }
public void UpdateVenue(Venue v) { this.UpdateFromFile(); venues[v.Identifier] = v; WriteCacheToFile(); }
static void Main(string[] args) { // Override the system UICulture string cultureOverride = null; if ((cultureOverride = ConfigurationManager.AppSettings["MSR.LST.ConferenceXP.VenueService.UICulture"]) != null) { try { System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(cultureOverride); System.Threading.Thread.CurrentThread.CurrentUICulture = ci; } catch { } } string message; VenueService_Sample VenueService_Sample = null; try { // Start by getting the venue service storage (use the app.config as an override) string filePath = ConfigurationManager.AppSettings["FilePath"]; if (filePath == null || filePath == String.Empty) { // Use the registry key using (RegistryKey key = Registry.LocalMachine.OpenSubKey(StorageInstaller.LocalMachineSubkey)) { filePath = (string)key.GetValue("DataFile"); } } FileStorage storage = new FileStorage(filePath); VenueService_Sample = new VenueService_Sample(); message = Strings.VenueServiceSampleStartedSuccessfully; VenueService_Sample.WriteToLog(message, EventLogEntryType.Information); // Create a reference to the VenueService web service Console.WriteLine(Strings.CreateAReferenceToTheVenueServiceWebService); MSR.LST.ConferenceXP.VenueService.VenueService.VenueService vs = new MSR.LST.ConferenceXP.VenueService.VenueService.VenueService(); // Cleanup - remove venues and particpants in case the sample was cancelled before it finished // Will fail silently if not present try { storage.DeleteVenue("*****@*****.**"); } catch {} try { storage.DeleteVenue("*****@*****.**"); } catch {} try { storage.DeleteParticipant("*****@*****.**"); } catch {} try { storage.DeleteParticipant("*****@*****.**"); } catch {} Console.WriteLine(Strings.CreateVenuesCalledV1AndV2); // Create the first venue called v1, and update the attributes // Create the security so venue1@ms and anyone at hotmail can join Venue v1 = new Venue(); v1.Name = "Test Venue 1"; v1.Identifier = "*****@*****.**"; v1.Icon = null; v1.IPAddress = "233.233.233.10"; v1.Port = 1000; v1.AccessList = new SecurityPatterns(new String[] { @"[\w-]@hotmail.com" }); storage.AddVenue(v1, new PrivateVenueState()); // Create the second venue called v2, and update the attributes // Create the security so venue2@ms and anyone at msn can join Venue v2 = new Venue(); v2.Name = "Test Venue 2"; v2.Identifier = "*****@*****.**"; v2.Icon = null; v2.IPAddress = "233.233.233.11"; v2.Port = 1000; v2.AccessList = new SecurityPatterns(new String[] { @"[\w-]@msn.com" }); storage.AddVenue(v2, new PrivateVenueState()); Console.WriteLine(Strings.TestVenueSecurity); // Get the list of venues for jav@hotmail and verify which venues he can see VS.Venue[] vList = vs.GetVenues("*****@*****.**"); bool v1Found = false; bool v2Found = false; foreach (VS.Venue v in vList) { if (v.Identifier == v1.Identifier) { v1Found = true; } else if (v.Identifier == v2.Identifier) { v2Found = true; } } // Validate that only allowed people can join v1 // positive case if (!v1Found) { message = Strings.PermissionFailedSecurityError; throw new Exception(message); } // negative case if (v2Found) { message = Strings.PermissionFailedNegativeCaseSecurityError; throw new Exception(message); } Console.WriteLine(Strings.UpdateTheNameAttributeOfV1); // Update the name attribute of v1 v1.Name = "Test Venue 1 Updated"; storage.UpdateVenue(new VenueState(v1, new PrivateVenueState())); // Verify the name change of v1 by retriving the name from the server // and compare against the local name. if (vs.GetVenue(v1.Identifier).Name != v1.Name) { message = string.Format(CultureInfo.CurrentCulture, Strings.VenueNameChangeFailed, vs.GetVenue(v1.Identifier).Name.ToString(), v1.Name.ToString()); throw new Exception(message); } Console.WriteLine(Strings.DeleteV1AndV2); // Delete v1 storage.DeleteVenue(v1.Identifier); // Verify v1 is deleted if (vs.GetVenue(v1.Identifier) != null) { message = Strings.FailedV1CannotBeDeleted; throw new Exception(message); } // Delete v2 storage.DeleteVenue(v2.Identifier); // Verify v2 is deleted if (vs.GetVenue(v2.Identifier) != null) { message = Strings.FailedV2CannotBeDeleted; throw new Exception(message); } Console.WriteLine(Strings.CreateParticipants); //Create the first participant called p1, and update the atrributes VS.Participant p1 = new VS.Participant(); p1.Name = "Test Participant 1"; p1.Icon = null; p1.Identifier = "*****@*****.**"; vs.AddParticipant(p1); //Create the second participant called p2, and update the attributes VS.Participant p2 = new VS.Participant(); p2.Name = "Test Participant 2"; p2.Icon = null; p2.Identifier = "*****@*****.**"; vs.AddParticipant(p2); // Verify the participants (p1 and p2) are created by checking the // total number of participants existed // Just check number is >= 2 so that we don't fail on sample venues. VS.Participant[] pList = vs.GetParticipants(); if (pList.Length < 2) { message = string.Format(CultureInfo.CurrentCulture, Strings.IncorrectNumberOfParticipants, pList.Length); throw new Exception(message); } Console.WriteLine(Strings.UpdateTheNameAttributeOfP1); // Update the name attribute of p1 p1.Name = "Test Participant 1 Updated"; vs.UpdateParticipant(p1); // Verify the name change of p1 by retriving the name from the server // and compare against the local name. if (vs.GetParticipant(p1.Identifier).Name != p1.Name) { message = string.Format(CultureInfo.CurrentCulture, Strings.ParticipantNameChangeFailed, vs.GetParticipant(p1.Identifier).Name.ToString(), p1.Name.ToString()); throw new Exception(message); } Console.WriteLine(Strings.DeleteP1AndP2); // Delete p1 storage.DeleteParticipant(p1.Identifier); // Verify p1 is deleted if (vs.GetParticipant(p1.Identifier) != null) { message = Strings.FailedDeleteParticipantP1; throw new Exception(message); } // Delete p2 storage.DeleteParticipant(p2.Identifier); // Verify p2 is deleted if (vs.GetParticipant(p2.Identifier) != null) { message = Strings.FailedDelteParticipantP2; throw new Exception(message); } message = Strings.VenueServiceSampleEndedSuccessfully; VenueService_Sample.WriteToLog(message, EventLogEntryType.Information); Console.WriteLine(Strings.PressAKeyToContinue); Console.Read(); return; } catch (Exception ex) { message = ex.ToString(); VenueService_Sample.WriteToLog(message, EventLogEntryType.Error); message = Strings.TestEndedAbnormally; VenueService_Sample.WriteToLog(message, EventLogEntryType.Information); return; } }