MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-67b630ead60119692b9abbdfd8717c96904ef041127c2cae033c86b718eaa61e/Microsoft/InfoCards/InfoCardSchemas.cs
2022-08-18 06:28:56 -05:00

157 lines
8.0 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.InfoCardSchemas
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: ADE0A079-11DB-4A46-8BDE-D2A592CA8DEA
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Virus.Win32.Expiro.w-67b630ead60119692b9abbdfd8717c96904ef041127c2cae033c86b718eaa61e.exe
using Microsoft.InfoCards.Diagnostics;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.Schema;
namespace Microsoft.InfoCards
{
internal class InfoCardSchemas
{
private static readonly string[] s_primarySchemas = new string[2]
{
"identity.xsd",
"ws-identity-2007.xsd"
};
private static readonly InfoCardSchemas.SchemaLocationResourceMapping[] s_supportingSchemas = new InfoCardSchemas.SchemaLocationResourceMapping[13]
{
new InfoCardSchemas.SchemaLocationResourceMapping("addressing.xsd", "http://www.w3.org/2005/08/addressing/addressing.xsd"),
new InfoCardSchemas.SchemaLocationResourceMapping("addressing04.xsd", "http://schemas.xmlsoap.org/ws/2004/08/addressing/"),
new InfoCardSchemas.SchemaLocationResourceMapping("xmldsig-core-schema.xsd", "http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"),
new InfoCardSchemas.SchemaLocationResourceMapping("xml.xsd", "http://www.w3.org/2001/xml.xsd"),
new InfoCardSchemas.SchemaLocationResourceMapping("xenc-schema.xsd", "http://www.w3.org/TR/xmlenc-core/xenc-schema.xsd"),
new InfoCardSchemas.SchemaLocationResourceMapping("oasis-200401-wss-wssecurity-secext-1.0.xsd", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"),
new InfoCardSchemas.SchemaLocationResourceMapping("oasis-200401-wss-wssecurity-utility-1.0.xsd", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"),
new InfoCardSchemas.SchemaLocationResourceMapping(XmlNames.WSPolicyXmlSoap2004.Instance.LocalSchemaLocation, XmlNames.WSPolicyXmlSoap2004.Instance.SchemaLocation),
new InfoCardSchemas.SchemaLocationResourceMapping(XmlNames.WSPolicyW32007.Instance.LocalSchemaLocation, XmlNames.WSPolicyW32007.Instance.SchemaLocation),
new InfoCardSchemas.SchemaLocationResourceMapping(XmlNames.WSSecurityPolicyXmlSoap2005.Instance.LocalSchemaLocation, XmlNames.WSSecurityPolicyXmlSoap2005.Instance.SchemaLocation),
new InfoCardSchemas.SchemaLocationResourceMapping(XmlNames.WSSecurityPolicyOasis2007.Instance.LocalSchemaLocation, XmlNames.WSSecurityPolicyOasis2007.Instance.SchemaLocation),
new InfoCardSchemas.SchemaLocationResourceMapping(XmlNames.WSTrustXmlSoap2005.Instance.LocalSchemaLocation, XmlNames.WSTrustXmlSoap2005.Instance.SchemaLocation),
new InfoCardSchemas.SchemaLocationResourceMapping(XmlNames.WSTrustOasis2007.Instance.LocalSchemaLocation, XmlNames.WSTrustOasis2007.Instance.SchemaLocation)
};
private static InfoCardSchemas s_current = new InfoCardSchemas(Assembly.GetExecutingAssembly());
private InfoCardSchemas.LocalCachingResolver m_resolver;
private Assembly m_assembly;
private XmlSchemaSet m_schemas;
private object m_sync;
private InfoCardSchemas(Assembly sourceAssembly)
{
this.m_sync = new object();
this.m_resolver = new InfoCardSchemas.LocalCachingResolver();
this.m_assembly = sourceAssembly;
}
public static XmlSchemaSet GetSchemaSet()
{
if (InfoCardSchemas.s_current.m_schemas == null)
{
lock (InfoCardSchemas.s_current.m_sync)
{
if (InfoCardSchemas.s_current.m_schemas == null)
InfoCardSchemas.s_current.InitializeSchemas();
}
}
return InfoCardSchemas.s_current.m_schemas;
}
public static XmlReader CreateReader(string fragment) => InfoCardSchemas.CreateReader(Utility.CreateReaderWithQuotas(fragment));
public static XmlReader CreateReader(Stream stream, XmlReaderSettings settings) => InfoCardSchemas.CreateReader(Utility.CreateReaderWithQuotas(stream), settings);
public static XmlReader CreateReader(
XmlDictionaryReader reader,
XmlReaderSettings settings)
{
return XmlReader.Create((XmlReader) reader, settings);
}
public static XmlReader CreateReader(XmlDictionaryReader reader)
{
XmlReaderSettings defaultReaderSettings = InfoCardSchemas.CreateDefaultReaderSettings();
return XmlReader.Create((XmlReader) reader, defaultReaderSettings);
}
public static XmlReaderSettings CreateDefaultReaderSettings()
{
XmlReaderSettings defaultReaderSettings = new XmlReaderSettings();
defaultReaderSettings.CloseInput = false;
defaultReaderSettings.ValidationType = ValidationType.Schema;
defaultReaderSettings.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings;
defaultReaderSettings.ConformanceLevel = ConformanceLevel.Auto;
defaultReaderSettings.Schemas = InfoCardSchemas.GetSchemaSet();
defaultReaderSettings.ValidationEventHandler += new ValidationEventHandler(InfoCardSchemas.ErrorHandler);
defaultReaderSettings.XmlResolver = (XmlResolver) InfoCardSchemas.s_current.m_resolver;
defaultReaderSettings.IgnoreComments = true;
defaultReaderSettings.IgnoreWhitespace = true;
defaultReaderSettings.IgnoreProcessingInstructions = true;
return defaultReaderSettings;
}
private void InitializeSchemas()
{
InfoCardSchemas.LocalCachingResolver localCachingResolver = new InfoCardSchemas.LocalCachingResolver();
for (int index = 0; index < InfoCardSchemas.s_supportingSchemas.Length; ++index)
{
Uri location = new Uri(InfoCardSchemas.s_supportingSchemas[index].SchemaLocation);
System.Xml.Schema.XmlSchema schema = System.Xml.Schema.XmlSchema.Read(this.m_assembly.GetManifestResourceStream(InfoCardSchemas.s_supportingSchemas[index].ResourceName), new ValidationEventHandler(InfoCardSchemas.ErrorHandler));
localCachingResolver.AddLocalSchema(location, schema);
}
XmlSchemaSet xmlSchemaSet = new XmlSchemaSet();
xmlSchemaSet.XmlResolver = (XmlResolver) localCachingResolver;
for (int index = 0; index < InfoCardSchemas.s_primarySchemas.Length; ++index)
{
System.Xml.Schema.XmlSchema schema = System.Xml.Schema.XmlSchema.Read(this.m_assembly.GetManifestResourceStream(InfoCardSchemas.s_primarySchemas[index]), new ValidationEventHandler(InfoCardSchemas.ErrorHandler));
xmlSchemaSet.Add(schema);
}
xmlSchemaSet.ValidationEventHandler += new ValidationEventHandler(InfoCardSchemas.ErrorHandler);
xmlSchemaSet.Compile();
this.m_resolver = localCachingResolver;
this.m_schemas = xmlSchemaSet;
}
private static void ErrorHandler(object sender, ValidationEventArgs args)
{
if (args.Severity == XmlSeverityType.Error)
throw InfoCardTrace.ThrowHelperCritical((Exception) new XmlSchemaValidationException(SR.GetString("SchemaValidationError", (object) args.Exception.Message), (Exception) args.Exception));
}
private class LocalCachingResolver : XmlUrlResolver
{
private Dictionary<Uri, System.Xml.Schema.XmlSchema> m_table;
public LocalCachingResolver() => this.m_table = new Dictionary<Uri, System.Xml.Schema.XmlSchema>();
public void AddLocalSchema(Uri location, System.Xml.Schema.XmlSchema schema) => this.m_table.Add(location, schema);
public override Uri ResolveUri(Uri baseUri, string relativeUri) => base.ResolveUri(baseUri, relativeUri);
public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn) => (object) this.m_table[absoluteUri];
}
private class SchemaLocationResourceMapping
{
private string m_resourceName;
private string m_schemaLocation;
public SchemaLocationResourceMapping(string resourceName, string schemaLocation)
{
this.m_resourceName = resourceName;
this.m_schemaLocation = schemaLocation;
}
public string ResourceName => this.m_resourceName;
public string SchemaLocation => this.m_schemaLocation;
}
}
}