Exemplo n.º 1
0
        internal Collection <RemoteHostCall> PerformSecurityChecksOnHostMessage(string computerName)
        {
            this._computerName = computerName;
            Collection <RemoteHostCall> collection = new Collection <RemoteHostCall>();

            if ((this._methodId == RemoteHostMethodId.PromptForCredential1) || (this._methodId == RemoteHostMethodId.PromptForCredential2))
            {
                string str  = this.ModifyCaption((string)this._parameters[0]);
                string str2 = this.ModifyMessage((string)this._parameters[1], computerName);
                this._parameters[0] = str;
                this._parameters[1] = str2;
                return(collection);
            }
            if (this._methodId == RemoteHostMethodId.Prompt)
            {
                if (this._parameters.Length == 3)
                {
                    Collection <FieldDescription> collection2 = (Collection <FieldDescription>) this._parameters[2];
                    bool flag = false;
                    foreach (FieldDescription description in collection2)
                    {
                        description.IsFromRemoteHost = true;
                        Type fieldType = InternalHostUserInterface.GetFieldType(description);
                        if (fieldType != null)
                        {
                            if (fieldType == typeof(PSCredential))
                            {
                                flag = true;
                                description.ModifiedByRemotingProtocol = true;
                            }
                            else if (fieldType == typeof(SecureString))
                            {
                                collection.Add(this.ConstructWarningMessageForSecureString(computerName, RemotingErrorIdStrings.RemoteHostPromptSecureStringPrompt));
                            }
                        }
                    }
                    if (flag)
                    {
                        string str3 = this.ModifyCaption((string)this._parameters[0]);
                        string str4 = this.ModifyMessage((string)this._parameters[1], computerName);
                        this._parameters[0] = str3;
                        this._parameters[1] = str4;
                    }
                }
                return(collection);
            }
            if (this._methodId == RemoteHostMethodId.ReadLineAsSecureString)
            {
                collection.Add(this.ConstructWarningMessageForSecureString(computerName, RemotingErrorIdStrings.RemoteHostReadLineAsSecureStringPrompt));
                return(collection);
            }
            if (this._methodId == RemoteHostMethodId.GetBufferContents)
            {
                collection.Add(this.ConstructWarningMessageForGetBufferContents(computerName));
            }
            return(collection);
        }
Exemplo n.º 2
0
        internal Collection <RemoteHostCall> PerformSecurityChecksOnHostMessage(
            string computerName)
        {
            this._computerName = computerName;
            Collection <RemoteHostCall> collection = new Collection <RemoteHostCall>();

            if (this._methodId == RemoteHostMethodId.PromptForCredential1 || this._methodId == RemoteHostMethodId.PromptForCredential2)
            {
                string str1 = this.ModifyCaption((string)this._parameters[0]);
                string str2 = this.ModifyMessage((string)this._parameters[1], computerName);
                this._parameters[0] = (object)str1;
                this._parameters[1] = (object)str2;
            }
            else if (this._methodId == RemoteHostMethodId.Prompt)
            {
                if (this._parameters.Length == 3)
                {
                    foreach (FieldDescription field in (Collection <FieldDescription>) this._parameters[2])
                    {
                        field.IsFromRemoteHost = true;
                        Type fieldType = InternalHostUserInterface.GetFieldType(field);
                        if (fieldType != null)
                        {
                            if (fieldType == typeof(PSCredential))
                            {
                                string str1 = this.ModifyCaption((string)this._parameters[0]);
                                string str2 = this.ModifyMessage((string)this._parameters[1], computerName);
                                this._parameters[0] = (object)str1;
                                this._parameters[1] = (object)str2;
                                field.ModifiedByRemotingProtocol = true;
                            }
                            else if (fieldType == typeof(SecureString))
                            {
                                collection.Add(this.ConstructWarningMessageForSecureString(computerName, PSRemotingErrorId.RemoteHostPromptSecureStringPrompt));
                            }
                        }
                    }
                }
            }
            else if (this._methodId == RemoteHostMethodId.ReadLineAsSecureString)
            {
                collection.Add(this.ConstructWarningMessageForSecureString(computerName, PSRemotingErrorId.RemoteHostReadLineAsSecureStringPrompt));
            }
            else if (this._methodId == RemoteHostMethodId.GetBufferContents)
            {
                collection.Add(this.ConstructWarningMessageForGetBufferContents(computerName));
            }
            return(collection);
        }
        public override Dictionary <string, PSObject> Prompt(string caption, string message, Collection <FieldDescription> descriptions)
        {
            Dictionary <string, PSObject> dictionary = this._serverMethodExecutor.ExecuteMethod <Dictionary <string, PSObject> >(RemoteHostMethodId.Prompt, new object[] { caption, message, descriptions });

            foreach (FieldDescription description in descriptions)
            {
                PSObject obj2;
                object   obj3;
                Type     fieldType = InternalHostUserInterface.GetFieldType(description);
                if (((fieldType != null) && dictionary.TryGetValue(description.Name, out obj2)) && LanguagePrimitives.TryConvertTo(obj2, fieldType, CultureInfo.InvariantCulture, out obj3))
                {
                    if (obj3 != null)
                    {
                        dictionary[description.Name] = PSObject.AsPSObject(obj3);
                    }
                    else
                    {
                        dictionary[description.Name] = null;
                    }
                }
            }
            return(dictionary);
        }
Exemplo n.º 4
0
        public override Dictionary <string, PSObject> Prompt(
            string caption,
            string message,
            Collection <FieldDescription> descriptions)
        {
            Dictionary <string, PSObject> dictionary = this._serverMethodExecutor.ExecuteMethod <Dictionary <string, PSObject> >(RemoteHostMethodId.Prompt, new object[3]
            {
                (object)caption,
                (object)message,
                (object)descriptions
            });

            foreach (FieldDescription description in descriptions)
            {
                Type     fieldType = InternalHostUserInterface.GetFieldType(description);
                PSObject psObject;
                object   result;
                if (fieldType != null && dictionary.TryGetValue(description.Name, out psObject) && LanguagePrimitives.TryConvertTo((object)psObject, fieldType, (IFormatProvider)CultureInfo.InvariantCulture, out result))
                {
                    dictionary[description.Name] = result == null ? (PSObject)null : PSObject.AsPSObject(result);
                }
            }
            return(dictionary);
        }