protected override OVAL.SystemCharacteristics.ItemType CreateItemTypeWithErrorStatus(string errorMessage)
 {
     var messageType = new MessageType() { level = MessageLevelEnumeration.error, Value = errorMessage };
     return new OVAL.SystemCharacteristics.fileeffectiverights_item()
     {
         status = OVAL.SystemCharacteristics.StatusEnumeration.error,
         message = new MessageType[] { messageType }
     };
 }
 private void AssertMessageType(MessageType messageTypeToAssert, string expectedChunkOfMessage)
 {
     Assert.IsNotNull(messageTypeToAssert, "There is no message type instance.");
     Assert.IsFalse(string.IsNullOrEmpty(messageTypeToAssert.Value), "There is no message type value.");
     Assert.IsTrue(messageTypeToAssert.Value.Contains("FileAuditedPermissionsObjectCollector"), "The expected chunk of text was not found in message type value.");
 }
        public IEnumerable<ItemType> CollectItemsApplyingOperation(string regHive, string regKey, string sidEntityValue, OperationEnumeration sidEntityOperation)
        {
            Dictionary<string, uint> allUsersDACL = null;
            try
            {
                var hiveID = RegistryHelper.GetRegistryHiveFromHiveName(regHive);//(RegistryHive)RegistryHelper.GetHiveKeyIdFromHiveName(regHive);
                allUsersDACL = AccessControlListProvider.GetRegKeyDACLs(this.TargetInfo, hiveID.ToString(), regKey);
            }
            catch (RegistryKeyEffectiveRightsNotFoundException)
            {
                var newNotExistsItem = new regkeyeffectiverights_item() { status = StatusEnumeration.doesnotexist };
                newNotExistsItem.hive = new EntityItemRegistryHiveType() { Value = regHive };
                newNotExistsItem.key = new EntityItemStringType() { Value = regKey, status = StatusEnumeration.doesnotexist };
                return new ItemType[] { newNotExistsItem };
            }
            catch (RegistryKeyEffectiveRightsAccessDenied regKeyAccessDeniedException)
            {
                var messageType = new MessageType() { level = MessageLevelEnumeration.error, Value = regKeyAccessDeniedException.Message };
                var newErrorItem =
                    new regkeyeffectiverights_item()
                    {
                        hive = new EntityItemRegistryHiveType() { Value = regHive },
                        key = new EntityItemStringType() { Value = regKey },
                        status = StatusEnumeration.error,
                        message = new MessageType[] { messageType }
                    };

                return new ItemType[] { newErrorItem };
            }

            var collectedItems = new List<ItemType>();
            foreach (var userDacl in allUsersDACL)
            {
                var userSid = userDacl.Key;
                var dacl = userDacl.Value;

                if (ProcessSidEntityOperation(sidEntityValue, userSid, sidEntityOperation))
                {
                    var winACE = this.DaclDisassembler.GetSecurityDescriptorFromAccessMask(dacl);
                    var newCollectedItem = CreateItemTypeFromWinACE(winACE, regHive, regKey, userSid);
                    collectedItems.Add(newCollectedItem);
                }
            }

            return collectedItems;
        }
 public static bool LoadFromFile(string fileName, out MessageType obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an MessageType object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output MessageType object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out MessageType obj, out System.Exception exception)
 {
     exception = null;
     obj = default(MessageType);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 public static bool Deserialize(string xml, out MessageType obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an MessageType object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output MessageType object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out MessageType obj, out System.Exception exception)
 {
     exception = null;
     obj = default(MessageType);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
        private MessageType[] CloneItemMessages(MessageType[] sourceMessagesType)
        {
            if (sourceMessagesType == null)
                return null;

            var clonedMessages = new List<MessageType>();
            foreach (var sourceMessage in sourceMessagesType)
                clonedMessages.Add(new MessageType() { level = sourceMessage.level, Value = sourceMessage.Value });
            
            return clonedMessages.ToArray();
        }