/// <summary>
        /// This ROP logs on to a private mailbox or public folder. 
        /// </summary>
        /// <param name="logonType">This type specifies ongoing action on the private mailbox or public folder.</param>
        /// <param name="logonResponse">The response of this ROP.</param>
        /// <param name="userDN">This string specifies which mailbox to log on to.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The handle of logon object.</returns>
        private uint RopLogon(LogonType logonType, out RopLogonResponse logonResponse, string userDN, bool needVerify)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;
            userDN += "\0";
            uint insideObjHandle = 0;

            RopLogonRequest logonRequest = new RopLogonRequest()
            {
                RopId = (byte)RopId.RopLogon,
                LogonId = LogonId,
                OutputHandleIndex = (byte)HandleIndex.FirstIndex,
                StoreState = (uint)StoreState.None,

                // Set parameters for public folder logon type.
                LogonFlags = logonType == LogonType.PublicFolder ? (byte)LogonFlags.PublicFolder : (byte)LogonFlags.Private,
                OpenFlags = logonType == LogonType.PublicFolder ? (uint)(OpenFlags.UsePerMDBReplipMapping | OpenFlags.Public) : (uint)OpenFlags.UsePerMDBReplipMapping,

                // Set EssdnSize to 0, which specifies the size of the ESSDN field.
                EssdnSize = logonType == LogonType.PublicFolder ? (ushort)0 : (ushort)Encoding.ASCII.GetByteCount(userDN),
                Essdn = logonType == LogonType.PublicFolder ? null : Encoding.ASCII.GetBytes(userDN),
            };

            this.responseSOHsValue = this.ProcessSingleRop(logonRequest, insideObjHandle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            logonResponse = (RopLogonResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, logonResponse.ReturnValue, string.Format("Logon Failed! Error: 0x{0:X8}", logonResponse.ReturnValue));
            }

            return this.responseSOHsValue[0][logonResponse.OutputHandleIndex];
        }
Exemplo n.º 2
0
        public override void Deserialize(BitReader reader)
        {
            Id = (ClientMailPacketId)reader.Read <uint>();

            switch (Id)
            {
            case ClientMailPacketId.Send:
                MailStruct = new MailSend();
                break;

            case ClientMailPacketId.DataRequest:
                break;

            case ClientMailPacketId.AttachmentCollected:
                MailStruct = new MailAttachmentCollected();
                break;

            case ClientMailPacketId.Delete:
                MailStruct = new MailDelete();
                break;

            case ClientMailPacketId.Read:
                MailStruct = new MailRead();
                break;

            case ClientMailPacketId.NotificationRequest:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(Id));
            }

            MailStruct?.Deserialize(reader);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This ROP logs on to a private mailbox or public folder.
        /// </summary>
        /// <param name="logonType">This type specifies ongoing action on the private mailbox or public folder.</param>
        /// <param name="logonResponse">The response of this ROP.</param>
        /// <param name="userDN">This string specifies which mailbox to log on to.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The handle of logon object.</returns>
        private uint RopLogon(LogonType logonType, out RopLogonResponse logonResponse, string userDN, bool needVerify)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;
            userDN += "\0";
            uint insideObjHandle = 0;

            RopLogonRequest logonRequest = new RopLogonRequest()
            {
                RopId             = (byte)RopId.RopLogon,
                LogonId           = LogonId,
                OutputHandleIndex = (byte)HandleIndex.FirstIndex,
                StoreState        = (uint)StoreState.None,

                // Set parameters for public folder logon type.
                LogonFlags = logonType == LogonType.PublicFolder ? (byte)LogonFlags.PublicFolder : (byte)LogonFlags.Private,
                OpenFlags  = logonType == LogonType.PublicFolder ? (uint)(OpenFlags.UsePerMDBReplipMapping | OpenFlags.Public) : (uint)OpenFlags.UsePerMDBReplipMapping,

                // Set EssdnSize to 0, which specifies the size of the ESSDN field.
                EssdnSize = logonType == LogonType.PublicFolder ? (ushort)0 : (ushort)Encoding.ASCII.GetByteCount(userDN),
                Essdn     = logonType == LogonType.PublicFolder ? null : Encoding.ASCII.GetBytes(userDN),
            };

            this.responseSOHsValue = this.ProcessSingleRop(logonRequest, insideObjHandle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            logonResponse          = (RopLogonResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, logonResponse.ReturnValue, string.Format("Logon Failed! Error: 0x{0:X8}", logonResponse.ReturnValue));
            }

            return(this.responseSOHsValue[0][logonResponse.OutputHandleIndex]);
        }
Exemplo n.º 4
0
        /// <summary>
        /// This ROP creates a new subfolder.
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="createFolderResponse">The response of this ROP.</param>
        /// <param name="displayName">The name of the created folder. </param>
        /// <param name="comment">The folder comment that is associated with the created folder.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The handle of new folder.</returns>
        private uint RopCreateFolder(uint handle, out RopCreateFolderResponse createFolderResponse, string displayName, string comment, bool needVerify)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;

            RopCreateFolderRequest createFolderRequest = new RopCreateFolderRequest()
            {
                RopId             = (byte)RopId.RopCreateFolder,
                LogonId           = LogonId,
                InputHandleIndex  = (byte)HandleIndex.FirstIndex,
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,
                FolderType        = (byte)FolderType.Genericfolder,
                UseUnicodeStrings = Convert.ToByte(false),
                OpenExisting      = Convert.ToByte(true),
                Reserved          = ReservedValue,
                DisplayName       = Encoding.ASCII.GetBytes(displayName + "\0"),
                Comment           = Encoding.ASCII.GetBytes(comment + "\0")
            };

            this.responseSOHsValue = this.ProcessSingleRop(createFolderRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            createFolderResponse   = (RopCreateFolderResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, createFolderResponse.ReturnValue, string.Format("RopCreateFolder Failed! Error: 0x{0:X8}", createFolderResponse.ReturnValue));
            }

            return(this.responseSOHsValue[0][createFolderResponse.OutputHandleIndex]);
        }
Exemplo n.º 5
0
        /// <summary>
        /// This ROP commits the changes made to a message.
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The response of this ROP.</returns>
        private RopSaveChangesMessageResponse RopSaveChangesMessage(uint handle, bool needVerify)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;

            RopSaveChangesMessageRequest saveChangesMessageRequest = new RopSaveChangesMessageRequest()
            {
                RopId               = (byte)RopId.RopSaveChangesMessage,
                LogonId             = LogonId,
                InputHandleIndex    = (byte)HandleIndex.FirstIndex,
                ResponseHandleIndex = (byte)HandleIndex.SecondIndex,

                // Set the SaveFlags flag to ForceSave, which indicates the client requests server to commit the changes.
                SaveFlags = (byte)SaveFlags.ForceSave,
            };

            this.responseSOHsValue = this.ProcessSingleRop(saveChangesMessageRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            RopSaveChangesMessageResponse saveChangesMessageResponse = (RopSaveChangesMessageResponse)this.responseValue;

            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, saveChangesMessageResponse.ReturnValue, string.Format("RopSaveChangesMessage Failed! Error: 0x{0:X8}", saveChangesMessageResponse.ReturnValue));
            }

            return(saveChangesMessageResponse);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes the test case before running it
        /// </summary>
        protected override void TestInitialize()
        {
            this.Site                 = TestClassBase.BaseTestSite;
            this.oxcrpcAdapter        = this.Site.GetAdapter <IMS_OXCRPCAdapter>();
            this.oxcrpcControlAdapter = this.Site.GetAdapter <IMS_OXCRPCSUTControlAdapter>();

            this.transportIsMAPI = string.Compare(Common.GetConfigurationPropertyValue("TransportSeq", this.Site), "mapi_http", true, System.Globalization.CultureInfo.InvariantCulture) == 0;

            if (!this.transportIsMAPI)
            {
                this.pcbAuxOut        = ConstValues.ValidpcbAuxOut;
                this.pcbOut           = ConstValues.ValidpcbOut;
                this.rgbIn            = new byte[0];
                this.pcxh             = IntPtr.Zero;
                this.pcxhInvalid      = IntPtr.Zero;
                this.pacxh            = IntPtr.Zero;
                this.pulTimeStamp     = 0x00000000;
                this.responseSOHTable = new List <List <uint> >();
                this.response         = null;
                this.objHandle        = 0;
                this.userDN           = Common.GetConfigurationPropertyValue("AdminUserEssdn", this.Site);
                this.userName         = Common.GetConfigurationPropertyValue("AdminUserName", this.Site);
                this.password         = Common.GetConfigurationPropertyValue("AdminUserPassword", this.Site);

                // Holds the value represents USE_PER_MDB_REPLID_MAPPING flag that control the behavior of the RopLogon
                this.userPrivilege = 0x01000000;

                #region Initializes Server and Client based on specific protocol sequence
                this.authenticationLevel   = (uint)Convert.ToInt32(Common.GetConfigurationPropertyValue("RpcAuthenticationLevel", this.Site));
                this.authenticationService = (uint)Convert.ToInt32(Common.GetConfigurationPropertyValue("RPCAuthenticationService", this.Site));
                #endregion
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// This ROP opens an attachment of a message.
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="attachmentId">The identifier of the attachment to be opened. </param>
        /// <param name="openAttachmentResponse">The response of this ROP.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The index of the output handle for the response.</returns>
        private uint RopOpenAttachment(uint handle, uint attachmentId, out RopOpenAttachmentResponse openAttachmentResponse, bool needVerify)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;

            RopOpenAttachmentRequest openAttachmentRequest = new RopOpenAttachmentRequest()
            {
                RopId               = (byte)RopId.RopOpenAttachment,
                LogonId             = LogonId,
                InputHandleIndex    = (byte)HandleIndex.FirstIndex,
                OutputHandleIndex   = (byte)HandleIndex.SecondIndex,
                OpenAttachmentFlags = (byte)OpenAttachmentFlags.ReadWrite,
                AttachmentID        = attachmentId
            };

            this.responseSOHsValue = this.ProcessSingleRop(openAttachmentRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            openAttachmentResponse = (RopOpenAttachmentResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, openAttachmentResponse.ReturnValue, string.Format("RopOpenAttachment Failed! Error: 0x{0:X8}", openAttachmentResponse.ReturnValue));
            }

            return(this.responseSOHsValue[0][openAttachmentResponse.OutputHandleIndex]);
        }
Exemplo n.º 8
0
        /// <summary>
        /// This ROP opens an attachment as a message.
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="openEmbeddedMessageResponse">The response of this ROP.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The index of the output handle of the response.</returns>
        private uint RopOpenEmbeddedMessage(uint handle, out RopOpenEmbeddedMessageResponse openEmbeddedMessageResponse, bool needVerify)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;

            RopOpenEmbeddedMessageRequest openEmbeddedMessageRequest = new RopOpenEmbeddedMessageRequest()
            {
                RopId = (byte)RopId.RopOpenEmbeddedMessage,

                // The logonId 0x00 is associated with RopOpenEmbeddedMessage.
                LogonId = 0x00,

                // This index specifies the location 0x00 in the Server Object Handle Table where the handle for the input Server Object is stored.
                InputHandleIndex = (byte)HandleIndex.FirstIndex,

                // This index specifies the location 0x01 in the Server Object Handle Table where the handle for the output Server Object is stored.
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,
                CodePageId        = 0x0FFF,
                OpenModeFlags     = 0x02
            };

            this.responseSOHsValue      = this.ProcessSingleRop(openEmbeddedMessageRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            openEmbeddedMessageResponse = (RopOpenEmbeddedMessageResponse)this.responseValue;

            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, openEmbeddedMessageResponse.ReturnValue, string.Format("RopOpenEmbeddedMessage Failed! Error: 0x{0:X8}", openEmbeddedMessageResponse.ReturnValue));
            }

            return(this.responseSOHsValue[0][openEmbeddedMessageResponse.OutputHandleIndex]);
        }
