Exemplo n.º 1
0
        public Policy(string filePath, XElement node, ObjectIndex references)
            : base(filePath, node, node.Attribute("PolicyId").Value, references)
        {
            if (XmlNode.Element(PolicyItem.ns + "BasePolicy")?.Element(PolicyItem.ns + "PolicyId")?.Value != null)
            {
                BasePolicy = new Reference <Policy>(this, XmlNode.Element(PolicyItem.ns + "BasePolicy")?.Element(PolicyItem.ns + "PolicyId")?.Value, references);
            }

            if (XmlNode.Element("UserJourneys") != null)
            {
                this.UserJourneys = new List <UserJourney>();
                foreach (var uj in XmlNode.Element("UserJourneys").Elements("UserJourney"))
                {
                    this.UserJourneys.Add(UserJourney.Load(this, filePath, uj, references));
                }
            }

            // RelyingParty
            this.RelyingParty = RelyingParty.Load(this, filePath, references);
            // BuildingBlocks
            this.BuildingBlocks = BuildingBlocks.Load(this, filePath, references);

            // ClaimsProviders
            if (XmlNode.Element(PolicyItem.ns + "ClaimsProviders") != null)
            {
                this.ClaimsProviders = new List <ClaimsProvider>();
                foreach (var cp in XmlNode.Element(PolicyItem.ns + "ClaimsProviders").Elements(PolicyItem.ns + "ClaimsProvider"))
                {
                    this.ClaimsProviders.Add(ClaimsProvider.Load(this, filePath, cp, references));
                }
            }
        }
        internal static BuildingBlocks Load(Policy policy, string path, ObjectIndex references)
        {
            var xmlNode = policy.XmlNode.Element(PolicyItem.ns + "BuildingBlocks");

            if (xmlNode == null)
            {
                return(null);
            }

            BuildingBlocks item = new BuildingBlocks(path, xmlNode, references, policy);

            // fill data

            // claims schema
            item.ClaimsSchema = new List <ClaimType>();
            if (xmlNode.Element(PolicyItem.ns + "ClaimsSchema") != null)
            {
                foreach (var node in xmlNode.Element(PolicyItem.ns + "ClaimsSchema").Elements(PolicyItem.ns + "ClaimType"))
                {
                    item.ClaimsSchema.Add(PolicyItem.Load <ClaimType>(item, path, node, references));
                }
            }

            // Predicates
            item.Predicates = new List <Predicate>();
            if (xmlNode.Element(PolicyItem.ns + "Predicates") != null)
            {
                // Predicate
                foreach (var node in xmlNode.Element(PolicyItem.ns + "Predicates").Elements(PolicyItem.ns + "Predicate"))
                {
                    item.Predicates.Add(PolicyItem.Load <Predicate>(item, path, node, references));
                }
            }

            // PredicateValidations
            item.PredicateValidations = new List <PredicateValidation>();
            if (xmlNode.Element(PolicyItem.ns + "PredicateValidations") != null)
            {
                foreach (var node in xmlNode.Element(PolicyItem.ns + "PredicateValidations").Elements(PolicyItem.ns + "PredicateValidation"))
                {
                    item.PredicateValidations.Add(PolicyItem.Load <PredicateValidation>(item, path, node, references));
                }
            }

            // ContentDefinitions
            item.ContentDefinitions = new List <ContentDefinition>();
            if (xmlNode.Element(PolicyItem.ns + "ContentDefinitions") != null)
            {
                foreach (var node in xmlNode.Element(PolicyItem.ns + "ContentDefinitions").Elements(PolicyItem.ns + "ContentDefinition"))
                {
                    item.ContentDefinitions.Add(PolicyItem.Load <ContentDefinition>(item, path, node, references));
                }
            }

            // ContentDefinitions
            item.Localization = Localization.Load(item, path, references);


            return(item);
        }
Exemplo n.º 3
0
 public RelyingParty(string filePath, XElement node, ObjectIndex references, Policy policy) :
     base(filePath, node, null, references, policy)
 {
     if (XmlNode.Element(PolicyItem.ns + "DefaultUserJourney")?.Attribute("ReferenceId")?.Value != null)
     {
         DefaultUserJourney = new Reference <UserJourney>(this, XmlNode.Element(PolicyItem.ns + "DefaultUserJourney")?.Attribute("ReferenceId")?.Value, references);
     }
 }
Exemplo n.º 4
0
        internal static Policy LoadXml(string data, string path, ObjectIndex references)
        {
            CancellationTokenSource source = new CancellationTokenSource();
            CancellationToken       token  = source.Token;
            XDocument xml    = XDocument.Parse(data);
            var       policy = new Policy(path, xml.Root, references);

            return(policy);
        }
