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); }
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); } }
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); }
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); } }
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); }
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); }
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); }
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); }
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); }
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; } } }
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) { }
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) { }
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)); }
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); }
public TechnicalProfile(string filePath, XElement node, string id, ObjectIndex references, BaseItem parent) : base(filePath, node, id, references, parent) { }
public Localization(string filePath, XElement node, ObjectIndex references, BuildingBlocks buildingBlocks) : base(filePath, node, null, references, buildingBlocks) { }
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); }
public UserJourney(string filePath, XElement node, string id, ObjectIndex references, BaseItem parent) : base(filePath, node, id, references, parent) { }
public ClaimsProvider(string filePath, XElement node, ObjectIndex references, BaseItem parent) : base(filePath, node, null, references, parent) { }
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); }
public static async Task <Policy> LoadFromStream(Stream stream, string fileName, ObjectIndex objectIndex) { return(await Policy.LoadXmlAsync(stream, fileName, objectIndex)); }
public Predicate(string filePath, XElement node, string id, ObjectIndex references, BaseItem parent) : base(filePath, node, id, references, parent) { }
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) { }