MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-1f15ee7e9f7da02b6bfb4c5a5e6484eb9fa71b82d3699c54bcc7a31794b4a66d/Microsoft/InfoCards/GetBrowserTokenParameters.cs
2022-08-18 06:28:56 -05:00

111 lines
5.1 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.GetBrowserTokenParameters
// 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 System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.IO;
using System.ServiceModel.Security;
using System.ServiceModel.Security.Tokens;
using System.Xml;
namespace Microsoft.InfoCards
{
internal class GetBrowserTokenParameters
{
private GetBrowserTokenEndpoint m_recipient;
private GetBrowserTokenEndpoint m_issuer;
private Uri m_tokenType;
private List<string> m_requiredClaims;
private List<string> m_optionalClaims;
private int m_flags;
private uint m_privacyVersion;
private Uri m_privacyUrl;
public GetBrowserTokenParameters()
{
this.m_recipient = new GetBrowserTokenEndpoint();
this.m_issuer = new GetBrowserTokenEndpoint();
this.m_requiredClaims = new List<string>();
this.m_optionalClaims = new List<string>();
}
public GetBrowserTokenEndpoint Recipient => this.m_recipient;
public GetBrowserTokenEndpoint Issuer => this.m_issuer;
public IList<string> RequiredClaims => (IList<string>) this.m_requiredClaims.AsReadOnly();
public IList<string> OptionalClaims => (IList<string>) this.m_optionalClaims.AsReadOnly();
public Uri PrivacyUrl => this.m_privacyUrl;
public uint PrivacyVersion => this.m_privacyVersion;
public void Load(BinaryReader reader, int paramVersion)
{
this.m_flags = paramVersion;
this.m_recipient.Load(reader, paramVersion);
this.m_issuer.Load(reader, paramVersion);
string uriString1 = Utility.DeserializeString(reader);
if (!string.IsNullOrEmpty(uriString1))
this.m_tokenType = new Uri(uriString1);
int num1 = reader.ReadInt32();
for (int index = 0; index < num1; ++index)
this.m_requiredClaims.Add(Utility.DeserializeString(reader));
int num2 = reader.ReadInt32();
for (int index = 0; index < num2; ++index)
this.m_optionalClaims.Add(Utility.DeserializeString(reader));
this.m_privacyVersion = reader.ReadUInt32();
string uriString2 = Utility.DeserializeString(reader);
if (!string.IsNullOrEmpty(uriString2))
this.m_privacyUrl = new Uri(uriString2);
else
this.m_privacyUrl = (Uri) null;
}
public CardSpacePolicyElement CreatePolicyElement(
ProtocolProfile protocolProfile)
{
XmlDocument document = new XmlDocument();
XmlElement element = document.CreateElement(protocolProfile.WSTrust.DefaultPrefix, protocolProfile.WSTrust.ClaimsElement, protocolProfile.WSTrust.Namespace);
foreach (string requiredClaim in (IEnumerable<string>) this.RequiredClaims)
element.AppendChild((XmlNode) GetBrowserTokenParameters.CreateClaimElement(document, requiredClaim, false));
foreach (string optionalClaim in (IEnumerable<string>) this.OptionalClaims)
element.AppendChild((XmlNode) GetBrowserTokenParameters.CreateClaimElement(document, optionalClaim, true));
IssuedSecurityTokenParameters securityTokenParameters = new IssuedSecurityTokenParameters();
if ((Uri) null != this.m_tokenType)
securityTokenParameters.TokenType = this.m_tokenType.ToString();
securityTokenParameters.AdditionalRequestParameters.Add(element);
Collection<XmlElement> requestParameters = securityTokenParameters.CreateRequestParameters(protocolProfile.MsgSecurityVersion, (SecurityTokenSerializer) new WSSecurityTokenSerializer(protocolProfile.MsgSecurityVersion.SecurityVersion, true, (SamlSerializer) null, (SecurityStateEncoder) null, (IEnumerable<Type>) null));
foreach (XmlElement xmlElement in requestParameters)
{
if (StringComparer.Ordinal.Equals(xmlElement.LocalName, protocolProfile.WSTrust.KeyType) && StringComparer.Ordinal.Equals(xmlElement.NamespaceURI, protocolProfile.WSTrust.Namespace))
{
xmlElement.RemoveAll();
xmlElement.AppendChild((XmlNode) xmlElement.OwnerDocument.CreateTextNode(protocolProfile.WSTrust.KeyTypeBearer.OriginalString));
break;
}
}
return new CardSpacePolicyElement(this.m_recipient != null ? this.m_recipient.CreateEndpointAddressXml() : (XmlElement) null, this.m_issuer != null ? this.m_issuer.CreateEndpointAddressXml() : (XmlElement) null, requestParameters, this.m_privacyUrl, Convert.ToInt32(this.m_privacyVersion), false);
}
private static XmlElement CreateClaimElement(
XmlDocument document,
string claimUri,
bool optional)
{
XmlElement element = document.CreateElement("wsid", "ClaimType", "http://schemas.xmlsoap.org/ws/2005/05/identity");
element.SetAttribute("Uri", claimUri);
if (optional)
element.SetAttribute("Optional", "true");
return element;
}
}
}