Exemplo n.º 5
0
        internal static async Task <Policy> LoadXmlAsync(Stream stream, string path, ObjectIndex references)
        {
            CancellationTokenSource source = new CancellationTokenSource();
            CancellationToken       token  = source.Token;
            XDocument xml = await XDocument.LoadAsync(stream, LoadOptions.None, token);

            var policy = new Policy(path, xml.Root, references);

            return(policy);
        }
 public OrchestrationStep(string filePath, XElement node, ObjectIndex references, BaseItem parent)
     : base(filePath, node, null, references, parent)
 {
     if (XmlNode.Attribute(PolicyItem.ns + "ContentDefinitionReferenceId") != null)
     {
         ContentDefinition = new Reference <ContentDefinition>(this, XmlNode.Attribute(PolicyItem.ns + "ContentDefinitionReferenceId").Value, references);
     }
     if (XmlNode.Attribute(PolicyItem.ns + "CpimIssuerTechnicalProfileId") != null)
     {
         CpimIssuerTechnicalProfile = new Reference <TechnicalProfile>(this, XmlNode.Attribute(PolicyItem.ns + "CpimIssuerTechnicalProfileId").Value, references);
     }
 }
Exemplo n.º 7
0
        internal static UserJourney Load(Policy policy, string path, XElement node, ObjectIndex references)
        {
            UserJourney item = new UserJourney(path, node, node.Attribute("Id").Value, references, policy);

            // fill data
            item.OrchestrationSteps = new List <OrchestrationStep>();
            foreach (var step in item.XmlNode.Element(PolicyItem.ns + "OrchestrationSteps").Elements(PolicyItem.ns + "OrchestrationStep"))
            {
                item.OrchestrationSteps.Add(OrchestrationStep.Load(item, path, step, references));
            }
            return(item);
        }
Exemplo n.º 8
0
        public static async Task <List <Policy> > LoadFromUrls(ObjectIndex objectIndex, params string[] ulrs)
        {
            var policies = ulrs.Select(url =>
            {
                return(LoadFromUrl(url, objectIndex));
            });
            var result = await Task.WhenAll(policies);

            var allPolicy = result.ToList();

            return(allPolicy);
        }
Exemplo n.º 9
0
        public static async Task <List <Policy> > LoadFromFiles(ObjectIndex objectIndex, params string[] files)
        {
            var policies = files.Select(path =>
            {
                using Stream fileStream = File.OpenRead(path);
                return(Policy.LoadXmlAsync(fileStream, path, objectIndex));
            });
            var result = await Task.WhenAll(policies);

            var allPolicy = result.ToList();

            return(allPolicy);
        }
Exemplo n.º 10
0
        public static async Task <List <Policy> > LoadFromFolder(string folder, ObjectIndex objectIndex)
        {
            var policies = Directory.EnumerateFiles(folder, "*.xml").Select(path =>
            {
                using Stream fileStream = File.OpenRead(path);
                return(Policy.LoadXmlAsync(fileStream, path, objectIndex));
            });
            var result = await Task.WhenAll(policies);

            var allPolicy = result.ToList();

            return(allPolicy);
        }
Exemplo n.º 11
0
        internal static RelyingParty Load(Policy policy, string path, ObjectIndex references)
        {
            var xmlNode = policy.XmlNode.Element(PolicyItem.ns + "RelyingParty");

            if (xmlNode == null)
            {
                return(null);
            }

            RelyingParty item = new RelyingParty(path, xmlNode, references, policy);

            // fill data
            return(item);
        }
Exemplo n.º 12
0
 public PolicyItem(string filePath, XElement node, string id, ObjectIndex references, BaseItem container)
     : base(filePath, node, id, references, container)
 {
     if (container != null)
     {
         if (container is Policy)
         {
             Policy = (Policy)container;
         }
         else
         {
             Policy = ((PolicyItem)container).Policy;
         }
     }
 }
Exemplo n.º 13
0
        static async Task <Policy> LoadFromUrl(string url, ObjectIndex objectIndex)
        {
            HttpClient client = new HttpClient();
            var        resp   = await client.GetAsync(url);

            if (resp.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var policy = await resp.Content.ReadAsStringAsync();

                return(Policy.LoadXml(policy, url, objectIndex));
            }
            else
            {
                return(null);
            }
        }
 public LocalizedResources(string filePath, XElement node, string id, ObjectIndex references, Localization parent)
     : base(filePath, node, id, references, parent)
 {
 }
Exemplo n.º 15
0
 public Reference(BaseItem item, string id, ObjectIndex references)
 {
     Id          = id;
     _references = references;
     _item       = item;
 }
 public ContentDefinition(string filePath, XElement node, string id, ObjectIndex references, BaseItem parent)
     : base(filePath, node, id, references, parent)
 {
 }
Exemplo n.º 17
0
        internal static T Load <T>(PolicyItem parent, string path, XElement node, ObjectIndex references) where T : PolicyItem
        {
            string id = node.Attribute("Id")?.Value;

            return((T)Activator.CreateInstance(typeof(T), path, node, id, references, parent));
        }
