// Decompiled with JetBrains decompiler // Type: Microsoft.InfoCards.PolicyFactory // Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // MVID: ADE0A079-11DB-4A46-8BDE-D2A592CA8DEA // Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Virus.Win32.Expiro.w-1f15ee7e9f7da02b6bfb4c5a5e6484eb9fa71b82d3699c54bcc7a31794b4a66d.exe using Microsoft.InfoCards.Diagnostics; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; using System.IdentityModel.Selectors; using System.IO; using System.ServiceModel; using System.ServiceModel.Security.Tokens; using System.Text; using System.Xml; namespace Microsoft.InfoCards { internal class PolicyFactory { private PolicyFactory() { } public static Policy CreatePolicyFromUnwrappedPolicyXml(string originalPolicyXml) { string rstPolicyXml = string.Format((IFormatProvider) CultureInfo.InvariantCulture, "<{0}:{1} xmlns:{0}='{2}'>{3}", (object) XmlNames.WSSecurityPolicyXmlSoap2005.Instance.DefaultPrefix, (object) XmlNames.WSSecurityPolicyXmlSoap2005.Instance.RequestSecurityTokenTemplate, (object) XmlNames.WSSecurityPolicyXmlSoap2005.Instance.Namespace, (object) originalPolicyXml); return new Policy(originalPolicyXml, rstPolicyXml); } public static InfoCardPolicy CreatePolicyForCustomTokenProvider( EndpointAddress immediateTokenRecipient, IssuedSecurityTokenParameters issuedTokenParameters, ProtocolProfile profile) { ParsedPolicy parsedPolicy = PolicyFactory.CreateParsedPolicy((IEnumerable) issuedTokenParameters.CreateRequestParameters(profile.MsgSecurityVersion, (SecurityTokenSerializer) profile.TokenSerializer)); return new InfoCardPolicy(immediateTokenRecipient, issuedTokenParameters.IssuerAddress, parsedPolicy, PolicyUsageContext.GetToken, (string) null, 0U, (RecipientIdentity) null, false); } public static InfoCardPolicy CreatePolicyForGetBrowserTokenRequest( CardSpacePolicyElement policyElement, Uri recipientPolicyNoticeLink, uint recipientPolicyNoticeVersion, RecipientIdentity recipientIdentity, PolicyUsageContext usageContext) { EndpointAddress immediateTokenRecipient = (EndpointAddress) null; if (!string.IsNullOrEmpty(policyElement.Target.OuterXml)) immediateTokenRecipient = PolicyFactory.CreateEndpointAddressFromString(policyElement.Target.OuterXml); EndpointAddress issuer = (EndpointAddress) null; if (policyElement.Issuer != null && !string.IsNullOrEmpty(policyElement.Issuer.OuterXml)) issuer = PolicyFactory.CreateEndpointAddressFromString(policyElement.Issuer.OuterXml); ParsedPolicy parsedPolicy = PolicyFactory.CreateParsedPolicy((IEnumerable) policyElement.Parameters); return new InfoCardPolicy(immediateTokenRecipient, issuer, parsedPolicy, usageContext, (Uri) null != recipientPolicyNoticeLink ? recipientPolicyNoticeLink.ToString() : (string) null, recipientPolicyNoticeVersion, recipientIdentity, false); } public static InfoCardPolicy CreatePolicyForIntermediateGetBrowserTokenRequest( CardSpacePolicyElement policyElement, Uri recipientPolicyNoticeLink, uint recipientPolicyNoticeVersion, RecipientIdentity recipientIdentity) { EndpointAddress immediateTokenRecipient = (EndpointAddress) null; if (!string.IsNullOrEmpty(policyElement.Target.OuterXml)) immediateTokenRecipient = PolicyFactory.CreateEndpointAddressFromString(policyElement.Target.OuterXml); EndpointAddress issuer = (EndpointAddress) null; if (policyElement.Issuer != null && !string.IsNullOrEmpty(policyElement.Issuer.OuterXml)) issuer = PolicyFactory.CreateEndpointAddressFromString(policyElement.Issuer.OuterXml); ParsedPolicy parsedPolicy = PolicyFactory.CreateParsedPolicy((IEnumerable) policyElement.Parameters); return new InfoCardPolicy(immediateTokenRecipient, issuer, parsedPolicy, PolicyUsageContext.Intermediate, (Uri) null != recipientPolicyNoticeLink ? recipientPolicyNoticeLink.ToString() : (string) null, recipientPolicyNoticeVersion, recipientIdentity, false); } public static InfoCardPolicy CreatePolicyForGetTokenRequest( BinaryReader reader, string recipientXml, string issuerXml, string policyXml, bool isManaged) { if (!string.IsNullOrEmpty(policyXml)) { string xml = string.Format((IFormatProvider) CultureInfo.InvariantCulture, "<{0}:{1} xmlns:{0}='{2}'>{3}", (object) XmlNames.WSSecurityPolicyXmlSoap2005.Instance.DefaultPrefix, (object) XmlNames.WSSecurityPolicyXmlSoap2005.Instance.RequestSecurityTokenTemplate, (object) XmlNames.WSSecurityPolicyXmlSoap2005.Instance.Namespace, (object) policyXml); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xml); Collection elements = new Collection(); foreach (XmlElement childNode in xmlDocument.DocumentElement.ChildNodes) elements.Add(childNode); ParsedPolicy parsedPolicy = PolicyFactory.CreateParsedPolicy((IEnumerable) elements); return new InfoCardPolicy(!string.IsNullOrEmpty(recipientXml) ? PolicyFactory.CreateEndpointAddressFromString(recipientXml) : (EndpointAddress) null, !string.IsNullOrEmpty(issuerXml) ? PolicyFactory.CreateEndpointAddressFromString(issuerXml) : (EndpointAddress) null, parsedPolicy, PolicyUsageContext.GetToken, (string) null, 0U, (RecipientIdentity) null, isManaged); } if (!isManaged) throw InfoCardTrace.ThrowHelperError((Exception) new PolicyValidationException(SR.GetString("InvalidPolicySpecified"))); return new InfoCardPolicy(!string.IsNullOrEmpty(recipientXml) ? PolicyFactory.CreateEndpointAddressFromString(recipientXml) : (EndpointAddress) null, !string.IsNullOrEmpty(issuerXml) ? PolicyFactory.CreateEndpointAddressFromString(issuerXml) : (EndpointAddress) null, (ParsedPolicy) null, PolicyUsageContext.GetToken, (string) null, 0U, (RecipientIdentity) null, isManaged); } private static ParsedPolicy CreateParsedPolicy(IEnumerable elements) { try { XmlElement xmlElement = (XmlElement) null; StringBuilder stringBuilder1 = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); foreach (XmlElement element in elements) { stringBuilder2.Append(element.OuterXml); if (element.LocalName == "SecondaryParameters" && element.NamespaceURI == "http://docs.oasis-open.org/ws-sx/ws-trust/200512") xmlElement = element; else stringBuilder1.Append(element.OuterXml); } return xmlElement != null ? new ParsedPolicy(stringBuilder2.ToString(), stringBuilder1.ToString(), xmlElement.InnerXml) : new ParsedPolicy(stringBuilder2.ToString(), stringBuilder1.ToString(), (string) null); } catch (XmlException ex) { throw InfoCardTrace.ThrowHelperError((Exception) new PolicyValidationException(SR.GetString("InvalidPolicySpecified"), (Exception) ex)); } } private static EndpointAddress CreateEndpointAddressFromString(string fragment) { try { using (XmlReader reader = PolicyFactory.LoadXmlIntoReader(fragment.Trim())) { reader.MoveToElement(); return EndpointAddress.ReadFrom(XmlDictionaryReader.CreateDictionaryReader(reader)); } } catch (Exception ex) { if (!InfoCardTrace.IsFatal(ex)) throw InfoCardTrace.ThrowHelperError((Exception) new PolicyValidationException(SR.GetString("ServiceInvalidEprInPolicy"), ex)); throw; } } private static XmlReader LoadXmlIntoReader(string fragment) => InfoCardSchemas.CreateReader(fragment); } }