/// <summary> /// Accept the connection request /// </summary> public bool AcceptConnection() { // Get the connection request var CurrentRequest = PendingConnectionRequests[0]; var RequestData = CurrentRequest.Data; // Extract the device profile var DeviceProfile = RequestData.Device; //// Validate the device profile //var SignedPersonalProfile = MeshClient.GetPersonalProfile(); //// Add device profile to personal profile //var UserProfile = SignedPersonalProfile.Signed; UserProfile.Add(DeviceProfile); UserProfile.SignedDeviceProfile = ThisDevice; foreach (var Entry in UserProfile.Applications) { AddDevice(Entry, UserProfile, DeviceProfile); } // Sign personal profile var SignedProfile = new SignedPersonalProfile(UserProfile); SignedProfile.ToRegistry(); // Send client the personal profile update MeshClient.Publish(SignedProfile); // Send client the connection result MeshClient.ConnectClose(CurrentRequest, ConnectionStatus.Accepted); return true; }
/// <summary> /// Generate a new profile with the requested options. Note that this could be /// parallelized very easily by performing time consuming operations (e.g. generating /// keys) while the user is answering other questions. /// </summary> public void GenerateProfile() { UserProfile = new PersonalProfile(ThisDevice); UDF = UserProfile.PersonalMasterProfile.MasterSignatureKey.UDF; if (ConfigurePassword) { var PasswordProfile = new PasswordProfile(UserProfile); PasswordProfile.AddDevice(ThisDevice); MeshClient.Publish(PasswordProfile.Signed); } if (ConfigureNetwork) { var NetworkProfile = new NetworkProfile(UserProfile); NetworkProfile.AddDevice(ThisDevice); MeshClient.Publish(NetworkProfile.Signed); } if (ConfigureEmail) { foreach (var MailAccountInfo in MailAccountInfos) { // Add in the S/MIME parameters and update the profile //if (!MailAccountInfo.GotSMIME) { MailAccountInfo.GenerateSMIME(); MailAccountInfo.Update(); //} var MailProfile = new MailProfile(UserProfile, MailAccountInfo); MailProfile.AddDevice(ThisDevice); //var SignedMailProfile = new SignedApplicationProfile(MailProfile); MeshClient.Publish(MailProfile.Signed); } } if (ConfigureRecovery) { MakeCheckRecovery(); } // publish to the cloud var SignedProfile = new SignedPersonalProfile(UserProfile); SignedProfile.ToRegistry(); MeshClient.CreatePersonalProfile(AccountID, SignedProfile); }