Пример #1
0
        public void removeAttribute(String userId, LinkIDAttribute attribute)
        {
            List <LinkIDAttribute> attributes = new List <LinkIDAttribute>();

            attributes.Add(attribute);
            removeAttributes(userId, attributes);
        }
Пример #2
0
        public void setAttributeValue(string userId, LinkIDAttribute attribute)
        {
            List <LinkIDAttribute> attributes = new List <LinkIDAttribute>();

            attributes.Add(attribute);
            setAttributeValue(userId, attributes);
        }
Пример #3
0
        public static LinkIDAttribute getAttribute(AttributeType attributeType)
        {
            Boolean multivalued   = isMultivalued(attributeType);
            String  attributeId   = getAttributeId(attributeType);
            String  attributeName = attributeType.Name;

            LinkIDAttribute attribute = new LinkIDAttribute(attributeId, attributeName);

            if (attributeType.AttributeValue.Length == 0)
            {
                return(attribute);
            }

            if (attributeType.AttributeValue[0] is AttributeType)
            {
                // compound
                AttributeType          compoundValue   = (AttributeType)attributeType.AttributeValue[0];
                List <LinkIDAttribute> compoundMembers = new List <LinkIDAttribute>();
                foreach (Object memberObject in compoundValue.AttributeValue)
                {
                    AttributeType   memberType = (AttributeType)memberObject;
                    LinkIDAttribute member     = new LinkIDAttribute(attributeId, memberType.Name,
                                                                     memberType.AttributeValue[0]);
                    compoundMembers.Add(member);
                }
                attribute.value = new LinkIDCompound(compoundMembers);
            }
            else
            {
                // single/multi valued
                attribute.value = attributeType.AttributeValue[0];
            }
            return(attribute);
        }
Пример #4
0
        public void createAttribute(String userId, LinkIDAttribute attribute)
        {
            List <LinkIDAttribute> attributes = new List <LinkIDAttribute>();

            attributes.Add(attribute);
            createAttribute(userId, attributes);
        }
        private static void getAttributeValues(ResponseType response, Dictionary <String, List <LinkIDAttribute> > attributeMap)
        {
            if (null == response.Items || response.Items.Length == 0)
            {
                throw new RuntimeException("No assertions in response");
            }
            AssertionType assertion = (AssertionType)response.Items[0];

            if (null == assertion.Items || assertion.Items.Length == 0)
            {
                throw new RuntimeException("No statements in response assertion");
            }
            AttributeStatementType attributeStatement = (AttributeStatementType)assertion.Items[0];

            foreach (Object attributeObject in attributeStatement.Items)
            {
                AttributeType   attributeType = (AttributeType)attributeObject;
                LinkIDAttribute attribute     = Saml2AuthUtil.getAttribute(attributeType);

                List <LinkIDAttribute> attributes;
                if (!attributeMap.ContainsKey(attribute.attributeName))
                {
                    attributes = new List <LinkIDAttribute>();
                }
                else
                {
                    attributes = attributeMap[attribute.attributeName];
                }
                attributes.Add(attribute);
                attributeMap.Remove(attribute.attributeName);
                attributeMap.Add(attribute.attributeName, attributes);
            }
        }
Пример #6
0
        private static CreateItemType getCreateItem(LinkIDAttribute attribute)
        {
            CreateItemType createItem = new CreateItemType();

            createItem.objectType = DataServiceConstants.ATTRIBUTE_OBJECT_TYPE;

            AppDataType newData = new AppDataType();

            newData.Attribute  = getAttributeType(attribute);
            createItem.NewData = newData;
            return(createItem);
        }
