private fileauditedpermissions53_object CreateFileObject( EntitySimpleBaseType filePath, EntitySimpleBaseType fileName, EntitySimpleBaseType path, EntitySimpleBaseType xpath) { EntitySimpleBaseType[] items; fileauditedpermissions53_objectItemsChoices[] itemChoices; if (filePath == null) { items = new EntitySimpleBaseType[4]; itemChoices = new fileauditedpermissions53_objectItemsChoices[3]; itemChoices[0] = fileauditedpermissions53_objectItemsChoices.path; itemChoices[1] = fileauditedpermissions53_objectItemsChoices.filename; itemChoices[2] = fileauditedpermissions53_objectItemsChoices.trustee_sid; items[0] = path; items[1] = fileName; items[2] = xpath; } else { items = new EntitySimpleBaseType[3]; itemChoices = new fileauditedpermissions53_objectItemsChoices[2]; itemChoices[0] = fileauditedpermissions53_objectItemsChoices.filepath; itemChoices[1] = fileauditedpermissions53_objectItemsChoices.trustee_sid; items[0] = filePath; items[1] = xpath; } return new fileauditedpermissions53_object() { Items = items, Fileauditedpermissions53ObjectItemsElementName = itemChoices }; }
private IEnumerable<ItemType> ProcessOperation(EntitySimpleBaseType userEntity, IEnumerable<String> evalutedVariables) { var entityOperation = userEntity.operation; var entityValue = userEntity.Value; var userNames = string.IsNullOrEmpty(userEntity.var_ref) ? new string[] { entityValue } : evalutedVariables; var result = new List<ItemType>(); foreach (var userName in userNames) if (IsEqualsOperation(userEntity)) result.Add(CreateUserItem(userName)); else foreach (var collectedUser in WindowsAccountProvider.GetAllGroupByUsers())//WindowsAccountProvider.GetAllUsersByGroup()) if (this.Compare(userName, collectedUser.Name, entityOperation)) result.Add(CreateUserItemFromWindowsAccount(collectedUser)); if (result.IsEmpty()) { var newNotExistsItem = CreateUserItem(userNames.FirstOrDefault()); newNotExistsItem.status = StatusEnumeration.doesnotexist; result.Add(newNotExistsItem); } return result; }
private xmlfilecontent_object CreateFileObject( EntitySimpleBaseType filePath, EntitySimpleBaseType fileName, EntitySimpleBaseType path, EntitySimpleBaseType xpath) { var newXmlFileContentObject = new xmlfilecontent_object(); EntitySimpleBaseType[] items; xmlfilecontent_ItemsChoices[] itemChoices; if (filePath == null) { items = new EntitySimpleBaseType[4]; itemChoices = new xmlfilecontent_ItemsChoices[3]; itemChoices[0] = xmlfilecontent_ItemsChoices.path; itemChoices[1] = xmlfilecontent_ItemsChoices.filename; itemChoices[2] = xmlfilecontent_ItemsChoices.xpath; items[0] = path; items[1] = fileName; items[2] = xpath; } else { items = new EntitySimpleBaseType[3]; itemChoices = new xmlfilecontent_ItemsChoices[2]; itemChoices[0] = xmlfilecontent_ItemsChoices.filepath; itemChoices[1] = xmlfilecontent_ItemsChoices.xpath; items[0] = filePath; items[1] = xpath; } newXmlFileContentObject.Items = items; newXmlFileContentObject.XmlfilecontentItemsElementName = itemChoices; return newXmlFileContentObject; }
/// <summary> /// This method evaluates variables specified in entityType. /// If is not exists any variables, the return value is the same value defined in entityType. /// </summary> /// <param name="entityType">EntityType.</param> /// <returns></returns> public IEnumerable<string> Evaluate(EntitySimpleBaseType entityType) { if (this.ExistsVariableDefined(entityType)) { return EvaluateVariable(entityType.var_ref); } else { return this.ReturnTheSameValue(entityType); } }
public IEnumerable<string> EvaluateEntityVariable(EntitySimpleBaseType entity) { if (entity == null) return null; VariableEntityEvaluator variableEvaluator = new VariableEntityEvaluator(this.EvaluatedVariables); var variables = variableEvaluator.EvaluateVariableForEntity(entity); if ((variables.Count() == 0) && (entity.Value != null)) ((IList)variables).Add(entity.Value); return variables; }
private bool Compare(EntityItemSimpleBaseType valueOfFieldItemType, EntitySimpleBaseType valueOfFieldStateType) { string itemValue = valueOfFieldItemType.Value; string stateValue = valueOfFieldStateType.Value; if ((itemValue == null) && (stateValue == null)) return true; // If one of objects to compare is null and another one is not null the compare result must be false. if (this.IsOneOfTheseObjectsNullAndAnotherOneNotNull(itemValue, stateValue) && string.IsNullOrEmpty(valueOfFieldStateType.var_ref)) return false; var value = valueOfFieldStateType.Value; if (IsThereDefinedVariable(valueOfFieldStateType)) value = ProcessVariableById(valueOfFieldStateType.var_ref); IOvalComparator comparator = new OvalComparatorFactory().GetComparator(valueOfFieldStateType.datatype); string firstElement = itemValue; string secondElement = value; return comparator.Compare(firstElement, secondElement, valueOfFieldStateType.operation); }
private bool CheckNullForEntities(EntityItemSimpleBaseType valueOfFieldItemType, EntitySimpleBaseType valueOfFieldStateType) { return (valueOfFieldItemType == null) && (valueOfFieldStateType == null); }
private static bool IsThereDefinedVariable(EntitySimpleBaseType valueOfFieldStateType) { return !String.IsNullOrEmpty(valueOfFieldStateType.var_ref); }
private IEnumerable<string> processVariablesForEntity(EntitySimpleBaseType entity) { var variables = new List<string>(); if (entity == null) return variables; var variableEvaluator = new VariableEntityEvaluator(this.variablesEvaluated); variables.AddRange(variableEvaluator.EvaluateVariableForEntity(entity)); if ((variables.Count() == 0) && (!string.IsNullOrEmpty(entity.Value))) variables.Add(entity.Value); return variables; }
private void assertGeneratedEntityItem(EntityItemStringType createdEntity, EntitySimpleBaseType sourceEntity, string entityName) { if (sourceEntity == null) return; Assert.AreEqual(sourceEntity.Value, createdEntity.Value, string.Format(UNEXPECTED_ENTITY_VALUE_FOUND, entityName)); }
private void AssertObjectEntity(EntitySimpleBaseType entityToAssert, string expectedEntiyValue) { Assert.IsNotNull(entityToAssert); Assert.IsNotNull(entityToAssert.Value); Assert.AreEqual(expectedEntiyValue, entityToAssert.Value); }
private bool IsEqualsOperation(EntitySimpleBaseType entity) { return entity.operation.Equals(OperationEnumeration.equals) || entity.operation.Equals(OperationEnumeration.caseinsensitiveequals); }
private textfilecontent54_object CreateTextFileContentObject( EntityObjectStringType filePath, EntityObjectStringType fileName, EntityObjectStringType path, EntityObjectStringType pattern, EntityObjectIntType instance, Object[] behaviors) { var fileContentObject = new textfilecontent54_object(); object[] items; textfilecontent54_ItemsChoices[] itemChoices; var hasBehaviors = (behaviors != null) && (behaviors.Count() > 0); var behaviorCount = behaviors.Count(); if (filePath == null) { if (hasBehaviors) { var entityCount = behaviorCount + 4; items = new object[entityCount]; itemChoices = new textfilecontent54_ItemsChoices[entityCount]; for (int i = 0; i < behaviorCount; i++) { itemChoices[i] = textfilecontent54_ItemsChoices.behaviors; items[i] = behaviors.ElementAt(i); } itemChoices[behaviorCount] = textfilecontent54_ItemsChoices.path; itemChoices[behaviorCount + 1] = textfilecontent54_ItemsChoices.filename; itemChoices[behaviorCount + 2] = textfilecontent54_ItemsChoices.pattern; itemChoices[behaviorCount + 3] = textfilecontent54_ItemsChoices.instance; items[behaviorCount] = path; items[behaviorCount + 1] = fileName; items[behaviorCount + 2] = pattern; items[behaviorCount + 3] = instance; } else { items = new EntitySimpleBaseType[4]; itemChoices = new textfilecontent54_ItemsChoices[4]; itemChoices[0] = textfilecontent54_ItemsChoices.path; itemChoices[1] = textfilecontent54_ItemsChoices.filename; itemChoices[2] = textfilecontent54_ItemsChoices.pattern; itemChoices[3] = textfilecontent54_ItemsChoices.instance; items[0] = path; items[1] = fileName; items[2] = pattern; items[3] = instance; } } else { if (hasBehaviors) { var entityCount = behaviorCount + 3; items = new object[entityCount]; itemChoices = new textfilecontent54_ItemsChoices[entityCount]; for (int i = 0; i < behaviorCount; i++) { itemChoices[i] = textfilecontent54_ItemsChoices.behaviors; items[i] = behaviors.ElementAt(i); } itemChoices[behaviorCount] = textfilecontent54_ItemsChoices.filepath; itemChoices[behaviorCount + 1] = textfilecontent54_ItemsChoices.pattern; itemChoices[behaviorCount + 2] = textfilecontent54_ItemsChoices.instance; items[behaviorCount] = filePath; items[behaviorCount + 1] = pattern; items[behaviorCount + 2] = instance; } else { items = new EntitySimpleBaseType[3]; itemChoices = new textfilecontent54_ItemsChoices[3]; itemChoices[0] = textfilecontent54_ItemsChoices.filepath; itemChoices[1] = textfilecontent54_ItemsChoices.pattern; itemChoices[2] = textfilecontent54_ItemsChoices.instance; items[0] = filePath; items[1] = pattern; items[2] = instance; } } fileContentObject.Items = items; fileContentObject.Textfilecontent54ItemsElementName = itemChoices; return fileContentObject; }
private bool ExistsVariableDefined(EntitySimpleBaseType entityType) { return (entityType.var_ref != null); }
private IEnumerable<string> ReturnTheSameValue(EntitySimpleBaseType entityType) { List<String> values = new List<string>(); values.Add(entityType.Value); return values; }
private fileeffectiverights53_object CreateFileEffectiveRightsObject( IEnumerable<EntitySimpleBaseType> entities, bool useFilepathEntity = true) { var itemsElementName = new List<fileeffectiverights53_object_ItemsChoices>(); if (useFilepathEntity) itemsElementName.Add(fileeffectiverights53_object_ItemsChoices.filepath); else { itemsElementName.Add(fileeffectiverights53_object_ItemsChoices.path); if (entities.ElementAt(1) == null) entities = new EntitySimpleBaseType[] { entities.First(), entities.Last() }; else itemsElementName.Add(fileeffectiverights53_object_ItemsChoices.filename); } itemsElementName.Add(fileeffectiverights53_object_ItemsChoices.trustee_sid); return new fileeffectiverights53_object() { id = "oval:modsic.fakeobject:obj:1", version = "1", Fileeffectiverights53ObjectItemsElementName = itemsElementName.ToArray(), Items = entities.ToArray() }; }