Exemplo n.º 18
0
        internal static Localization Load(BuildingBlocks buildingBlocks, string path, ObjectIndex references)
        {
            var xmlNode = buildingBlocks.XmlNode.Element(PolicyItem.ns + "Localization");

            if (xmlNode == null)
            {
                return(null);
            }

            Localization item = new Localization(path, xmlNode, references, buildingBlocks);

            // fill data
            item.SupportedLanguage = new List <string>();
            foreach (var lang in item.XmlNode.Element(PolicyItem.ns + "SupportedLanguages").Elements(PolicyItem.ns + "SupportedLanguage"))
            {
                item.SupportedLanguage.Add(lang.Value);
            }


            item.LocalizedResources = new List <LocalizedResources>();
            foreach (var locRes in item.XmlNode.Element(PolicyItem.ns + "SupportedLanguages").Elements(PolicyItem.ns + "LocalizedResources"))
            {
                item.LocalizedResources.Add(PolicyItem.Load <LocalizedResources>(item, path, locRes, references));
            }
            return(item);
        }
Exemplo n.º 19
0
 public TechnicalProfile(string filePath, XElement node, string id, ObjectIndex references, BaseItem parent)
     : base(filePath, node, id, references, parent)
 {
 }
Exemplo n.º 20
0
 public Localization(string filePath, XElement node, ObjectIndex references, BuildingBlocks buildingBlocks) :
     base(filePath, node, null, references, buildingBlocks)
 {
 }
Exemplo n.º 21
0
        internal static ClaimsProvider Load(Policy policy, string path, XElement node, ObjectIndex references)
        {
            ClaimsProvider item = new ClaimsProvider(path, node, references, policy);

            // fill data
            item.TechnicalProfiles = new List <TechnicalProfile>();
            foreach (var step in item.XmlNode.Element(PolicyItem.ns + "TechnicalProfiles").Elements(PolicyItem.ns + "TechnicalProfile"))
            {
                item.TechnicalProfiles.Add(TechnicalProfile.Load(item, path, step, references));
            }
            return(item);
        }
Exemplo n.º 22
0
 public UserJourney(string filePath, XElement node, string id, ObjectIndex references, BaseItem parent) : base(filePath, node, id, references, parent)
 {
 }
Exemplo n.º 23
0
 public ClaimsProvider(string filePath, XElement node, ObjectIndex references, BaseItem parent)
     : base(filePath, node, null, references, parent)
 {
 }
Exemplo n.º 24
0
        internal static TechnicalProfile Load(PolicyItem parent, string path, XElement node, ObjectIndex references)
        {
            TechnicalProfile item = new TechnicalProfile(path, node, node.Attribute("Id").Value, references, parent);

            // fill data
            item.OutputClaims = new List <Claim>();
            if (item.XmlNode.Element(PolicyItem.ns + "OutputClaims") != null)
            {
                foreach (var claim in item.XmlNode.Element(PolicyItem.ns + "OutputClaims").Elements(PolicyItem.ns + "OutputClaim"))
                {
                    item.OutputClaims.Add(PolicyItem.Load <Claim>(item, path, claim, references));
                }
            }

            item.InputClaims = new List <Claim>();
            if (item.XmlNode.Element(PolicyItem.ns + "InputClaims") != null)
            {
                foreach (var claim in item.XmlNode.Element(PolicyItem.ns + "InputClaims").Elements(PolicyItem.ns + "InputClaim"))
                {
                    item.InputClaims.Add(PolicyItem.Load <Claim>(item, path, claim, references));
                }
            }
            return(item);
        }
        internal static OrchestrationStep Load(UserJourney journey, string path, XElement node, ObjectIndex references)
        {
            OrchestrationStep item = new OrchestrationStep(path, node, references, journey);

            // fill data

            return(item);
        }
Exemplo n.º 26
0
 public static async Task <Policy> LoadFromStream(Stream stream, string fileName, ObjectIndex objectIndex)
 {
     return(await Policy.LoadXmlAsync(stream, fileName, objectIndex));
 }
Exemplo n.º 27
0
 public Predicate(string filePath, XElement node, string id, ObjectIndex references, BaseItem parent)
     : base(filePath, node, id, references, parent)
 {
 }
Exemplo n.º 28
0
 public Claim(string filePath, XElement node, string id, ObjectIndex references, TechnicalProfile parent)
     : base(filePath, node, id, references, parent)
 {
     ClaimTypeReferenceId = new Reference <Claim>(this, XmlNode.Attribute("ClaimTypeReferenceId").Value, references);
 }
 public BuildingBlocks(string filePath, XElement node, ObjectIndex references, Policy policy) :
     base(filePath, node, null, references, policy)
 {
 }