Пример #7
0
        public static LinkIDAttribute getAttribute(AttributeType attributeType)
        {
            Boolean multivalued   = isMultivalued(attributeType);
            String  attributeId   = getAttributeId(attributeType);
            String  attributeName = attributeType.Name;

            LinkIDAttribute attribute = new LinkIDAttribute(attributeId, attributeName);

            if (attributeType.AttributeValue.Length == 0)
            {
                return(attribute);
            }

            if (attributeType.AttributeValue[0] is XmlNode[])
            {
                // compound
                List <LinkIDAttribute> compoundMembers = new List <LinkIDAttribute>();
                foreach (XmlNode attributeNode in (XmlNode[])attributeType.AttributeValue[0])
                {
                    if (isAttributeElement(attributeNode))
                    {
                        LinkIDAttribute member = new LinkIDAttribute(attributeId,
                                                                     getXmlAttribute(attributeNode, WebServiceConstants.ATTRIBUTE_NAME_ATTRIBUTE));
                        member.value = attributeNode.InnerText;
                        compoundMembers.Add(member);
                    }
                }
                attribute.value = new LinkIDCompound(compoundMembers);
            }
            else if (attributeType.AttributeValue[0] is AttributeType)
            {
                // also compound but through WS
                AttributeType          compoundValue   = (AttributeType)attributeType.AttributeValue[0];
                List <LinkIDAttribute> compoundMembers = new List <LinkIDAttribute>();
                foreach (Object memberObject in compoundValue.AttributeValue)
                {
                    AttributeType   memberType = (AttributeType)memberObject;
                    LinkIDAttribute member     = new LinkIDAttribute(attributeId, memberType.Name, memberType.AttributeValue[0]);
                    compoundMembers.Add(member);
                }
                attribute.value = new LinkIDCompound(compoundMembers);
            }
            else
            {
                // single/multi valued
                attribute.value = attributeType.AttributeValue[0];
            }
            return(attribute);
        }
Пример #8
0
        private static DeleteItemType getDeleteItem(LinkIDAttribute attribute)
        {
            DeleteItemType deleteItem = new DeleteItemType();

            deleteItem.objectType = DataServiceConstants.ATTRIBUTE_OBJECT_TYPE;
            SelectType select = new SelectType();

            select.Value = attribute.attributeName;
            if (null != attribute.attributeId)
            {
                setAttributeId(select, attribute.attributeId);
            }

            return(deleteItem);
        }
Пример #9
0
        private static ModifyItemType getModifyItem(LinkIDAttribute attribute)
        {
            ModifyItemType modifyItem = new ModifyItemType();

            modifyItem.objectType = DataServiceConstants.ATTRIBUTE_OBJECT_TYPE;

            SelectType select = new SelectType();

            select.Value      = attribute.attributeName;
            modifyItem.Select = select;

            AppDataType newData = new AppDataType();

            newData.Attribute  = getAttributeType(attribute);
            modifyItem.NewData = newData;

            return(modifyItem);
        }
Пример #10
0
        private static AttributeType getAttributeType(LinkIDAttribute attribute)
        {
            AttributeType attributeType = new AttributeType();

            attributeType.Name = attribute.attributeName;
            if (null != attribute.attributeId)
            {
                setAttributeId(attributeType, attribute.attributeId);
            }

            if (null != attribute.value)
            {
                if (attribute.value is LinkIDCompound)
                {
                    // wrap members
                    AttributeType compoundValueAttribute = new AttributeType();
                    attributeType.AttributeValue = new AttributeType[] { compoundValueAttribute };

                    // compounded
                    LinkIDCompound       compound = (LinkIDCompound)attribute.value;
                    List <AttributeType> members  = new List <AttributeType>();
                    foreach (LinkIDAttribute member in compound.members)
                    {
                        AttributeType memberAttributeType = new AttributeType();
                        memberAttributeType.Name           = member.attributeName;
                        memberAttributeType.AttributeValue = new Object[] { member.value };
                        members.Add(memberAttributeType);
                    }
                    compoundValueAttribute.AttributeValue = members.ToArray();
                }
                else
                {
                    // single/multi valued
                    attributeType.AttributeValue = new Object[] { attribute.value };
                }
            }
            return(attributeType);
        }
Пример #11
0
        private static Dictionary <string, List <LinkIDAttribute> > getAttributes(AttributeStatementType attributeStatement)
        {
            Dictionary <string, List <LinkIDAttribute> > attributeMap = new Dictionary <string, List <LinkIDAttribute> >();

            foreach (object item in attributeStatement.Items)
            {
                AttributeType   attributeType = (AttributeType)item;
                LinkIDAttribute attribute     = getAttribute(attributeType);

                List <LinkIDAttribute> attributes;
                if (!attributeMap.ContainsKey(attribute.attributeName))
                {
                    attributes = new List <LinkIDAttribute>();
                }
                else
                {
                    attributes = attributeMap[attribute.attributeName];
                }
                attributes.Add(attribute);
                attributeMap.Remove(attribute.attributeName);
                attributeMap.Add(attribute.attributeName, attributes);
            }
            return(attributeMap);
        }