Exemplo n.º 9
0
        /// <summary>
        /// This ROP opens an existing message in a mailbox.
        /// </summary>
        /// <param name="handle">The handle to operate</param>
        /// <param name="folderId">The parent folder of the message to be opened.</param>
        /// <param name="messageId">The identifier of the message to be opened.</param>
        /// <param name="openMessageResponse">The response of this ROP.</param>
        /// <param name="needVerify">Whether need to verify the response</param>
        /// <returns>The handle of the opened message</returns>
        private uint RopOpenMessage(uint handle, ulong folderId, ulong messageId, out RopOpenMessageResponse openMessageResponse, bool needVerify)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;

            RopOpenMessageRequest openMessageRequest = new RopOpenMessageRequest()
            {
                RopId             = (byte)RopId.RopOpenMessage,
                LogonId           = LogonId,
                InputHandleIndex  = (byte)HandleIndex.FirstIndex,
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,

                // Set CodePageId to SameAsLogonObject, which indicates it uses the same code page as the one for logon object.
                CodePageId = (ushort)CodePageId.SameAsLogonObject,
                FolderId   = folderId,

                // Set OpenModeFlags to read and write for further operation.
                OpenModeFlags = (byte)MessageOpenModeFlags.ReadWrite,
                MessageId     = messageId
            };

            this.responseSOHsValue = this.ProcessSingleRop(openMessageRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            openMessageResponse    = (RopOpenMessageResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, openMessageResponse.ReturnValue, string.Format("RopOpenMessageResponse Failed! Error: 0x{0:X8}", openMessageResponse.ReturnValue));
            }

            return(this.responseSOHsValue[0][openMessageResponse.OutputHandleIndex]);
        }
Exemplo n.º 10
0
        /// <summary>
        /// This ROP creates a Message object in a mailbox.
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="folderId">This value identifies the parent folder.</param>
        /// <param name="associatedFlag">This flag specifies whether the message is a folder associated information (FAI) message.</param>
        /// <param name="createMessageResponse">The response of this ROP.</param>
        /// <param name="needVerify">Whether need to verify the response</param>
        /// <returns>The handle of the created message.</returns>
        private uint RopCreateMessage(uint handle, ulong folderId, byte associatedFlag, out RopCreateMessageResponse createMessageResponse, bool needVerify)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;

            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest()
            {
                RopId             = (byte)RopId.RopCreateMessage,
                LogonId           = LogonId,
                InputHandleIndex  = (byte)HandleIndex.FirstIndex,
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,
                CodePageId        = (ushort)CodePageId.SameAsLogonObject,
                FolderId          = folderId,
                AssociatedFlag    = associatedFlag
            };

            this.responseSOHsValue = this.ProcessSingleRop(createMessageRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            createMessageResponse  = (RopCreateMessageResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, createMessageResponse.ReturnValue, string.Format("RopCreateMessageResponse Failed! Error: 0x{0:X8}", createMessageResponse.ReturnValue));
            }

            return(this.responseSOHsValue[0][createMessageResponse.OutputHandleIndex]);
        }
Exemplo n.º 11
0
        /// <summary>
        /// This ROP opens an existing folder in a mailbox.
        /// </summary>
        /// <param name="handle">The handle to operate</param>
        /// <param name="openFolderResponse">The response of this ROP</param>
        /// <param name="folderId">The identifier of the folder to be opened.</param>
        /// <param name="needVerify">Whether need to verify the response</param>
        /// <returns>The handle of the opened folder</returns>
        private uint RopOpenFolder(uint handle, out RopOpenFolderResponse openFolderResponse, ulong folderId, bool needVerify)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;

            RopOpenFolderRequest openFolderRequest = new RopOpenFolderRequest()
            {
                RopId             = (byte)RopId.RopOpenFolder,
                LogonId           = LogonId,
                InputHandleIndex  = (byte)HandleIndex.FirstIndex,
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,
                FolderId          = folderId,

                // Open an existing folder with None value for OpenModeFlags flag.
                OpenModeFlags = (byte)FolderOpenModeFlags.None
            };

            this.responseSOHsValue = this.ProcessSingleRop(openFolderRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            openFolderResponse     = (RopOpenFolderResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, openFolderResponse.ReturnValue, string.Format("RopOpenFolderResponse Failed! Error: 0x{0:X8}", openFolderResponse.ReturnValue));
            }

            return(this.responseSOHsValue[0][openFolderResponse.OutputHandleIndex]);
        }
