Personal profile signed with a valid administration key
        /// <summary>
        /// Create a new profile for [email protected]
        /// </summary>
        void CreateProfile() {
            // Create device profile
            SignedDeviceProfile1 = new SignedDeviceProfile(Device1, Device1Description);
            // Create master profile

            PersonalProfile = new PersonalProfile(SignedDeviceProfile1);
            SignedPersonalProfile = PersonalProfile.Signed;
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a MeshClient for the specified portal and request the specified 
        /// account.
        /// </summary>
        /// <param name="Portal">Mesh Portal.</param>
        /// <param name="Account">Mesh Account.</param>
        /// <returns>UDF of the personal profile.</returns>
        public string GetAccount (string Portal, string Account) {

            // Attempt to connect to portal and connect to account.

            this.Portal = Portal;
            this.AccountName = Account;

            MeshClient = new MeshClient(Portal, AccountID);
            SignedPersonalProfile = MeshClient.GetPersonalProfile();
            if (SignedPersonalProfile == null) return null;
            return SignedPersonalProfile.UDF;
            }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the active profile associated with the current account.
        /// </summary>
        /// <returns>The signed personal profile.</returns>
        public SignedPersonalProfile GetPersonalProfile() {
            if (AccountID == null) return null;

            var GetRequest = new GetRequest ();
            GetRequest.Account = AccountID;
            GetRequest.Multiple = false;

            var GetResponse = MeshService.Get(GetRequest);

            if (GetResponse.Entries.Count == 0) { return null; }

            _SignedPersonalProfile = GetResponse.Entries[0] as SignedPersonalProfile;

            if (PersonalProfile != null) {
                PersonalProfile.SignedDeviceProfile = SignedDeviceProfile;
                }
            return _SignedPersonalProfile;
            }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a new account and set the personal profile
        /// </summary>
        /// <param name="AccountID">The requested account identifier.</param>
        /// <param name="SignedCurrentProfile">The personal profile to use.</param>
        /// <returns>The service response.</returns>
        public CreateResponse CreatePersonalProfile(string AccountID,
                            SignedPersonalProfile SignedCurrentProfile) {

            var CreateRequest = new CreateRequest();
            CreateRequest.Profile = SignedCurrentProfile;
            CreateRequest.Account = AccountID;
            var CreateResponse = MeshService.CreateAccount(CreateRequest);

            this.AccountID = AccountID;
            //Register.Write(Constants.RegistryAccounts, AccountID, SignedCurrentProfile.UDF);

            return CreateResponse;
            }
        /// <summary>
        /// Having read a tag, process the corresponding value data.
        /// </summary>
        /// <param name="JSONReader"></param>
        /// <param name="Tag"></param>
		public override void DeserializeToken (JSONReader JSONReader, string Tag) {
			
			switch (Tag) {
				case "Profile" : {
					// An untagged structure
					Profile = new SignedPersonalProfile (JSONReader);
 
					break;
					}
				default : {
					base.DeserializeToken(JSONReader, Tag);
					break;
					}
				}
			// check up that all the required elements are present
			}
Ejemplo n.º 6
0
        /// <summary>
        /// Deserialize a tagged stream
        /// </summary>
        /// <param name="JSONReader">The input stream</param>
        /// <returns>The created object.</returns>		
        public static new SignedPersonalProfile  FromTagged (JSONReader JSONReader) {
			SignedPersonalProfile Out = null;

			JSONReader.StartObject ();
            if (JSONReader.EOR) {
                return null;
                }

			string token = JSONReader.ReadToken ();

			switch (token) {

				case "SignedPersonalProfile" : {
					var Result = new SignedPersonalProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				default : {
					//Ignore the unknown data
                    //throw new Exception ("Not supported");
                    break;
					}
				}
			JSONReader.EndObject ();

			return Out;
			}
Ejemplo n.º 7
0
        /// <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);
            }
        public void CheckValid () {
            var DevProfile = new  SignedDeviceProfile(Device1, Device1Description);
            var UserProfile = new PersonalProfile(DevProfile);
            var PasswordProfile = new PasswordProfile(UserProfile);
            var SignedProfile = new SignedPersonalProfile(UserProfile);
            //PasswordProfile.AddDevice(DevProfile);

            Mesh.AddProfile(SignedProfile);

            var UserProfile2 = Mesh.GetPersonalProfile(UserName);
            }
 private bool CheckProfile(SignedPersonalProfile Profile) {
     try {
         var TheProfile = Profile.Signed;
         return true;
         }
     catch {
         return false;
         }
     }
 private bool CheckProfileFails(SignedPersonalProfile Profile, Type ShouldThrow) {
     try {
         var TheProfile = Profile.Signed;
         return false;
         }
     catch (Exception ex) {
         if (ex.GetType() == ShouldThrow) {
             return true;
             }
         return false;
         }
     }
        public void CheckInValidBadProfileSignature(Mesh Mesh) {
            var DevProfile = new SignedDeviceProfile(Device1, Device1Description);
            var UserProfile = new PersonalProfile(DevProfile);
            var PasswordProfile = new PasswordProfile(UserProfile);
            //PasswordProfile.AddDevice(DevProfile);

            var SignedProfile = new SignedPersonalProfile(UserProfile);

            Mesh.AddProfile(SignedProfile);
            
            var SignedProfile2 = Mesh.GetSignedPersonalProfile(UserName);
            Trace.Spoil(SignedProfile2.SignedData.Signature, SignedProfile2.SignedData.Signature);
            var FoundError = CheckProfileFails(SignedProfile2, typeof(System.Exception));

            Debug.Trace.Assert("Missed error", FoundError);
            }
        public bool Calculate() {

            if (NewDeviceProfile) {
                var NewProfile = new SignedDeviceProfile(DeviceName, DeviceDescription);
                _DeviceProfile = NewProfile;
                }
            else {
                _DeviceProfile = ProfileManager.RegistrationMachine.Device.Device;
                }
            _PersonalProfile = new PersonalProfile(_DeviceProfile);


            // Have got the profile, escrow the key
            if (EscrowKeys) {
                var OfflineEscrowEntry = new
                    OfflineEscrowEntry(_PersonalProfile, EscrowShares, EscrowQuorum);

                EscrowKeyShares = new List<Goedel.Trojan.Object>();

                int Index = 1;
                foreach (var KeyShare in OfflineEscrowEntry.KeyShares) {
                    var Share = new Share();
                    Share.Number.Value = Index++;
                    Share.Value.Value = KeyShare.Text;
                    EscrowKeyShares.Add(Share);
                    }
                }

            if (WebApplicationProfile) {
                PasswordProfile = new PasswordProfile(PersonalProfile);
                PasswordProfile.AddDevice(_DeviceProfile);
                }

            // Mail profiles here
            /*
                             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);
                                }
             * */

            // Network profiles here
            /*
                                var NetworkProfile = new NetworkProfile(UserProfile);
                                NetworkProfile.AddDevice(ThisDevice);
                                MeshClient.Publish(NetworkProfile.Signed);
            */

            // SSH profiles here


            SignedPasswordProfile = PasswordProfile.Signed;
            _SignedPersonalProfile = new SignedPersonalProfile(PersonalProfile);

            return true;
            }
Ejemplo n.º 13
0
		/// <summary>
        /// Construct an instance from the specified tagged JSONReader stream.
        /// </summary>
        /// <param name="JSONReader">Input stream</param>
        /// <param name="Out">The created object</param>
        public static void Deserialize(JSONReader JSONReader, out JSONObject Out) {
	
			JSONReader.StartObject ();
            if (JSONReader.EOR) {
                Out = null;
                return;
                }

			string token = JSONReader.ReadToken ();
			Out = null;

			switch (token) {

				case "PublicKey" : {
					var Result = new PublicKey ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "SignedData" : {
					var Result = new SignedData ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "EncryptedData" : {
					var Result = new EncryptedData ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "Connection" : {
					var Result = new Connection ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "Entry" : {
					var Result = new Entry ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "SignedProfile" : {
					var Result = new SignedProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "Profile" : {
					Out = null;
					throw new Exception ("Can't create abstract type");
					}


				case "SignedDeviceProfile" : {
					var Result = new SignedDeviceProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "DeviceProfile" : {
					var Result = new DeviceProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "DevicePrivateProfile" : {
					var Result = new DevicePrivateProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "SignedMasterProfile" : {
					var Result = new SignedMasterProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "MasterProfile" : {
					var Result = new MasterProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "SignedPersonalProfile" : {
					var Result = new SignedPersonalProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "PersonalProfile" : {
					var Result = new PersonalProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "SignedApplicationProfile" : {
					var Result = new SignedApplicationProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "EncryptedProfile" : {
					var Result = new EncryptedProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "ApplicationProfile" : {
					var Result = new ApplicationProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "ApplicationProfilePrivate" : {
					var Result = new ApplicationProfilePrivate ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "ApplicationProfileEntry" : {
					var Result = new ApplicationProfileEntry ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "EscrowEntry" : {
					var Result = new EscrowEntry ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "OfflineEscrowEntry" : {
					var Result = new OfflineEscrowEntry ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "OnlineEscrowEntry" : {
					var Result = new OnlineEscrowEntry ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "EscrowedKeySet" : {
					var Result = new EscrowedKeySet ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "ConnectionRequest" : {
					var Result = new ConnectionRequest ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "SignedConnectionRequest" : {
					var Result = new SignedConnectionRequest ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "ConnectionResult" : {
					var Result = new ConnectionResult ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}


				case "SignedConnectionResult" : {
					var Result = new SignedConnectionResult ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				default : {
					throw new Exception ("Not supported");
					}
				}	
			JSONReader.EndObject ();
            }
Ejemplo n.º 14
0
        /// <summary>
        /// Attempt to complete the connection
        /// </summary>
        /// <returns></returns>
        public bool CompleteConnect () {
            var Connected = MeshClient.ConnectStatus(DevProfile.UDF);

            // Success?

            // Pull the new profile from the mesh.
            MeshClient = new MeshClient(Portal, AccountID);
            SignedPersonalProfile = MeshClient.GetPersonalProfile();


            // extract the personal profile

            var PersonalProfile = SignedPersonalProfile.Signed;
            PersonalProfile.SignedDeviceProfile = DevProfile;

            // extract the mail profile(s)

            foreach (var AppProfile in PersonalProfile.Applications) {
                if (AppProfile.Type == "MailProfile") {
                    InstallMail(PersonalProfile, AppProfile.Identifier);
                    }

                }

            // Create WLM accounts.


            return true;
            }
Ejemplo n.º 15
0
        public static void Dump(SignedPersonalProfile Item) {
            if (Item == null) return;

            Dump (Item.Signed);
            }
Ejemplo n.º 16
0
        /// <summary>
        /// Add a second device
        /// </summary>
        void ConnectDevice() {
            
            // Create device profile
            SignedDeviceProfile2 = new SignedDeviceProfile(Device2, Device2Description);

            Portal.Label(LabelConnectRequest);
            // Post connection request
            MeshClient.ConnectRequest (SignedDeviceProfile2);

            Portal.Label(LabelConnectPending);
            // Poll for list of connection requests
            var ConnectPendingResult = MeshClient.ConnectPending();


            var FirstRequest = ConnectPendingResult.Pending[0];

            // Publish the updated profile to the Mesh.
            Portal.Label(LabelConnectPublish);
            PersonalProfile.Add(FirstRequest.Data.Device);
            SignedPersonalProfile = PersonalProfile.Signed;
            MeshClient.Publish(SignedPersonalProfile);

            Portal.Label(LabelConnectAccept);
            // Post acceptance for first request
            MeshClient.ConnectClose(FirstRequest, ConnectionStatus.Accepted);
            Portal.Label(LabelConnectStatus);
            // Retrieve acceptance
            MeshClient.ConnectStatus(SignedDeviceProfile2.UDF);
            }
Ejemplo n.º 17
0
        private void GetProfile(String Portal, String UDF) {

            RegistrationPersonal = Machine.Personal;
            Utils.Assert(RegistrationPersonal, "No profile found");

            PortalID = RegistrationPersonal?.Portals?[0];
            Utils.Assert(PortalID, "No portal ID known");

            SignedPersonalProfile = RegistrationPersonal.Profile;
            PersonalProfile = SignedPersonalProfile.Signed;

            PersonalProfile.SignedDeviceProfile = GetDevice(SignedPersonalProfile);
            }
Ejemplo n.º 18
0
        /// <summary>
        /// One time initialization of the page.
        /// </summary>
        public override void Initialize() {

            // Get the device profile or create a new one if necessary.
            ThisDevice = SignedDeviceProfile.GetLocal(Device1, Device1Description);



            if (DoLocal) {
                MeshPortal.Default = new MeshPortalDirect();

                // Get the default profile if possible
                MeshClient = new MeshClient(); // default account
                MeshClient.AccountID = AccountID;

                if (MeshClient.Connected) {
                    AccountName = MeshClient.AccountName;
                    Portal = MeshClient.Portal;
                    SignedCurrentProfile = SignedPersonalProfile.GetLocal(MeshClient.UDF);
                    Navigate(Data_SetupComplete);
                    }
                }


            else {

                JPCProvider.LocalLoopback = false;
                var Portal = new MeshPortalRemote();
                MeshPortal.Default = Portal;


                }


            }
Ejemplo n.º 19
0
 // A placeholder routine. This should actually search
 // the profile to find a matching device profile that
 // is supported on the local machine.
 private SignedDeviceProfile GetDevice(SignedPersonalProfile Profile) {
     return Machine.Device.Device;
     }
Ejemplo n.º 20
0
        /// <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;
            }
Ejemplo n.º 21
0
        /// <summary>
        /// Deserialize a tagged stream
        /// </summary>
        /// <param name="JSONReader">The input stream</param>
        /// <returns>The created object.</returns>		
        public static new Entry  FromTagged (JSONReader JSONReader) {
			Entry Out = null;

			JSONReader.StartObject ();
            if (JSONReader.EOR) {
                return null;
                }

			string token = JSONReader.ReadToken ();

			switch (token) {

				case "Entry" : {
					var Result = new Entry ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "SignedProfile" : {
					var Result = new SignedProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "SignedDeviceProfile" : {
					var Result = new SignedDeviceProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "SignedMasterProfile" : {
					var Result = new SignedMasterProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "SignedPersonalProfile" : {
					var Result = new SignedPersonalProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "SignedApplicationProfile" : {
					var Result = new SignedApplicationProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "SignedConnectionRequest" : {
					var Result = new SignedConnectionRequest ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "SignedConnectionResult" : {
					var Result = new SignedConnectionResult ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "Profile" : {
					Out = null;
					throw new Exception ("Can't create abstract type");
					}

				case "DeviceProfile" : {
					var Result = new DeviceProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "MasterProfile" : {
					var Result = new MasterProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "PersonalProfile" : {
					var Result = new PersonalProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "ApplicationProfile" : {
					var Result = new ApplicationProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "EncryptedProfile" : {
					var Result = new EncryptedProfile ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "ApplicationProfilePrivate" : {
					var Result = new ApplicationProfilePrivate ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "EscrowEntry" : {
					var Result = new EscrowEntry ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "OfflineEscrowEntry" : {
					var Result = new OfflineEscrowEntry ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				case "OnlineEscrowEntry" : {
					var Result = new OnlineEscrowEntry ();
					Result.Deserialize (JSONReader);
					Out = Result;
					break;
					}

				default : {
					//Ignore the unknown data
                    //throw new Exception ("Not supported");
                    break;
					}
				}
			JSONReader.EndObject ();

			return Out;
			}