Ejemplo n.º 1
0
        private SCIMRepresentationAttribute TryAddMetaAttribute()
        {
            var metaAttribute = Attributes.FirstOrDefault(a => a.SchemaAttribute.Name == SCIMConstants.StandardSCIMRepresentationAttributes.Meta);

            if (metaAttribute == null)
            {
                var metaSchemaAttribute = SCIMConstants.StandardSchemas.CommonSchema.Attributes.First();
                metaAttribute = new SCIMRepresentationAttribute(Guid.NewGuid().ToString(), metaSchemaAttribute);
                Attributes.Add(metaAttribute);
            }

            return(metaAttribute);
        }
Ejemplo n.º 2
0
        public object Clone()
        {
            var result = new SCIMRepresentationAttribute(Id)
            {
                Id              = Id,
                ValuesString    = ValuesString.ToList(),
                ValuesBoolean   = ValuesBoolean.ToList(),
                ValuesDateTime  = ValuesDateTime.ToList(),
                ValuesInteger   = ValuesInteger.ToList(),
                ValuesReference = ValuesReference.ToList(),
                SchemaAttribute = (SCIMSchemaAttribute)SchemaAttribute.Clone()
            };

            foreach (var cloneAttribute in Values.Select(v => (SCIMRepresentationAttribute)v.Clone()).ToList())
            {
                result.Add(cloneAttribute);
            }

            return(result);
        }
Ejemplo n.º 3
0
 public void Add(SCIMRepresentationAttribute value)
 {
     Values.Add(value);
     value.Parent = this;
 }
Ejemplo n.º 4
0
 public void AddAttribute(SCIMRepresentationAttribute attribute)
 {
     Attributes.Add(attribute);
 }
        private static ICollection <SCIMRepresentationAttribute> ExtractRepresentationAttributesFromJSON(SCIMSchemaAttribute schemaAttribute, object jObj)
        {
            var jArr = jObj as JArray;
            var parsedRepresentationAttributes = new List <SCIMRepresentationAttribute>();

            if (schemaAttribute.Type == SCIMSchemaAttributeTypes.COMPLEX)
            {
                if (jArr != null)
                {
                    foreach (JObject record in jArr)
                    {
                        var attribute = new SCIMRepresentationAttribute(Guid.NewGuid().ToString(), schemaAttribute);
                        foreach (var attr in SCIMRepresentationHelper.BuildRepresentationAttributes(record, schemaAttribute.SubAttributes))
                        {
                            attribute.Add(attr);
                        }

                        parsedRepresentationAttributes.Add(attribute);
                    }
                }
                else
                {
                    var attribute = new SCIMRepresentationAttribute(Guid.NewGuid().ToString(), schemaAttribute);
                    foreach (var attr in SCIMRepresentationHelper.BuildRepresentationAttributes(jObj as JObject, schemaAttribute.SubAttributes))
                    {
                        attribute.Add(attr);
                    }

                    parsedRepresentationAttributes.Add(attribute);
                }
            }
            else
            {
                switch (schemaAttribute.Type)
                {
                case SCIMSchemaAttributeTypes.BOOLEAN:
                    parsedRepresentationAttributes.Add(new SCIMRepresentationAttribute(Guid.NewGuid().ToString(), schemaAttribute, valuesBoolean: new List <bool> {
                        bool.Parse(jObj.ToString())
                    }));
                    break;

                case SCIMSchemaAttributeTypes.STRING:
                    parsedRepresentationAttributes.Add(new SCIMRepresentationAttribute(Guid.NewGuid().ToString(), schemaAttribute, valuesString: new List <string> {
                        jObj.ToString()
                    }));
                    break;

                case SCIMSchemaAttributeTypes.INTEGER:
                    parsedRepresentationAttributes.Add(new SCIMRepresentationAttribute(Guid.NewGuid().ToString(), schemaAttribute, valuesInteger: new List <int> {
                        int.Parse(jObj.ToString())
                    }));
                    break;

                case SCIMSchemaAttributeTypes.DATETIME:
                    parsedRepresentationAttributes.Add(new SCIMRepresentationAttribute(Guid.NewGuid().ToString(), schemaAttribute, valuesDateTime: new List <DateTime> {
                        DateTime.Parse(jObj.ToString())
                    }));
                    break;
                }
            }

            return(parsedRepresentationAttributes);
        }
 public EnrichParameter(SCIMSchema schema, int order, SCIMRepresentationAttribute attributeNode)
 {
     Schema        = schema;
     Order         = order;
     AttributeNode = attributeNode;
 }
Ejemplo n.º 7
0
        public bool IsSimilar(SCIMRepresentationAttribute attr)
        {
            if (attr.SchemaAttribute.Name != SchemaAttribute.Name)
            {
                return(false);
            }

            switch (attr.SchemaAttribute.Type)
            {
            case SCIMSchemaAttributeTypes.STRING:
                if (attr.ValuesString.All(s => ValuesString.Contains(s)))
                {
                    return(true);
                }
                break;

            case SCIMSchemaAttributeTypes.BINARY:
                if (attr.ValuesBinary.All(s => ValuesBinary.Contains(s)))
                {
                    return(true);
                }
                break;

            case SCIMSchemaAttributeTypes.BOOLEAN:
                if (attr.ValuesBoolean.All(s => ValuesBoolean.Contains(s)))
                {
                    return(true);
                }
                break;

            case SCIMSchemaAttributeTypes.DATETIME:
                if (attr.ValuesDateTime.All(s => ValuesDateTime.Contains(s)))
                {
                    return(true);
                }
                break;

            case SCIMSchemaAttributeTypes.DECIMAL:
                if (attr.ValuesDecimal.All(s => ValuesDecimal.Contains(s)))
                {
                    return(true);
                }
                break;

            case SCIMSchemaAttributeTypes.INTEGER:
                if (attr.ValuesInteger.All(s => ValuesInteger.Contains(s)))
                {
                    return(true);
                }
                break;

            case SCIMSchemaAttributeTypes.REFERENCE:
                if (attr.ValuesReference.All(s => ValuesReference.Contains(s)))
                {
                    return(true);
                }
                break;

            case SCIMSchemaAttributeTypes.COMPLEX:
                if (attr.Values.All(s => Values.Any(v => v.IsSimilar(s))))
                {
                    return(true);
                }
                break;
            }

            return(false);
        }
Ejemplo n.º 8
0
 public SCIMSchema GetSchema(SCIMRepresentationAttribute attribute)
 {
     return(GetSchema(attribute.SchemaAttribute));
 }
Ejemplo n.º 9
0
 public bool ContainsAttribute(SCIMRepresentationAttribute attr)
 {
     return(Attributes.Any(a => a.IsSimilar(attr)));
 }