Exemplo n.º 12
0
        protected object transmitPacket(ISerializable request, IDeserializable reply = null)
        {
            MemoryStream stream = new MemoryStream();

            request.Serialize(stream);
            byte[] rawRequest = stream.ToArray();

            if (reply == null)
            {
                DebugWrite("transmit:        ", request);
                spiWrite(rawRequest);
                return(null);
            }
            else
            {
                byte[] rawReply = spiReadWrite(rawRequest);
                stream = new MemoryStream(rawReply);
                reply.Deserialize(stream);

                DebugWrite("received:        ", reply);

                if (!((IValidate)reply).IsValid)
                {
                    throw new CheckSumException();
                }

                return(reply);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// This ROP deletes all messages and subfolders from a folder.
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="wantAsynchronous">This value specifies whether the operation is to be executed asynchronously with status reported via RopProgress.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The response of this ROP.</returns>
        private RopEmptyFolderResponse RopEmptyFolder(uint handle, byte wantAsynchronous, bool needVerify)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;

            RopEmptyFolderRequest emptyFolderRequest = new RopEmptyFolderRequest()
            {
                RopId                = (byte)RopId.RopEmptyFolder,
                LogonId              = LogonId,
                InputHandleIndex     = (byte)HandleIndex.FirstIndex,
                WantAsynchronous     = wantAsynchronous,
                WantDeleteAssociated = Convert.ToByte(true),
            };

            this.responseSOHsValue = this.ProcessSingleRop(emptyFolderRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            RopEmptyFolderResponse emptyFolderResponse = (RopEmptyFolderResponse)this.responseValue;

            if (needVerify)
            {
                Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, emptyFolderResponse.ReturnValue, string.Format("RopEmptyFolder Failed! Error: 0x{0:X8}", emptyFolderResponse.ReturnValue));
            }

            return(emptyFolderResponse);
        }
Exemplo n.º 14
0
 TopicInfo(string messageDependencies, string callerId, string topic, string md5Sum, string type,
           IDeserializable <T>?generator)
 {
     MessageDependencies = messageDependencies;
     CallerId            = callerId;
     Topic          = topic;
     Md5Sum         = md5Sum;
     Type           = type;
     this.generator = generator;
 }
Exemplo n.º 15
0
 public TopicInfo(string callerId, string topic, IDeserializable <T> generator)
     : this(
         BuiltIns.DecompressDependencies(generator.GetType()),
         callerId, topic,
         BuiltIns.GetMd5Sum(generator.GetType()),
         BuiltIns.GetMessageType(generator.GetType()),
         generator
         )
 {
 }
Exemplo n.º 16
0
        public Saver(List <Employe> plant) //Hidden initialization
        {
            SerializationFlag = new SetGetSerialezationMethod();
            switch (SerializationFlag.SerialezationMethod)
            {
            case Enums.SerializationMethods.xml:
                Serializator = new XMLSerializator(plant);
                break;

            case Enums.SerializationMethods.bin:
            default:
                Serializator = new BinarySerializator(plant);
                break;
            }

            //string[] filesListWithPath = Directory.GetFiles(Directory.GetCurrentDirectory());
            string[]      filesListWithPath = Directory.GetFiles(@"C:\Users\salischev.a\Documents\Visual Studio 2015\Projects\EmployesDB\EmployesDB\bin\Debug\");
            List <string> fileList          = new List <string>();

            foreach (string item in filesListWithPath)
            {
                fileList.Add(Path.GetFileName(item));
            }

            string dbFile = null;

            foreach (string fileName in fileList)
            {
                if (fileName.ToLower().Contains("plant"))
                {
                    dbFile = fileName;
                    DBName = dbFile;
                }
            }
            if (dbFile != null)
            {
                IsDBExist = true;
                string[] splittingDBFile = dbFile.Split('.');
                if (splittingDBFile.Length == 2)
                {
                    switch (splittingDBFile[1].ToLower())
                    {
                    case "dat":
                        Deserializator = new BinaryDeserializator();
                        break;

                    case "xml":
                    default:
                        Deserializator = new XMLDeserializator();
                        break;
                    }
                }
            }
        }
Exemplo n.º 17
0
        public void deSerialize(RWStream file)
        {
            int             size  = file.ReadInt32();
            var             bData = file.ReadBytes(size);
            RWStream        data  = new RWStream(bData);
            IDeserializable Iself = this;

            while (data.Position < data.Length)
            {
                Utilities.ReadProperty(ref data, Iself);
            }
        }
Exemplo n.º 18
0
 public static void Read(this BitReader @this, IDeserializable serializable)
 {
     if (@this == null)
     {
         throw new ArgumentNullException(nameof(@this),
                                         Resources.ResourceStrings.BitReader_Read_NullReaderException);
     }
     if (serializable == null)
     {
         throw new ArgumentNullException(nameof(serializable),
                                         Resources.ResourceStrings.BitReader_Read_NullSerializableException);
     }
     serializable.Deserialize(@this);
 }
        public void deSerialize(Stream file)
        {
            int size = Functions.readInt32FromFile(file);

            byte[] bData = new byte[size];
            file.Read(bData, 0, size);
            MemoryStream    data  = new MemoryStream(bData);
            IDeserializable Iself = this;

            while (data.Position < data.Length)
            {
                Functions.readProperty(data, Iself);
            }
        }
Exemplo n.º 20
0
        public void deSerialize(RWStream file)
        {
            var size  = file.ReadInt32();
            var bData = new byte[size]; file.Position += 4;

            Utilities.ReadStringFromFile(ref file); file.Position += 4;
            bData = file.ReadBytes(size);;
            var             data  = new RWStream(bData);
            IDeserializable Iself = this;

            while (data.Position < data.Length)
            {
                Utilities.ReadProperty(ref data, Iself);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// This ROP releases all resources associated with a server object.
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        private void RopRelease(uint handle)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;

            RopReleaseRequest releaseRequest = new RopReleaseRequest()
            {
                RopId            = (byte)RopId.RopRelease,
                LogonId          = LogonId,
                InputHandleIndex = (byte)HandleIndex.FirstIndex
            };

            // The RopRelease ROP doesn't return response from server.
            this.responseSOHsValue = this.ProcessSingleRop(releaseRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
        }
Exemplo n.º 22
0
        public object GetDeserializableFileObject(string name, Type type, bool cacheResults, string mediaType)
        {
            object obj = null;

            // PERF: Whole cache is locked while loading a single item. Should use finer granularity
            lock (Cache)
            {
                obj = Cache[name];

                if (obj == null)
                {
                    using (var stream = new FileStream(Server.MapPath(name), FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        ConstructorInfo constructorInfoObj = type.GetConstructor(
                            BindingFlags.Instance | BindingFlags.Public, null,
                            CallingConventions.HasThis, new Type[0], null);

                        if (constructorInfoObj == null)
                        {
                            throw new TargetException();
                        }

                        obj = constructorInfoObj.Invoke(null);

                        IDeserializable ides = obj as IDeserializable;
                        if (ides == null)
                        {
                            throw new TargetException();
                        }

                        ides.Deserialize(stream, mediaType);
                    }

                    if (cacheResults)
                    {
                        Cache[name] = obj;
                    }
                }
            }

            if (obj.GetType() != type)
            {
                throw new InvalidOperationException("Object is of the wrong type.");
            }

            return(obj);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Method which executes single ROP.
        /// </summary>
        /// <param name="ropRequest">ROP request objects.</param>
        /// <param name="inputObjHandle">Server object handle in request.</param>
        /// <param name="response">ROP response objects.</param>
        /// <param name="rawData">The ROP response payload.</param>
        /// <param name="expectedRopResponseType">ROP response type expected.</param>
        /// <returns>Server objects handles in response.</returns>
        public List <List <uint> > ProcessSingleRop(
            ISerializable ropRequest,
            uint inputObjHandle,
            ref IDeserializable response,
            ref byte[] rawData,
            RopResponseType expectedRopResponseType)
        {
            uint returnValue;
            List <List <uint> > responseSOHs = this.ProcessSingleRopWithReturnValue(ropRequest, inputObjHandle, ref response, ref rawData, expectedRopResponseType, out returnValue);

            if (returnValue == 1726)
            {
                Site.Assert.AreEqual <RopResponseType>(RopResponseType.RPCError, expectedRopResponseType, "Unexpected RPC error {0} occurred.", returnValue);
            }

            return(responseSOHs);
        }
Exemplo n.º 24
0
        public void Response(ulong messageId, IResponseMessage responseMessage, IDeserializable singleDeserializable)
        {
            if (_acks.TryGetValue(messageId, out var responseCallback))
            {
                var success = false;
                lock (_lockAcks) {
                    success = _acks.Remove(messageId);
                }

                if (success)
                {
                    responseCallback?.Invoke(responseMessage, singleDeserializable);
                }
                else
                {
                    Logger.Warn($"删除{nameof(messageId)} = {messageId}失败!");
                }
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Deserialize input bytes indicated by ropBytes into a list of ROPs indicated by ropList
        /// </summary>
        /// <param name="ropBytes">The bytes need to be deserialized</param>
        /// <param name="ropList">The ROPs list deserialized into</param>
        public static void Deserialize(byte[] ropBytes, ref IDeserializable ropList)
        {
            int index = 0;
            if (index < ropBytes.Length)
            {
                int ropId = ropBytes[index];

                // Deserialize to a rop
                // Renew every response before deserialize.
                Type type  = maps[ropId].GetType();
                maps[ropId] = (IDeserializable)type.InvokeMember("new", System.Reflection.BindingFlags.CreateInstance, null, null, null);

                int desBytes = maps[ropId].Deserialize(ropBytes, index);

                // Add deserialized rop into rop list
                ropList = maps[ropId];
                index += desBytes;
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Deserialize input bytes indicated by ropBytes into a list of ROPs indicated by ropList
        /// </summary>
        /// <param name="ropBytes">The bytes need to be deserialized</param>
        /// <param name="ropList">The ROPs list deserialized into</param>
        public static void Deserialize(byte[] ropBytes, ref IDeserializable ropList)
        {
            int index = 0;

            if (index < ropBytes.Length)
            {
                int ropId = ropBytes[index];

                // Deserialize to a rop
                // Renew every response before deserialize.
                Type type = maps[ropId].GetType();
                maps[ropId] = (IDeserializable)type.InvokeMember("new", System.Reflection.BindingFlags.CreateInstance, null, null, null);

                int desBytes = maps[ropId].Deserialize(ropBytes, index);

                // Add deserialized rop into rop list
                ropList = maps[ropId];
                index  += desBytes;
            }
        }
Exemplo n.º 27
0
        public static object Deserialize(IDeserializable source)
        {
            ExceptionHelper.ThrowIfArgumentNull(source, "source");
            object result = CreateInstance(source.AssemblyName, source.TypeName);

            {
                using (SerializableObject serializableObject = new SerializableObject(result))
                {
                    DeserializableMemberList members = source.DeserializableMembers;
                    if (members != null && members.Count > 0)
                    {
                        foreach (DeserializableMember member in members)
                        {
                            serializableObject[member.Name] = member.Value;
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 28
0
        /// <summary>
        /// 根据类型反序列化,会通过反射创建对象,并将其返回
        /// </summary>
        /// <returns></returns>
        internal object _Deserialize(MyStream stream, Type type)
        {
            if (!deserializeMap.ContainsKey(type))
            {
                throw new Exception("Type has not been regist : " + type);
            }

            if (typeof(ISerObj).IsAssignableFrom(type))
            {
                object          result = type.Assembly.CreateInstance(type.FullName);
                IDeserializable des    = deserializeMap[type];
                des.Deserialize(stream, result);
                return(result);
            }
            else
            {
                DeserializeCell des = deserializeMap[type] as DeserializeCell;
                return(des.GetDeserializeValue(stream));
            }
        }
Exemplo n.º 29
0
        public void Response(ulong messageId, IResponseMessage responseMessage,
                             IDeserializable singleDeserializable)
        {
            if (messageId == 0)
            {
                return;
            }

            foreach (var item in _acks)
            {
                Logger.Debug(item.Key);
            }
            if (_acks.TryRemove(messageId, out var responseCallback))
            {
                responseCallback?.Invoke(responseMessage, singleDeserializable);
            }
            else
            {
                Logger.Error($"删除 {nameof(messageId)} = {messageId}失败!");
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// This ROP deletes a folder and its contents.
        /// </summary>
        /// <param name="handle">The handle of the folder to be deleted.</param>
        /// <param name="folderId">The Id of the folder to be deleted.</param>
        /// <returns>The response of this ROP</returns>
        private RopDeleteFolderResponse RopDeleteFolder(uint handle, ulong folderId)
        {
            this.rawDataValue      = null;
            this.responseValue     = null;
            this.responseSOHsValue = null;

            RopDeleteFolderRequest deleteFolderRequest = new RopDeleteFolderRequest()
            {
                RopId             = (byte)RopId.RopDeleteFolder,
                LogonId           = LogonId,
                InputHandleIndex  = (byte)HandleIndex.FirstIndex,
                DeleteFolderFlags = 0x15,
                FolderId          = folderId,
            };

            this.responseSOHsValue = this.ProcessSingleRop(deleteFolderRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            RopDeleteFolderResponse deleteFolderResponse = (RopDeleteFolderResponse)this.responseValue;

            this.Site.Assert.IsNotNull(deleteFolderResponse, string.Format("RopDeleteFolderResponse Failed! Error: 0x{0:X8}", deleteFolderResponse.ReturnValue));
            return(deleteFolderResponse);
        }
Exemplo n.º 31
0
        /// <summary>
        /// This ROP creates a new subfolder. 
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="createFolderResponse">The response of this ROP.</param>
        /// <param name="displayName">The name of the created folder. </param>
        /// <param name="comment">The folder comment that is associated with the created folder.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The handle of new folder.</returns>
        private uint RopCreateFolder(uint handle, out RopCreateFolderResponse createFolderResponse, string displayName, string comment, bool needVerify)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;

            RopCreateFolderRequest createFolderRequest = new RopCreateFolderRequest()
            {
                RopId = (byte)RopId.RopCreateFolder,
                LogonId = LogonId,
                InputHandleIndex = (byte)HandleIndex.FirstIndex,
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,
                FolderType = (byte)FolderType.Genericfolder,
                UseUnicodeStrings = Convert.ToByte(false),
                OpenExisting = Convert.ToByte(true),
                Reserved = ReservedValue,
                DisplayName = Encoding.ASCII.GetBytes(displayName + "\0"),
                Comment = Encoding.ASCII.GetBytes(comment + "\0")
            };

            this.responseSOHsValue = this.ProcessSingleRop(createFolderRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            createFolderResponse = (RopCreateFolderResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, createFolderResponse.ReturnValue, string.Format("RopCreateFolder Failed! Error: 0x{0:X8}", createFolderResponse.ReturnValue));
            }

            return this.responseSOHsValue[0][createFolderResponse.OutputHandleIndex];
        }
 /// <summary>
 /// The method EcDoRpcExt2 passes generic remote operation (ROP) commands to the server for processing within a Session Context. Each call can contain multiple ROP commands. 
 /// </summary>
 /// <param name="pcxh">The unique value points to a CXH.</param>
 /// <param name="pulFlags">Flags that tell the server how to build the rgbOut parameter.</param>
 /// <param name="rgbIn">This buffer contains the ROP request payload. </param>
 /// <param name="pcbOut">On input, this parameter contains the maximum size of the rgbOut buffer. On output, this parameter contains the size of the ROP response payload.</param>
 /// <param name="rgbAuxIn">This parameter contains an auxiliary payload buffer. </param>
 /// <param name="pcbAuxOut">On input, this parameter contains the maximum length of the rgbAuxOut buffer. On output, this parameter contains the size of the data to be returned in the rgbAuxOut buffer.</param>
 /// <param name="response">The ROP response returned in this RPC method and parsed by adapter.</param>
 /// <param name="responseSOHTable">The Response SOH Table returned by ROP call, provides information like object handle.</param>
 /// <returns>If success, it returns 0, else returns the error code specified in the Open Specification.</returns>
 public uint EcDoRpcExt2(
     ref IntPtr pcxh,
     PulFlags pulFlags, 
     byte[] rgbIn,
     ref uint pcbOut,
     byte[] rgbAuxIn,
     ref uint pcbAuxOut,
     out IDeserializable response,
     ref List<List<uint>> responseSOHTable)
 {
     byte[] rgbOut = new byte[pcbOut];
     byte[] rgbAuxOut = new byte[pcbAuxOut];
     uint payloadCount = 0;
     return this.EcDoRpcExt2(ref pcxh, pulFlags, rgbIn, ref rgbOut, ref pcbOut, rgbAuxIn, ref pcbAuxOut, out response, ref responseSOHTable, out payloadCount, ref rgbAuxOut);
 }
        /// <summary>
        /// The method EcDoRpcExt2 passes generic remote operation (ROP) commands to the server for processing within a Session Context. Each call can contain multiple ROP commands. 
        /// </summary>
        /// <param name="pcxh">The unique value to be used as a CXH</param>
        /// <param name="pulFlags">Flags that tell the server how to build the rgbOut parameter.</param>
        /// <param name="rgbIn">This buffer contains the ROP request payload. </param>
        /// <param name="rgbOut">On Output, this parameter contains the response payload.</param>
        /// <param name="pcbOut">On Output, this parameter contains the size of response payload.</param>
        /// <param name="rgbAuxIn">This parameter contains an auxiliary payload buffer. </param>
        /// <param name="pcbAuxOut">On input, this parameter contains the maximum length of the rgbAuxOut buffer. On output, this parameter contains the size of the data to be returned in the rgbAuxOut buffer.</param>
        /// <param name="response">The ROP response returned in this RPC method and parsed by adapter.</param>
        /// <param name="responseSOHTable">The Response SOH Table returned by ROP call, provides information like object handle.</param>
        /// <param name="payloadCount">The count of payload that ROP response contains.</param>
        /// <param name="rgbAuxOut">The data of the output buffer rgbAuxOut. </param>
        /// <returns>If success, it return 0, else return the error code.</returns>
        public uint EcDoRpcExt2(
            ref IntPtr pcxh,
            PulFlags pulFlags,
            byte[] rgbIn, 
            ref byte[] rgbOut,
            ref uint pcbOut,
            byte[] rgbAuxIn, 
            ref uint pcbAuxOut,
            out IDeserializable response,
            ref List<List<uint>> responseSOHTable,
            out uint payloadCount,
            ref byte[] rgbAuxOut)
        {
            #region Variables
            uint inputPcbOutValue = pcbOut;
            uint inputPcbAuxOutValue = pcbAuxOut;
            IntPtr pcxhInput = pcxh;
            int pcxhValue = pcxh.ToInt32();
            uint flags = (uint)pulFlags;
            payloadCount = 0;
            uint returnValue = 0;
            uint pulTransTime;
            uint inputROPSize = 0;
            if (rgbIn != null)
            {
                inputROPSize = (uint)rgbIn.Length;
            }
            else
            {
                rgbIn = new byte[0];
            }

            uint inputAuxSize = 0;
            if (rgbAuxIn != null)
            {
                inputAuxSize = (uint)rgbAuxIn.Length;
            }
            else
            {
                rgbAuxIn = new byte[0];
            }

            rgbOut = new byte[pcbOut];
            response = null;
            #endregion

            IntPtr rgbInPtr = Marshal.AllocHGlobal(rgbIn.Length);
            IntPtr rgbAuxInPtr = Marshal.AllocHGlobal(rgbAuxIn.Length);

            try
            {
                Marshal.Copy(rgbIn, 0, rgbInPtr, rgbIn.Length);
                Marshal.Copy(rgbAuxIn, 0, rgbAuxInPtr, rgbAuxIn.Length);

                // Record whether the server is busy and needs to retry later.
                bool needRetry = false;
                int retryCount = 0;
                int maxRetryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
                do
                {
                    IntPtr rgbOutPtr = Marshal.AllocHGlobal((int)pcbOut);
                    IntPtr rgbAuxOutPtr = Marshal.AllocHGlobal((int)pcbAuxOut);

                    needRetry = false;
                    returnValue = NativeMethods.EcDoRpcExt2(
                        ref pcxhInput,
                        ref flags,
                        rgbInPtr,
                        inputROPSize,
                        rgbOutPtr,
                        ref pcbOut,
                        rgbAuxInPtr,
                        inputAuxSize,
                        rgbAuxOutPtr,
                        ref pcbAuxOut,
                        out pulTransTime);

                    rgbOut = new byte[(int)pcbOut];
                    Marshal.Copy(rgbOutPtr, rgbOut, 0, (int)pcbOut);
                    Marshal.FreeHGlobal(rgbOutPtr);

                    rgbAuxOut = new byte[(int)pcbAuxOut];
                    Marshal.Copy(rgbAuxOutPtr, rgbAuxOut, 0, (int)pcbAuxOut);
                    Marshal.FreeHGlobal(rgbAuxOutPtr);

                    #region Verify requirements while EcDoRpcExt2 success

                    if (returnValue == 0 && pcbOut > 0)
                    {
                        RPC_HEADER_EXT[] rpcHeaderExts;
                        byte[][] rops;
                        uint[][] serverHandleObjectsTables;

                        byte[] rawData = new byte[pcbOut];
                        Array.Copy(rgbOut, rawData, pcbOut);
                        int size;
                        int actualSize;
                        int payLoadSizeCount = 0;
                        int payLoadActualSizeCount = 0;
                        short flag;
                        bool isCompressed = false;
                        List<byte> actualData = new List<byte>();
                        List<short> flagValuesBeforeDecompressing = new List<short>();

                        #region Decompress or revert rgbOut if it is compressed or obfuscated
                        do
                        {
                            flag = BitConverter.ToInt16(rawData, payLoadSizeCount + ConstValues.RpcHeaderExtVersionByteSize);
                            flagValuesBeforeDecompressing.Add(flag);
                            size = BitConverter.ToInt16(rawData, payLoadSizeCount + ConstValues.RpcHeaderExtVersionByteSize + ConstValues.RpcHeaderExtFlagsByteSize);
                            actualSize = BitConverter.ToInt16(rawData, payLoadSizeCount + ConstValues.RpcHeaderExtVersionByteSize + ConstValues.RpcHeaderExtFlagsByteSize + ConstValues.RpcHeaderExtSizeByteSize);
                            byte[] resultByte = new byte[actualSize + AdapterHelper.RPCHeaderExtlength];
                            Array.Copy(rawData, payLoadSizeCount, resultByte, 0, size + AdapterHelper.RPCHeaderExtlength);

                            // Compressed (0x00000001) means the data that follows the RPC_HEADER_EXT is compressed. 
                            if ((flag & (short)RpcHeaderExtFlags.Compressed) == (short)RpcHeaderExtFlags.Compressed)
                            {
                                isCompressed = true;
                                byte[] rgbOriOut = new byte[size + AdapterHelper.RPCHeaderExtlength];
                                Array.Copy(rawData, payLoadSizeCount, rgbOriOut, 0, size + AdapterHelper.RPCHeaderExtlength);
                                bool decompressResult = false;
                                try
                                {
                                    resultByte = Common.DecompressStream(rgbOriOut);
                                    decompressResult = true;
                                }
                                catch (ArgumentException)
                                {
                                    decompressResult = false;
                                }
                                catch (InvalidOperationException)
                                {
                                    decompressResult = false;
                                }

                                this.VerifyCompressionAlgorithm(decompressResult, false, false, flag);
                                this.VerifyDIRECT2EncodingAlgorithm(decompressResult);
                            }

                            // XorMagic(0x00000002) means that the data follows the RPC_HEADER_EXT has been obfuscated.
                            if ((flag & (short)RpcHeaderExtFlags.XorMagic) == (short)RpcHeaderExtFlags.XorMagic)
                            {
                                byte[] rgbXorOut = null;
                                byte[] rgbOriOut = new byte[size + AdapterHelper.RPCHeaderExtlength];
                                Array.Copy(rawData, payLoadSizeCount, rgbOriOut, 0, size + AdapterHelper.RPCHeaderExtlength);

                                // According to the Open Specification, every byte of the data to be obfuscated has XOR applied with the value 0xA5.
                                bool obfuscationResult = false;
                                rgbXorOut = Common.XOR(rgbOriOut);
                                if (rgbXorOut != null)
                                {
                                    obfuscationResult = true;
                                }

                                Array.Copy(rawData, payLoadSizeCount, resultByte, 0, AdapterHelper.RPCHeaderExtlength);
                                Array.Copy(rgbXorOut, 8, resultByte, AdapterHelper.RPCHeaderExtlength, actualSize);

                                // The first false means current method is EcDoRpcExt2
                                // The second false means current field is rgbOut
                                this.VerifyObfuscationAlgorithm(obfuscationResult, false, false, flag);
                            }

                            actualData.AddRange(resultByte);
                            payLoadSizeCount += size + AdapterHelper.RPCHeaderExtlength;
                            payLoadActualSizeCount += actualSize + AdapterHelper.RPCHeaderExtlength;
                        }
                        while ((flag & (short)RpcHeaderExtFlags.Last) != (short)RpcHeaderExtFlags.Last);
                        rgbOut = actualData.ToArray();
                        #endregion

                        #region Resize rgbOut
                        if (rgbOut != null)
                        {
                            if (isCompressed)
                            {
                                Array.Resize<byte>(ref rgbOut, payLoadActualSizeCount + 1);
                            }
                            else
                            {
                                Array.Resize<byte>(ref rgbOut, (int)pcbOut);
                            }
                        }
                        #endregion

                        this.ParseResponseBuffer(rgbOut, out rpcHeaderExts, out rops, out serverHandleObjectsTables);

                        #region Verify RPC_HEADER_EXTs in rgbOut buffer

                        for (int i = 0; i < rpcHeaderExts.Length; i++)
                        {
                            this.VerifyRPCHeaderExt(flagValuesBeforeDecompressing, rpcHeaderExts[i], false, false, i == rpcHeaderExts.Length - 1);
                        }

                        this.VerifyMultiRPCHeader(rpcHeaderExts.Length);

                        #endregion

                        #region Deserialize Rops

                        List<IDeserializable> responseRops = new List<IDeserializable>();

                        int ropID = 0;
                        if (rops != null)
                        {
                            // Verify the length of payload in the rgbOut
                            this.VerifyPayloadLengthResponse(rops);

                            // Only contains one ROP response
                            if (rops.Length == 1)
                            {
                                ropID = rops[0][0];
                                if (ropID == (int)RopId.RopBackoff)
                                {
                                    needRetry = true;

                                    // Revert the value of variables whose type is a reference type and used by method EcDoRpcExt2.
                                    pcxh = pcxhInput;
                                    flags = (uint)pulFlags;
                                    pcbOut = inputPcbOutValue;
                                    pcbAuxOut = inputPcbAuxOutValue;

                                    // Wait a period of time before retrying since the server is busy now.
                                    System.Threading.Thread.Sleep(int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site)));
                                    retryCount++;
                                    continue;
                                }
                                
                                IDeserializable ropRes = null;
                                RopDeserializer.Deserialize(rops[0], ref ropRes);
                                payloadCount = 1;

                                // True means RopDeserializer.Deserialize method is successful(Because there is no exception thrown and code can arrive here).
                                // 1 means one ROP response
                                this.VerifyIsRopResponse(true, 1);
                                responseRops.Add(ropRes);
                            }
                            else
                            {
                                // Contains more than one ROP response
                                ropID = rops[0][0];
                                foreach (byte[] rop in rops)
                                {
                                    if (rop[0] == (byte)RopId.RopBackoff)
                                    {
                                        needRetry = true;

                                        // Revert the value of variables whose type is a reference type and used by method EcDoRpcExt2.
                                        pcxh = pcxhInput;
                                        flags = (uint)pulFlags;
                                        pcbOut = inputPcbOutValue;
                                        pcbAuxOut = inputPcbAuxOutValue;

                                        // Wait a period of time before retrying since the server is busy now.
                                        System.Threading.Thread.Sleep(int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site)));
                                        retryCount++;
                                        break;
                                    }

                                    IDeserializable ropRes = null;
                                    RopDeserializer.Deserialize(rop, ref ropRes);
                                    payloadCount = (uint)rops.Length;

                                    // True means RopDeserializer.Deserialize method is successful(Because there is no exception thrown and code can arrive here).
                                    this.VerifyIsRopResponse(true, rops.Length);
                                    switch (rop[0])
                                    {
                                        // RopReadStream Response Buffer.
                                        case (int)RopId.RopReadStream:
                                            RopReadStreamResponse readStreamResponse = (RopReadStreamResponse)ropRes;
                                            responseRops.Add(readStreamResponse);
                                            break;

                                        // RopQueryRows Response Buffer.
                                        case (int)RopId.RopQueryRows:
                                            RopQueryRowsResponse queryRowsResponse = (RopQueryRowsResponse)ropRes;
                                            responseRops.Add(queryRowsResponse);
                                            break;

                                        // RopFastTransferSourceGetBuffer Response Buffer.
                                        case (int)RopId.RopFastTransferSourceGetBuffer:
                                            RopFastTransferSourceGetBufferResponse bufferResponse = (RopFastTransferSourceGetBufferResponse)ropRes;
                                            responseRops.Add(bufferResponse);
                                            break;
                                        default:
                                            throw new InvalidCastException("The returned ROP ID is {0}.", ropID);
                                    }
                                }

                                switch (ropID)
                                {
                                    // RopReadStream Response Buffer.
                                    case (int)RopId.RopReadStream:
                                        for (int i = 0; i < responseRops.Count; i++)
                                        {
                                            for (int j = i + 1; j < responseRops.Count; j++)
                                            {
                                                RopReadStreamResponse readStreamResponse0 = (RopReadStreamResponse)responseRops[i];
                                                RopReadStreamResponse readStreamResponse1 = (RopReadStreamResponse)responseRops[j];
                                                this.VerifyRopReadStreamResponse(readStreamResponse0.DataSize, readStreamResponse1.DataSize, responseRops.Count);
                                            }
                                        }

                                        break;

                                    // RopQueryRows Response Buffer.
                                    case (int)RopId.RopQueryRows:
                                        for (int i = 0; i < responseRops.Count; i++)
                                        {
                                            for (int j = i + 1; j < responseRops.Count; j++)
                                            {
                                                RopQueryRowsResponse queryRowsResponse0 = (RopQueryRowsResponse)responseRops[i];
                                                RopQueryRowsResponse queryRowsResponse1 = (RopQueryRowsResponse)responseRops[j];
                                                this.VerifyRopQueryRowsResponse(queryRowsResponse0.RowCount, queryRowsResponse1.RowCount, responseRops.Count);
                                            }
                                        }

                                        break;

                                    // RopFastTransferSourceGetBuffer Response Buffer.
                                    case (int)RopId.RopFastTransferSourceGetBuffer:
                                        this.VerifyRopFastTransferSourceGetBufferResponse(responseRops.Count);
                                        break;
                                    default:
                                        throw new InvalidCastException("The returned ROP ID is {0}.", ropID);
                                }
                            }

                            if (responseRops != null)
                            {
                                if (responseRops.Count > 0)
                                {
                                    response = responseRops[0];
                                }
                            }
                            else
                            {
                                response = null;
                            }
                        }

                        #endregion

                        #region Deserialize SOH

                        if (needRetry)
                        {
                            continue;
                        }

                        responseSOHTable = new List<List<uint>>();

                        // Deserialize serverHandleObjectsTables
                        if (serverHandleObjectsTables != null)
                        {
                            foreach (uint[] serverHandleObjectsTable in serverHandleObjectsTables)
                            {
                                List<uint> serverHandleObjectList = new List<uint>();
                                foreach (uint serverHandleObject in serverHandleObjectsTable)
                                {
                                    serverHandleObjectList.Add(serverHandleObject);
                                }

                                responseSOHTable.Add(serverHandleObjectList);
                            }
                        }

                        #endregion

                        #region Parse rgbAuxOut

                        #region Capture code

                        #region Verify rgbAuxOut
                        this.VerifyIsRgbSupportedOnEcDoRpcExt2(pcbAuxOut);

                        List<short> flagValues = new List<short>();

                        if (pcbAuxOut != 0)
                        {
                            isCompressed = false;

                            // Decompress or revert if the rgbAuxOut is compressed or obfuscated
                            flag = BitConverter.ToInt16(rgbAuxOut, ConstValues.RpcHeaderExtVersionByteSize);
                            size = BitConverter.ToInt16(rgbAuxOut, ConstValues.RpcHeaderExtFlagsByteSize + ConstValues.RpcHeaderExtSizeByteSize) + AdapterHelper.RPCHeaderExtlength;
                            actualSize = BitConverter.ToInt16(rgbAuxOut, ConstValues.RpcHeaderExtSizeByteSize + ConstValues.RpcHeaderExtFlagsByteSize + ConstValues.RpcHeaderExtVersionByteSize) + AdapterHelper.RPCHeaderExtlength;
                            flagValues.Add(flag);

                            // Decompress or revert rgbAuxOut if it is compressed or obfuscated
                            // Compressed (0x00000001) means the data that follows the RPC_HEADER_EXT is compressed.
                            if ((flag & (short)RpcHeaderExtFlags.Compressed) == (short)RpcHeaderExtFlags.Compressed)
                            {
                                isCompressed = true;
                                byte[] rgbOriAuxOut = new byte[size];
                                Array.Copy(rgbAuxOut, 0, rgbOriAuxOut, 0, size);
                                bool decompressResult = false;
                                try
                                {
                                    rgbAuxOut = Common.DecompressStream(rgbOriAuxOut);
                                    decompressResult = true;
                                }
                                catch (ArgumentException)
                                {
                                    decompressResult = false;
                                }
                                catch (InvalidOperationException)
                                {
                                    decompressResult = false;
                                }

                                // False means current method is EcDoRpcExt2
                                // True means current field is rgbAuxOut
                                this.VerifyCompressionAlgorithm(decompressResult, false, true, flag);
                                this.VerifyDIRECT2EncodingAlgorithm(decompressResult);
                            }

                            // XorMagic(0x00000002) means that the data follows the RPC_HEADER_EXT has been obfuscated.
                            if ((flag & (short)RpcHeaderExtFlags.XorMagic) == (short)RpcHeaderExtFlags.XorMagic)
                            {
                                byte[] rgbXorAuxOut = null;
                                byte[] rgbOriAuxOut = new byte[size];
                                Array.Copy(rgbAuxOut, AdapterHelper.RPCHeaderExtlength, rgbOriAuxOut, 0, size);

                                // Every byte of the data to be obfuscated has XOR applied with the value 0xA5.
                                bool obfuscationResult = false;
                                rgbXorAuxOut = Common.XOR(rgbOriAuxOut);
                                if (rgbXorAuxOut != null)
                                {
                                    obfuscationResult = true;
                                }

                                Array.Copy(rgbXorAuxOut, 0, rgbAuxOut, AdapterHelper.RPCHeaderExtlength, size - AdapterHelper.RPCHeaderExtlength);
                                this.VerifyObfuscationAlgorithm(obfuscationResult, false, true, flag);
                            }

                            if (rgbAuxOut != null)
                            {
                                if (isCompressed)
                                {
                                    Array.Resize<byte>(ref rgbAuxOut, actualSize);
                                }
                                else
                                {
                                    Array.Resize<byte>(ref rgbAuxOut, (int)pcbAuxOut);
                                }
                            }
                            #region Verify RPC header
                            ExtendedBuffer[] buffer = ExtractExtendedBuffer(rgbAuxOut);
                            this.VerifyRPCHeaderExt(flagValues, buffer[0].Header, false, true, true);
                            #endregion
                            List<AUX_SERVER_TOPOLOGY_STRUCTURE> rgbAuxOutValue = this.ParseRgbAuxOut(rgbAuxOut);
                            this.VerifyRgbAuxOutOnEcDoRpcExt2(rgbAuxOutValue);
                        }
                        #endregion

                        #endregion Capture code

                        #endregion
                    }

                    // Verify method EcDoRpcExt2.
                    this.VerifyEcDoRpcExt2(pcxhValue, pcxhInput.ToInt32(), pcbOut, pcbAuxOut, inputPcbOutValue, rgbOut, inputPcbAuxOutValue, rgbAuxOut, returnValue, (uint)pulFlags, flags);
                    #endregion
                }
                while (needRetry && retryCount < maxRetryCount);
                if (needRetry && retryCount == maxRetryCount)
                {
                    Site.Assert.Fail("Server is still busy after retrying {0} times which is defined in the common configuration file and the returned ROP is RopBackOff.", retryCount);
                }
            }
            catch (SEHException e)
            {
                // Uses try...catch... code structure to get the error code of RPC call
                returnValue = NativeMethods.RpcExceptionCode(e);

                Site.Log.Add(LogEntryKind.Comment, "EcDoRpcExt2 throws exception, system error code is {0}, the error message is: {1}", returnValue, (new Win32Exception((int)returnValue)).ToString());
            }
            finally
            {
                Marshal.FreeHGlobal(rgbInPtr);
                Marshal.FreeHGlobal(rgbAuxInPtr);
            }

            return returnValue;
        }
        /// <summary>
        /// Method which executes single ROP with multiple server objects.
        /// </summary>
        /// <param name="ropRequest">ROP request object.</param>
        /// <param name="inputObjHandles">Server object handles in request.</param>
        /// <param name="response">ROP response object.</param>
        /// <param name="rawData">The ROP response payload.</param>
        /// <param name="expectedRopResponseType">ROP response type expected.</param>
        /// <returns>Server objects handles in response.</returns>
        public List<List<uint>> ProcessSingleRopWithMutipleServerObjects(
            ISerializable ropRequest,
            List<uint> inputObjHandles,
            ref IDeserializable response,
            ref byte[] rawData,
            RopResponseType expectedRopResponseType)
        {
            List<ISerializable> requestRops = new List<ISerializable>
            {
                ropRequest
            };

            List<uint> requestSOH = new List<uint>();
            for (int i = 0; i < inputObjHandles.Count; i++)
            {
                requestSOH.Add(inputObjHandles[i]);
            }

            if (Common.IsOutputHandleInRopRequest(ropRequest))
            {
                 // Add an element for server output object handle, set default value to 0xFFFFFFFF
                requestSOH.Add(DefaultOutputHandle);
            }

            List<IDeserializable> responseRops = new List<IDeserializable>();
            List<List<uint>> responseSOHs = new List<List<uint>>();

            uint ret = this.RopCall(requestRops, requestSOH, ref responseRops, ref responseSOHs, ref rawData, MaxRgbOut);
            if (ret != OxcRpcErrorCode.ECNone)
            {
                Site.Assert.AreEqual<RopResponseType>(RopResponseType.RPCError, expectedRopResponseType, "Unexpected RPC error {0} occurred.", ret);
                return responseSOHs;
            }

            if (responseRops != null)
            {
                if (responseRops.Count > 0)
                {
                    response = responseRops[0];
                }
            }
            else
            {
                response = null;
            }

            if (ropRequest.GetType() == typeof(RopReleaseRequest))
            {
                return responseSOHs;
            }

            try
            {
                this.VerifyAdapterCaptureCode(expectedRopResponseType, response, ropRequest);
            }
            catch (TargetInvocationException invocationEx)
            {
                Site.Log.Add(LogEntryKind.Debug, invocationEx.Message);
                if (invocationEx.InnerException != null)
                {
                    throw invocationEx.InnerException;
                }
            }
            catch (NullReferenceException nullEx)
            {
                Site.Log.Add(LogEntryKind.Debug, nullEx.Message);
            }

            return responseSOHs;
        }
Exemplo n.º 35
0
        /// <summary>
        /// This ROP creates a Message object in a mailbox. 
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="folderId">This value identifies the parent folder.</param>
        /// <param name="associatedFlag">This flag specifies whether the message is a folder associated information (FAI) message.</param>
        /// <param name="createMessageResponse">The response of this ROP.</param>
        /// <param name="needVerify">Whether need to verify the response</param>
        /// <returns>The handle of the created message.</returns>
        private uint RopCreateMessage(uint handle, ulong folderId, byte associatedFlag, out RopCreateMessageResponse createMessageResponse, bool needVerify)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;

            RopCreateMessageRequest createMessageRequest = new RopCreateMessageRequest()
            {
                RopId = (byte)RopId.RopCreateMessage,
                LogonId = LogonId,
                InputHandleIndex = (byte)HandleIndex.FirstIndex,
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,
                CodePageId = (ushort)CodePageId.SameAsLogonObject,
                FolderId = folderId,
                AssociatedFlag = associatedFlag
            };

            this.responseSOHsValue = this.ProcessSingleRop(createMessageRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            createMessageResponse = (RopCreateMessageResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, createMessageResponse.ReturnValue, string.Format("RopCreateMessageResponse Failed! Error: 0x{0:X8}", createMessageResponse.ReturnValue));
            }

            return this.responseSOHsValue[0][createMessageResponse.OutputHandleIndex];
        }
Exemplo n.º 36
0
        /// <summary>
        /// This ROP opens an existing folder in a mailbox.  
        /// </summary>
        /// <param name="handle">The handle to operate</param>
        /// <param name="openFolderResponse">The response of this ROP</param>
        /// <param name="folderId">The identifier of the folder to be opened.</param>
        /// <param name="needVerify">Whether need to verify the response</param>
        /// <returns>The handle of the opened folder</returns>
        private uint RopOpenFolder(uint handle, out RopOpenFolderResponse openFolderResponse, ulong folderId, bool needVerify)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;

            RopOpenFolderRequest openFolderRequest = new RopOpenFolderRequest()
            {
                RopId = (byte)RopId.RopOpenFolder,
                LogonId = LogonId,
                InputHandleIndex = (byte)HandleIndex.FirstIndex,
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,
                FolderId = folderId,

                // Open an existing folder with None value for OpenModeFlags flag.
                OpenModeFlags = (byte)FolderOpenModeFlags.None
            };

            this.responseSOHsValue = this.ProcessSingleRop(openFolderRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            openFolderResponse = (RopOpenFolderResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, openFolderResponse.ReturnValue, string.Format("RopOpenFolderResponse Failed! Error: 0x{0:X8}", openFolderResponse.ReturnValue));
            }

            return this.responseSOHsValue[0][openFolderResponse.OutputHandleIndex];
        }
Exemplo n.º 37
0
        /// <summary>
        /// This ROP deletes a folder and its contents.
        /// </summary>
        /// <param name="handle">The handle of the folder to be deleted.</param>
        /// <param name="folderId">The Id of the folder to be deleted.</param>
        /// <returns>The response of this ROP</returns>
        private RopDeleteFolderResponse RopDeleteFolder(uint handle, ulong folderId)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;

            RopDeleteFolderRequest deleteFolderRequest = new RopDeleteFolderRequest()
            {
                RopId = (byte)RopId.RopDeleteFolder,
                LogonId = LogonId,
                InputHandleIndex = (byte)HandleIndex.FirstIndex,
                DeleteFolderFlags = 0x15,
                FolderId = folderId,
            };

            this.responseSOHsValue = this.ProcessSingleRop(deleteFolderRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            RopDeleteFolderResponse deleteFolderResponse = (RopDeleteFolderResponse)this.responseValue;
            this.Site.Assert.IsNotNull(deleteFolderResponse, string.Format("RopDeleteFolderResponse Failed! Error: 0x{0:X8}", deleteFolderResponse.ReturnValue));
            return deleteFolderResponse;
        }
Exemplo n.º 38
0
        /// <summary>
        /// This ROP deletes all messages and subfolders from a folder. 
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="wantAsynchronous">This value specifies whether the operation is to be executed asynchronously with status reported via RopProgress.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The response of this ROP.</returns>
        private RopEmptyFolderResponse RopEmptyFolder(uint handle, byte wantAsynchronous, bool needVerify)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;

            RopEmptyFolderRequest emptyFolderRequest = new RopEmptyFolderRequest()
            {
                RopId = (byte)RopId.RopEmptyFolder,
                LogonId = LogonId,
                InputHandleIndex = (byte)HandleIndex.FirstIndex,
                WantAsynchronous = wantAsynchronous,
                WantDeleteAssociated = Convert.ToByte(true),
            };

            this.responseSOHsValue = this.ProcessSingleRop(emptyFolderRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            RopEmptyFolderResponse emptyFolderResponse = (RopEmptyFolderResponse)this.responseValue;
            if (needVerify)
            {
                Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, emptyFolderResponse.ReturnValue, string.Format("RopEmptyFolder Failed! Error: 0x{0:X8}", emptyFolderResponse.ReturnValue));
            }

            return emptyFolderResponse;
        }
Exemplo n.º 39
0
 public DeserializeReader(IReadable <string> stringReader, IDeserializable <string> deserializer)
 {
     StringReader = stringReader;
     Deserializer = deserializer;
 }
Exemplo n.º 40
0
        /// <summary>
        /// Verify adapter capture code using reflection mechanism.
        /// </summary>
        /// <param name="expectedRopResponseType">The Expected ROP response type.</param>
        /// <param name="response">ROP response object.</param>
        /// <param name="ropRequest">ROP request object.</param>
        private void VerifyAdapterCaptureCode(RopResponseType expectedRopResponseType, IDeserializable response, ISerializable ropRequest)
        {
            string resName = response.GetType().Name;

            // The word "Response" takes 8 length.
            string ropName     = resName.Substring(0, resName.Length - 8);
            Type   adapterType = typeof(MS_OXCROPSAdapter);

            // Call capture code using reflection mechanism
            // The code followed is to construct the verify method name of capture code and then call this method through reflection.
            string verifyMethodName = string.Empty;

            if (expectedRopResponseType == RopResponseType.SuccessResponse)
            {
                verifyMethodName = "Verify" + ropName + "SuccessResponse";
            }
            else if (expectedRopResponseType == RopResponseType.FailureResponse)
            {
                verifyMethodName = "Verify" + ropName + "FailureResponse";
            }
            else if (expectedRopResponseType == RopResponseType.Response)
            {
                verifyMethodName = "Verify" + ropName + "Response";
            }
            else if (expectedRopResponseType == RopResponseType.NullDestinationFailureResponse)
            {
                verifyMethodName = "Verify" + ropName + "NullDestinationFailureResponse";
            }
            else if (expectedRopResponseType == RopResponseType.RedirectResponse)
            {
                verifyMethodName = "Verify" + ropName + "RedirectResponse";
            }

            Type       reqType = ropRequest.GetType();
            MethodInfo method  = adapterType.GetMethod(verifyMethodName, BindingFlags.NonPublic | BindingFlags.Instance);

            if (method == null)
            {
                if (expectedRopResponseType == RopResponseType.SuccessResponse || expectedRopResponseType == RopResponseType.FailureResponse)
                {
                    verifyMethodName = "Verify" + ropName + "Response";
                    method           = adapterType.GetMethod(verifyMethodName, BindingFlags.NonPublic | BindingFlags.Instance);
                }
            }

            if (method != null)
            {
                ParameterInfo[] paraInfos   = method.GetParameters();
                int             paraNum     = paraInfos.Length;
                object[]        paraObjects = new object[paraNum];
                paraObjects[0] = response;
                for (int i = 1; i < paraNum; i++)
                {
                    FieldInfo fieldInReq = reqType.GetField(
                        paraInfos[i].Name,
                        BindingFlags.IgnoreCase
                        | BindingFlags.DeclaredOnly
                        | BindingFlags.Public
                        | BindingFlags.NonPublic
                        | BindingFlags.GetField
                        | BindingFlags.Instance);
                    paraObjects[i] = fieldInReq.GetValue(ropRequest);
                }

                method.Invoke(this, paraObjects);
            }
        }
        /// <summary>
        /// Method which executes single ROP.
        /// </summary>
        /// <param name="ropRequest">ROP request objects.</param>
        /// <param name="inputObjHandle">Server object handle in request.</param>
        /// <param name="response">ROP response objects.</param>
        /// <param name="rawData">The ROP response payload.</param>
        /// <param name="expectedRopResponseType">ROP response type expected.</param>
        /// <param name="returnValue">The return value of the ROP method.</param>
        /// <returns>Server objects handles in response.</returns>
        public List<List<uint>> ProcessSingleRopWithReturnValue(
            ISerializable ropRequest,
            uint inputObjHandle,
            ref IDeserializable response,
            ref byte[] rawData,
            RopResponseType expectedRopResponseType,
            out uint returnValue)
        {
            List<ISerializable> requestRops = null;
            if (ropRequest != null)
            {
                requestRops = new List<ISerializable>
                {
                    ropRequest
                };
            }

            List<uint> requestSOH = new List<uint>
            {
                inputObjHandle
            };

            if (Common.IsOutputHandleInRopRequest(ropRequest))
            {
                // Add an element for server output object handle and set default value to 0xFFFFFFFF.
                requestSOH.Add(DefaultOutputHandle);
            }

            if (this.IsInvalidInputHandleNeeded(ropRequest, expectedRopResponseType))
            {
                // Add an invalid input handle in request and set its value to 0xFFFFFFFF.
                requestSOH.Add(InvalidInputHandle);
            }

            List<IDeserializable> responseRops = new List<IDeserializable>();
            List<List<uint>> responseSOHs = new List<List<uint>>();

            uint ret = this.RopCall(requestRops, requestSOH, ref responseRops, ref responseSOHs, ref rawData, MaxRgbOut);
            returnValue = ret;
            if (ret != OxcRpcErrorCode.ECNone && ret != 1726)
            {
                Site.Assert.AreEqual<RopResponseType>(RopResponseType.RPCError, expectedRopResponseType, "Unexpected RPC error {0} occurred.", ret);
                return responseSOHs;
            }

            if (responseRops != null)
            {
                if (responseRops.Count > 0)
                {
                    response = responseRops[0];
                }
            }
            else
            {
                response = null;
            }

            if (ropRequest.GetType() == typeof(RopReleaseRequest))
            {
                return responseSOHs;
            }

            if (response.GetType() == typeof(RopSaveChangesMessageResponse) && ((RopSaveChangesMessageResponse)response).ReturnValue == 0x80040401)
            {
                return responseSOHs;
            }

            if (response != null)
            {
                try
                {
                    this.VerifyAdapterCaptureCode(expectedRopResponseType, response, ropRequest);
                }
                catch (TargetInvocationException invocationEx)
                {
                    Site.Log.Add(LogEntryKind.Debug, invocationEx.Message);
                    if (invocationEx.InnerException != null)
                    {
                        throw invocationEx.InnerException;
                    }
                }
                catch (NullReferenceException nullEx)
                {
                    Site.Log.Add(LogEntryKind.Debug, nullEx.Message);
                }
            }

            return responseSOHs;
        }
        /// <summary>
        /// Method which executes single ROP.
        /// </summary>
        /// <param name="ropRequest">ROP request objects.</param>
        /// <param name="inputObjHandle">Server object handle in request.</param>
        /// <param name="response">ROP response objects.</param>
        /// <param name="rawData">The ROP response payload.</param>
        /// <param name="expectedRopResponseType">ROP response type expected.</param>
        /// <returns>Server objects handles in response.</returns>
        public List<List<uint>> ProcessSingleRop(
            ISerializable ropRequest,
            uint inputObjHandle,
            ref IDeserializable response,
            ref byte[] rawData,
            RopResponseType expectedRopResponseType)
        {
            uint returnValue;
            List<List<uint>> responseSOHs = this.ProcessSingleRopWithReturnValue(ropRequest, inputObjHandle, ref response, ref rawData, expectedRopResponseType, out returnValue);
            if (returnValue == 1726)
            {
                Site.Assert.AreEqual<RopResponseType>(RopResponseType.RPCError, expectedRopResponseType, "Unexpected RPC error {0} occurred.", returnValue);
            }

            return responseSOHs;
        }
        /// <summary>
        /// Method which executes single ROP with multiple server objects.
        /// </summary>
        /// <param name="ropRequest">ROP request object.</param>
        /// <param name="insideObjHandle">Server object handles in request.</param>
        /// <param name="response">ROP response object.</param>
        /// <param name="rawData">The ROP response payload.</param>
        /// <param name="expectedRopResponseType">ROP response type expected.</param>
        /// <returns>Server objects handles in response.</returns>
        private List<List<uint>> ProcessSingleRopWithMutipleServerObjects(
            ISerializable ropRequest,
            List<uint> insideObjHandle,
            ref IDeserializable response,
            ref byte[] rawData,
            RopResponseType expectedRopResponseType)
        {
            List<ISerializable> requestRops = new List<ISerializable>
            {
                ropRequest
            };

            List<uint> requestSOH = new List<uint>();
            for (int i = 0; i < insideObjHandle.Count; i++)
            {
                requestSOH.Add(insideObjHandle[i]);
            }

            if (Common.IsOutputHandleInRopRequest(ropRequest))
            {
                // Add an element for server output object handle, set default value to 0xFFFFFFFF
                requestSOH.Add(DefaultOutputHandle);
            }

            List<IDeserializable> responseRops = new List<IDeserializable>();
            List<List<uint>> responseSOHs = new List<List<uint>>();

            uint ret = this.oxcropsClient.RopCall(requestRops, requestSOH, ref responseRops, ref responseSOHs, ref rawData, MaxRgbOut);
            this.Site.Assert.AreEqual<uint>(OxcRpcErrorCode.ECNone, ret, "ROP call should return 0 for success, actually it returns {0}", ret);
            if (responseRops != null)
            {
                if (responseRops.Count > 0)
                {
                    response = responseRops[0];
                }
            }
            else
            {
                response = null;
            }

            if (ropRequest is RopReleaseRequest)
            {
                return responseSOHs;
            }

            try
            {
                string resName = response.GetType().Name;

                // The word "Response" takes 8 length.
                string ropName = resName.Substring(0, resName.Length - 8);
                Type adapterType = typeof(MS_OXCPRPTAdapter);

                // Call capture code using reflection mechanism
                // The code followed is to construct the verify method name of capture code and then call this method through reflection.
                string verifyMethodName = string.Empty;
                if (expectedRopResponseType == RopResponseType.SuccessResponse)
                {
                    verifyMethodName = "Verify" + ropName + "SuccessResponse";
                }
                else if (expectedRopResponseType == RopResponseType.FailureResponse)
                {
                    verifyMethodName = "Verify" + ropName + "FailureResponse";
                }
                else if (expectedRopResponseType == RopResponseType.Response)
                {
                    verifyMethodName = "Verify" + ropName + "Response";
                }
                else if (expectedRopResponseType == RopResponseType.NullDestinationFailureResponse)
                {
                    verifyMethodName = "Verify" + ropName + "NullDestinationFailureResponse";
                }
                else if (expectedRopResponseType == RopResponseType.RedirectResponse)
                {
                    verifyMethodName = "Verify" + ropName + "RedirectResponse";
                }

                Type reqType = ropRequest.GetType();
                MethodInfo method = adapterType.GetMethod(verifyMethodName, BindingFlags.NonPublic | BindingFlags.Instance);
                if (method == null)
                {
                    if (expectedRopResponseType == RopResponseType.SuccessResponse || expectedRopResponseType == RopResponseType.FailureResponse)
                    {
                        verifyMethodName = "Verify" + ropName + "Response";
                        method = adapterType.GetMethod(verifyMethodName, BindingFlags.NonPublic | BindingFlags.Instance);
                    }
                }

                if (method != null)
                {
                    ParameterInfo[] paraInfos = method.GetParameters();
                    int paraNum = paraInfos.Length;
                    object[] paraObjects = new object[paraNum];
                    paraObjects[0] = response;
                    for (int i = 1; i < paraNum; i++)
                    {
                        FieldInfo fieldInReq = reqType.GetField(
                            paraInfos[i].Name,
                            BindingFlags.IgnoreCase
                            | BindingFlags.DeclaredOnly
                            | BindingFlags.Public
                            | BindingFlags.NonPublic
                            | BindingFlags.GetField
                            | BindingFlags.Instance);
                        paraObjects[i] = fieldInReq.GetValue(ropRequest);
                    }

                    method.Invoke(this, paraObjects);
                }
            }
            catch (TargetInvocationException invocationEx)
            {
                Site.Log.Add(LogEntryKind.Debug, invocationEx.Message);
                if (invocationEx.InnerException != null)
                {
                    throw invocationEx.InnerException;
                }
            }
            catch (NullReferenceException nullEx)
            {
                Site.Log.Add(LogEntryKind.Debug, nullEx.Message);
            }

            return responseSOHs;
        }
        /// <summary>
        /// Verify adapter capture code using reflection mechanism.
        /// </summary>
        /// <param name="expectedRopResponseType">The Expected ROP response type.</param>
        /// <param name="response">ROP response object.</param>
        /// <param name="ropRequest">ROP request object.</param>
        private void VerifyAdapterCaptureCode(RopResponseType expectedRopResponseType, IDeserializable response, ISerializable ropRequest)
        {
            string resName = response.GetType().Name;

            // The word "Response" takes 8 length.
            string ropName = resName.Substring(0, resName.Length - 8);
            Type adapterType = typeof(MS_OXCROPSAdapter);

            // Call capture code using reflection mechanism
            // The code followed is to construct the verify method name of capture code and then call this method through reflection.
            string verifyMethodName = string.Empty;
            if (expectedRopResponseType == RopResponseType.SuccessResponse)
            {
                verifyMethodName = "Verify" + ropName + "SuccessResponse";
            }
            else if (expectedRopResponseType == RopResponseType.FailureResponse)
            {
                verifyMethodName = "Verify" + ropName + "FailureResponse";
            }
            else if (expectedRopResponseType == RopResponseType.Response)
            {
                verifyMethodName = "Verify" + ropName + "Response";
            }
            else if (expectedRopResponseType == RopResponseType.NullDestinationFailureResponse)
            {
                verifyMethodName = "Verify" + ropName + "NullDestinationFailureResponse";
            }
            else if (expectedRopResponseType == RopResponseType.RedirectResponse)
            {
                verifyMethodName = "Verify" + ropName + "RedirectResponse";
            }

            Type reqType = ropRequest.GetType();
            MethodInfo method = adapterType.GetMethod(verifyMethodName, BindingFlags.NonPublic | BindingFlags.Instance);
            if (method == null)
            {
                if (expectedRopResponseType == RopResponseType.SuccessResponse || expectedRopResponseType == RopResponseType.FailureResponse)
                {
                    verifyMethodName = "Verify" + ropName + "Response";
                    method = adapterType.GetMethod(verifyMethodName, BindingFlags.NonPublic | BindingFlags.Instance);
                }
            }

            if (method != null)
            {
                ParameterInfo[] paraInfos = method.GetParameters();
                int paraNum = paraInfos.Length;
                object[] paraObjects = new object[paraNum];
                paraObjects[0] = response;
                for (int i = 1; i < paraNum; i++)
                {
                    FieldInfo fieldInReq = reqType.GetField(
                        paraInfos[i].Name,
                        BindingFlags.IgnoreCase
                        | BindingFlags.DeclaredOnly
                        | BindingFlags.Public
                        | BindingFlags.NonPublic
                        | BindingFlags.GetField
                        | BindingFlags.Instance);
                    paraObjects[i] = fieldInReq.GetValue(ropRequest);
                }

                method.Invoke(this, paraObjects);
            }
        }
Exemplo n.º 45
0
 /// <summary>
 /// Register a ROP's Id together with a Deserializer
 /// </summary>
 /// <param name="ropId">The ROP's Id</param>
 /// <param name="iropDeserializer">The interface define the methods that is needed to deserialize a bytes array into an ROP object</param>
 public static void Register(int ropId, IDeserializable iropDeserializer)
 {
     maps[ropId] = iropDeserializer;
 }
        /// <summary>
        /// Initializes the test case before running it
        /// </summary>
        protected override void TestInitialize()
        {
            this.Site = TestClassBase.BaseTestSite;
            this.oxcrpcAdapter = this.Site.GetAdapter<IMS_OXCRPCAdapter>();
            this.oxcrpcControlAdapter = this.Site.GetAdapter<IMS_OXCRPCSUTControlAdapter>();

            this.transportIsMAPI = string.Compare(Common.GetConfigurationPropertyValue("TransportSeq", this.Site), "mapi_http", true, System.Globalization.CultureInfo.InvariantCulture) == 0;

            if (!this.transportIsMAPI)
            {
                this.pcbAuxOut = ConstValues.ValidpcbAuxOut;
                this.pcbOut = ConstValues.ValidpcbOut;
                this.rgbIn = new byte[0];
                this.pcxh = IntPtr.Zero;
                this.pcxhInvalid = IntPtr.Zero;
                this.pacxh = IntPtr.Zero;
                this.pulTimeStamp = 0x00000000;
                this.responseSOHTable = new List<List<uint>>();
                this.response = null;
                this.objHandle = 0;
                this.userDN = Common.GetConfigurationPropertyValue("AdminUserEssdn", this.Site);
                this.userName = Common.GetConfigurationPropertyValue("AdminUserName", this.Site);
                this.password = Common.GetConfigurationPropertyValue("AdminUserPassword", this.Site);

                // Holds the value represents USE_PER_MDB_REPLID_MAPPING flag that control the behavior of the RopLogon
                this.userPrivilege = 0x01000000;

                #region Initializes Server and Client based on specific protocol sequence
                this.authenticationLevel = (uint)Convert.ToInt32(Common.GetConfigurationPropertyValue("RpcAuthenticationLevel", this.Site));
                this.authenticationService = (uint)Convert.ToInt32(Common.GetConfigurationPropertyValue("RPCAuthenticationService", this.Site));
                #endregion
            }
        }
Exemplo n.º 47
0
        /// <summary>
        /// This ROP opens an attachment of a message. 
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="attachmentId">The identifier of the attachment to be opened. </param>
        /// <param name="openAttachmentResponse">The response of this ROP.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The index of the output handle for the response.</returns>
        private uint RopOpenAttachment(uint handle, uint attachmentId, out RopOpenAttachmentResponse openAttachmentResponse, bool needVerify)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;

            RopOpenAttachmentRequest openAttachmentRequest = new RopOpenAttachmentRequest()
            {
                RopId = (byte)RopId.RopOpenAttachment,
                LogonId = LogonId,
                InputHandleIndex = (byte)HandleIndex.FirstIndex,
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,
                OpenAttachmentFlags = (byte)OpenAttachmentFlags.ReadWrite,
                AttachmentID = attachmentId
            };

            this.responseSOHsValue = this.ProcessSingleRop(openAttachmentRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            openAttachmentResponse = (RopOpenAttachmentResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, openAttachmentResponse.ReturnValue, string.Format("RopOpenAttachment Failed! Error: 0x{0:X8}", openAttachmentResponse.ReturnValue));
            }

            return this.responseSOHsValue[0][openAttachmentResponse.OutputHandleIndex];
        }
Exemplo n.º 48
0
        /// <summary>
        /// This ROP opens an attachment as a message. 
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="openEmbeddedMessageResponse">The response of this ROP.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The index of the output handle of the response.</returns>
        private uint RopOpenEmbeddedMessage(uint handle, out RopOpenEmbeddedMessageResponse openEmbeddedMessageResponse, bool needVerify)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;

            RopOpenEmbeddedMessageRequest openEmbeddedMessageRequest = new RopOpenEmbeddedMessageRequest()
            {
                RopId = (byte)RopId.RopOpenEmbeddedMessage,

                // The logonId 0x00 is associated with RopOpenEmbeddedMessage.
                LogonId = 0x00,

                // This index specifies the location 0x00 in the Server Object Handle Table where the handle for the input Server Object is stored. 
                InputHandleIndex = (byte)HandleIndex.FirstIndex,

                // This index specifies the location 0x01 in the Server Object Handle Table where the handle for the output Server Object is stored. 
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,
                CodePageId = 0x0FFF,
                OpenModeFlags = 0x02
            };

            this.responseSOHsValue = this.ProcessSingleRop(openEmbeddedMessageRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            openEmbeddedMessageResponse = (RopOpenEmbeddedMessageResponse)this.responseValue;

            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, openEmbeddedMessageResponse.ReturnValue, string.Format("RopOpenEmbeddedMessage Failed! Error: 0x{0:X8}", openEmbeddedMessageResponse.ReturnValue));
            }

            return this.responseSOHsValue[0][openEmbeddedMessageResponse.OutputHandleIndex];
        }
Exemplo n.º 49
0
        /// <summary>
        /// This ROP commits the changes made to a message. 
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        /// <param name="needVerify">Whether need to verify the response.</param>
        /// <returns>The response of this ROP.</returns>
        private RopSaveChangesMessageResponse RopSaveChangesMessage(uint handle, bool needVerify)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;

            RopSaveChangesMessageRequest saveChangesMessageRequest = new RopSaveChangesMessageRequest()
            {
                RopId = (byte)RopId.RopSaveChangesMessage,
                LogonId = LogonId,
                InputHandleIndex = (byte)HandleIndex.FirstIndex,
                ResponseHandleIndex = (byte)HandleIndex.SecondIndex,

                // Set the SaveFlags flag to ForceSave, which indicates the client requests server to commit the changes. 
                SaveFlags = (byte)SaveFlags.ForceSave,
            };

            this.responseSOHsValue = this.ProcessSingleRop(saveChangesMessageRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            RopSaveChangesMessageResponse saveChangesMessageResponse = (RopSaveChangesMessageResponse)this.responseValue;

            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, saveChangesMessageResponse.ReturnValue, string.Format("RopSaveChangesMessage Failed! Error: 0x{0:X8}", saveChangesMessageResponse.ReturnValue));
            }

            return saveChangesMessageResponse;
        }
Exemplo n.º 50
0
        /// <summary>
        /// Test cleanup.
        /// </summary>
        protected override void TestCleanup()
        {
            if (!this.needDoCleanup)
            {
                return;
            }

            string userName = Common.GetConfigurationPropertyValue("AdminUserName", this.Site);
            string passWord = Common.GetConfigurationPropertyValue("PassWord", this.Site);

            // Hard Delete Messages and Subfolders of Inbox
            switch (this.TestContext.TestName)
            {
                case "MSOXCROPS_S01_TC01_TestLogonFailed":
                case "MSOXCROPS_S01_TC02_TestLogonRedirect":
                    break;
                default:
                    // Delete subfolders and messages under Inbox folder
                    this.HardDeleteMessagesAndSubfolders(userName, passWord, this.userDN, 4);

                    // Delete subfolders and messages under the 5th folder
                    this.HardDeleteMessagesAndSubfolders(userName, passWord, this.userDN, 5);

                    if (this.TestContext.TestName == "MSOXCROPS_S05_TC01_TestRopSubmitMessage" || this.TestContext.TestName == "MSOXCROPS_S05_TC07_TestRopTransportSend")
                    {
                        userName = Common.GetConfigurationPropertyValue("EmailAlias", this.Site);
                        passWord = Common.GetConfigurationPropertyValue("EmailAliasPassword", this.Site);
                        this.userDN = Common.GetConfigurationPropertyValue("EmailAliasEssdn", this.Site) + "\0";

                        // Delete subfolders and messages under Inbox folder of the receiver's mailbox
                        this.HardDeleteMessagesAndSubfolders(userName, passWord, this.userDN, 4, true);
                    }

                    break;
            }

            // Objects initialization.
            this.rawData = null;
            this.inputObjHandle = 0;
            this.response = null;
            this.responseSOHs = null;

            // Call the Reset method the re-initialize the Site.
            this.cropsAdapter.RpcDisconnect();
        }
Exemplo n.º 51
0
        /// <summary>
        /// This ROP releases all resources associated with a server object. 
        /// </summary>
        /// <param name="handle">The handle to operate.</param>
        private void RopRelease(uint handle)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;

            RopReleaseRequest releaseRequest = new RopReleaseRequest()
            {
                RopId = (byte)RopId.RopRelease,
                LogonId = LogonId,
                InputHandleIndex = (byte)HandleIndex.FirstIndex
            };

            // The RopRelease ROP doesn't return response from server.
            this.responseSOHsValue = this.ProcessSingleRop(releaseRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
        }
Exemplo n.º 52
0
        /// <summary>
        /// This ROP opens an existing message in a mailbox. 
        /// </summary>
        /// <param name="handle">The handle to operate</param>
        /// <param name="folderId">The parent folder of the message to be opened.</param>
        /// <param name="messageId">The identifier of the message to be opened.</param>
        /// <param name="openMessageResponse">The response of this ROP.</param>
        /// <param name="needVerify">Whether need to verify the response</param>
        /// <returns>The handle of the opened message</returns>
        private uint RopOpenMessage(uint handle, ulong folderId, ulong messageId, out RopOpenMessageResponse openMessageResponse, bool needVerify)
        {
            this.rawDataValue = null;
            this.responseValue = null;
            this.responseSOHsValue = null;

            RopOpenMessageRequest openMessageRequest = new RopOpenMessageRequest()
            {
                RopId = (byte)RopId.RopOpenMessage,
                LogonId = LogonId,
                InputHandleIndex = (byte)HandleIndex.FirstIndex,
                OutputHandleIndex = (byte)HandleIndex.SecondIndex,

                // Set CodePageId to SameAsLogonObject, which indicates it uses the same code page as the one for logon object.
                CodePageId = (ushort)CodePageId.SameAsLogonObject,
                FolderId = folderId,

                // Set OpenModeFlags to read and write for further operation.
                OpenModeFlags = (byte)MessageOpenModeFlags.ReadWrite,
                MessageId = messageId
            };

            this.responseSOHsValue = this.ProcessSingleRop(openMessageRequest, handle, ref this.responseValue, ref this.rawDataValue, RopResponseType.SuccessResponse);
            openMessageResponse = (RopOpenMessageResponse)this.responseValue;
            if (needVerify)
            {
                this.Site.Assert.AreEqual((uint)RopResponseType.SuccessResponse, openMessageResponse.ReturnValue, string.Format("RopOpenMessageResponse Failed! Error: 0x{0:X8}", openMessageResponse.ReturnValue));
            }

            return this.responseSOHsValue[0][openMessageResponse.OutputHandleIndex];
        }
        /// <summary>
        /// This method is used to process the response and 
        /// call the corresponding verification method.
        /// </summary>
        /// <param name="response">The IDeserializable type response</param>
        private void ProcessResponse(IDeserializable response)
        {
            if (response == null)
            {
                Site.Assert.Fail("Response should not be null");
            }

            string responseName = response.GetType().Name;

            switch (responseName)
            {
                case "RopAbortResponse":
                    {
                        // Verify RopAbortResponse Response
                        RopAbortResponse abortResponse = (RopAbortResponse)response;
                        this.VerifyRopAbortResponse(abortResponse);
                        break;
                    }

                case "RopCollapseRowResponse":
                    {
                        // Verify RopCollapseRow Response
                        RopCollapseRowResponse collapseRowResponse = (RopCollapseRowResponse)response;
                        this.VerifyRopCollapseRowResponse(collapseRowResponse);
                        break;
                    }

                case "RopCreateBookmarkResponse":
                    {
                        // Verify RopCreateBookmark Response
                        RopCreateBookmarkResponse createBookmarkResponse = (RopCreateBookmarkResponse)response;
                        if (createBookmarkResponse.ReturnValue == 0x00000000)
                        {
                            this.VerifyRopCreateBookmarkResponse(createBookmarkResponse);
                        }

                        break;
                    }

                case "RopExpandRowResponse":
                    {
                        // Verify RopExpandRow Response
                        RopExpandRowResponse expandRowResponse = (RopExpandRowResponse)response;
                        if (expandRowResponse.ReturnValue == 0x00000000)
                        {
                            this.VerifyRopExpandRowResponse(expandRowResponse, this.maxRowCountInExpandRowRequest);
                        }

                        break;
                    }

                case "RopFindRowResponse":
                    {
                        // Verify RopFindRow Response
                        RopFindRowResponse findRowResponse = (RopFindRowResponse)response;

                        this.VerifyRopFindRowResponse(findRowResponse);
                        break;
                    }

                case "RopFreeBookmarkResponse":
                    {
                        break;
                    }

                case "RopGetCollapseStateResponse":
                    {
                        // Verify RopGetCollapseState Response
                        RopGetCollapseStateResponse getCollapseStateResponse = (RopGetCollapseStateResponse)response;
                        if (getCollapseStateResponse.ReturnValue == 0x00000000)
                        {
                            this.VerifyRopGetCollapseStateResponse(getCollapseStateResponse);
                        }

                        break;
                    }

                case "RopGetStatusResponse":
                    {
                        // Verify RopGetStatusResponse Response
                        RopGetStatusResponse getStatusResponse = (RopGetStatusResponse)response;
                        this.VerifyGetStatusResponse(getStatusResponse);
                        break;
                    }

                case "RopQueryColumnsAllResponse":
                    {
                        // Verify RopQueryColumnsALL Response.
                        RopQueryColumnsAllResponse queryColumnsAllResponse = (RopQueryColumnsAllResponse)response;
                        if (queryColumnsAllResponse.ReturnValue == 0x00000000)
                        {
                            this.VerifyRopQueryColumnsALLResponse(queryColumnsAllResponse);
                        }

                        break;
                    }

                case "RopQueryPositionResponse":
                    {
                        // Verify RopQueryPosition Response.
                        RopQueryPositionResponse queryPositionRespone = (RopQueryPositionResponse)response;
                        if (queryPositionRespone.ReturnValue == 0x00000000)
                        {
                            this.VerifyRopQueryPositionResponse(queryPositionRespone);
                        }

                        break;
                    }

                case "RopQueryRowsResponse":
                    {
                        // Verify RopQueryRows Response.
                        RopQueryRowsResponse queryRowsRespone = (RopQueryRowsResponse)response;
                        if (queryRowsRespone.ReturnValue == 0x00000000)
                        {
                            this.VerifyRopQueryRowsResponse(queryRowsRespone, this.rowCountInQueryRowsRequest);
                        }

                        break;
                    }

                case "RopResetTableResponse":
                    {
                        break;
                    }

                case "RopRestrictResponse":
                    {
                        // Verify RopRestrict Response.
                        RopRestrictResponse restrictResponse = (RopRestrictResponse)response;
                        if (restrictResponse.ReturnValue == 0x00000000)
                        {
                            this.VerifyRopRestrictResponse(restrictResponse);
                        }

                        break;
                    }

                case "RopSeekRowResponse":
                    {
                        // Verify RopSeekRow Response.
                        RopSeekRowResponse seekRowResponse = (RopSeekRowResponse)response;
                        if (seekRowResponse.ReturnValue == 0x00000000)
                        {
                            this.VerifyRopSeekRowResponse(seekRowResponse, this.rowCountInSeekRowRequest);
                        }

                        break;
                    }

                case "RopSeekRowBookmarkResponse":
                    {
                        // Verify RopSeekRowBookmark Response.
                        RopSeekRowBookmarkResponse seekRowBookmarkResponse = (RopSeekRowBookmarkResponse)response;
                        if (seekRowBookmarkResponse.ReturnValue == 0x00000000)
                        {
                            this.VerifyRopSeekRowBookmarkResponse(seekRowBookmarkResponse, this.rowCountInSeekRowBookmarkRequest);
                        }

                        break;
                    }

                case "RopSeekRowFractionalResponse":
                    {
                        break;
                    }

                case "RopSetCollapseStateResponse":
                    {
                        // Verify RopSetCollapseState Response.
                        RopSetCollapseStateResponse setCollapsStateResponse = (RopSetCollapseStateResponse)response;
                        if (setCollapsStateResponse.ReturnValue == 0x00000000)
                        {
                            this.VerifyRopSetCollapseStateResponse(setCollapsStateResponse);
                        }

                        break;
                    }

                case "RopSetColumnsResponse":
                    {
                        // Verify RopSetColumns Response.
                        RopSetColumnsResponse setColumnsResponse = (RopSetColumnsResponse)response;
                        if (setColumnsResponse.ReturnValue == 0x00000000)
                        {
                            this.VerifyRopSetColumnsResponse(setColumnsResponse);
                        }

                        break;
                    }

                case "RopSortTableResponse":
                    {
                        // Verify RopSortTable Response.
                        RopSortTableResponse sortTableResponse = (RopSortTableResponse)response;
                        if (sortTableResponse.ReturnValue == 0x00000000)
                        {
                            this.VerifyRopSortTableResponse(sortTableResponse);
                        }

                        break;
                    }

                default:
                    break;
            }
        }