You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
ikvm-native
libgc
llvm
m4
man
mcs
build
class
Accessibility
Commons.Xml.Relaxng
Cscompmgd
CustomMarshalers
Facades
I18N
IBM.Data.DB2
ICSharpCode.SharpZipLib
Microsoft.Build
Microsoft.Build.Engine
Microsoft.Build.Framework
Microsoft.Build.Tasks
Microsoft.Build.Utilities
Microsoft.CSharp
Microsoft.NuGet.Build.Tasks
Microsoft.VisualC
Microsoft.Web.Infrastructure
MicrosoftAjaxLibrary
Mono.Btls.Interface
Mono.C5
Mono.CSharp
Mono.Cairo
Mono.Cecil
Mono.Cecil.Mdb
Mono.CodeContracts
Mono.CompilerServices.SymbolWriter
Mono.Data.Sqlite
Mono.Data.Tds
Mono.Debugger.Soft
Mono.Http
Mono.Management
Mono.Messaging
Mono.Messaging.RabbitMQ
Mono.Options
Mono.Parallel
Mono.Posix
Mono.Profiler.Log
Mono.Runtime.Tests
Mono.Security
Mono.Security.Win32
Mono.Simd
Mono.Tasklets
Mono.WebBrowser
Mono.XBuild.Tasks
Novell.Directory.Ldap
PEAPI
RabbitMQ.Client
SMDiagnostics
System
System.ComponentModel.Composition.4.5
System.ComponentModel.DataAnnotations
System.Configuration
System.Configuration.Install
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Linq
System.Data.OracleClient
System.Data.Services
System.Data.Services.Client
System.Deployment
System.Design
System.DirectoryServices
System.DirectoryServices.Protocols
System.Drawing
System.Drawing.Design
System.Dynamic
System.EnterpriseServices
System.IO.Compression
System.IO.Compression.FileSystem
System.IdentityModel
System.IdentityModel.Selectors
System.Json
System.Json.Microsoft
System.Management
System.Messaging
System.Net
System.Net.Http
System.Net.Http.Formatting
System.Net.Http.WebRequest
System.Net.Http.WinHttpHandler
System.Numerics
System.Numerics.Vectors
System.Reactive.Core
System.Reactive.Debugger
System.Reactive.Experimental
System.Reactive.Interfaces
System.Reactive.Linq
System.Reactive.Observable.Aliases
System.Reactive.PlatformServices
System.Reactive.Providers
System.Reactive.Runtime.Remoting
System.Reactive.Windows.Forms
System.Reactive.Windows.Threading
System.Reflection.Context
System.Runtime.Caching
System.Runtime.CompilerServices.Unsafe
System.Runtime.DurableInstancing
System.Runtime.Remoting
System.Runtime.Serialization
System.Runtime.Serialization.Formatters.Soap
System.Security
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.Web
System.ServiceProcess
System.Threading.Tasks.Dataflow
System.Transactions
System.Web
System.Web.Abstractions
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Extensions
System.Web.Extensions.Design
System.Web.Http
System.Web.Http.SelfHost
System.Web.Http.WebHost
System.Web.Mobile
System.Web.Mvc3
System.Web.Razor
System.Web.RegularExpressions
System.Web.Routing
System.Web.Services
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
System.Windows
System.Windows.Forms
System.Windows.Forms.DataVisualization
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.XML
System.Xaml
System.Xml.Linq
System.Xml.Serialization
SystemWebTestShim
WebMatrix.Data
WindowsBase
aot-compiler
corlib
dlr
doc
legacy
lib
monodoc
notes
reference-assemblies
referencesource
SMDiagnostics
System
System.Activities
System.Activities.Core.Presentation
System.Activities.DurableInstancing
System.Activities.Presentation
System.ComponentModel.DataAnnotations
System.Configuration
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Entity.Design
System.Data.Linq
System.Data.SqlXml
System.IdentityModel
InternalApis
System
IdentityModel
Claims
Configuration
Diagnostics
Metadata
Policy
Protocols
Selectors
Tokens
AbsoluteUriCollection.cs
AggregateTokenResolver.cs
AsymmetricProofDescriptor.cs
AsymmetricSecurityKey.cs
AudienceRestriction.cs
AudienceUriValidationFailedException.cs
AuthenticationContext.cs
AuthenticationMethods.cs
AuthorizationPolicy.cs
BinaryKeyIdentifierClause.cs
BootstrapContext.cs
ComputedKeyAlgorithms.cs
ConfigurationBasedIssuerNameRegistry.cs
DEREncoding.cs
DefaultTokenReplayCache.cs
EmptySecurityKeyIdentifierClause.cs
EncryptedKeyEncryptingCredentials.cs
EncryptedKeyIdentifierClause.cs
EncryptedSecurityToken.cs
EncryptedSecurityTokenHandler.cs
EncryptedTokenDecryptionFailedException.cs
EncryptingCredentials.cs
EndpointAuthorizationPolicy.cs
GenericXmlSecurityKeyIdentifierClause.cs
GenericXmlSecurityToken.cs
IssuerNameRegistry.cs
IssuerTokenResolver.cs
KerberosReceiverSecurityToken.cs
KerberosRequestorSecurityToken.cs
KerberosSecurityTokenHandler.cs
KerberosTicketHashIdentifierClause.cs
KeyInfoSerializer.cs
LocalIdKeyIdentifierClause.cs
MruSessionSecurityTokenCache.cs
ProofDescriptor.cs
RsaKeyIdentifierClause.cs
RsaSecurityKey.cs
RsaSecurityToken.cs
RsaSecurityTokenHandler.cs
Saml2Action.cs
Saml2Advice.cs
Saml2Assertion.cs
Saml2AssertionKeyIdentifierClause.cs
Saml2Attribute.cs
Saml2AttributeStatement.cs
Saml2AudienceRestriction.cs
Saml2AuthenticationContext.cs
Saml2AuthenticationStatement.cs
Saml2AuthorizationDecisionStatement.cs
Saml2Conditions.cs
Saml2Constants.cs
Saml2Evidence.cs
Saml2Id.cs
Saml2NameIdentifier.cs
Saml2ProxyRestriction.cs
Saml2SecurityKeyIdentifierClause.cs
Saml2SecurityToken.cs
Saml2SecurityTokenHandler.cs.REMOVED.git-id
Saml2Statement.cs
Saml2Subject.cs
Saml2SubjectConfirmation.cs
Saml2SubjectConfirmationData.cs
Saml2SubjectLocality.cs
SamlAccessDecision.cs
SamlAction.cs
SamlAdvice.cs
SamlAssertion.cs
SamlAssertionKeyIdentifierClause.cs
SamlAttribute.cs
SamlAttributeKeyComparer.cs
SamlAttributeStatement.cs
SamlAudienceRestrictionCondition.cs
SamlAuthenticationClaimResource.cs
SamlAuthenticationStatement.cs
SamlAuthorityBinding.cs
SamlAuthorizationDecisionClaimResource.cs
SamlAuthorizationDecisionStatement.cs
SamlCondition.cs
SamlConditions.cs
SamlConstants.cs
SamlDoNotCacheCondition.cs
SamlEvidence.cs
SamlNameIdentifierClaimResource.cs
SamlSecurityKeyIdentifierClause.cs
SamlSecurityToken.cs
SamlSecurityTokenHandler.cs.REMOVED.git-id
SamlSecurityTokenRequirement.cs
SamlSerializer.cs
SamlStatement.cs
SamlSubject.cs
SamlSubjectStatement.cs
SctAuthorizationPolicy.cs
SecurityAlgorithms.cs
SecurityKey.cs
SecurityKeyElement.cs
SecurityKeyIdentifier.cs
SecurityKeyIdentifierClause.cs
SecurityKeyIdentifierClauseSerializer.cs
SecurityKeyType.cs
SecurityKeyUsage.cs
SecurityToken.cs
SecurityTokenDescriptor.cs
SecurityTokenElement.cs
SecurityTokenException.cs
SecurityTokenExpiredException.cs
SecurityTokenHandler.cs
SecurityTokenHandlerCollection.cs
SecurityTokenHandlerCollectionManager.cs
SecurityTokenHandlerConfiguration.cs
SecurityTokenNotYetValidException.cs
SecurityTokenReplayDetectedException.cs
SecurityTokenSerializerAdapter.cs
SecurityTokenTypes.cs
SecurityTokenValidationException.cs
SessionDictionary.cs
SessionSecurityToken.cs
SessionSecurityTokenCache.cs
SessionSecurityTokenCacheKey.cs
SessionSecurityTokenHandler.cs
SigningCredentials.cs
SymmetricKey.cs
SymmetricProofDescriptor.cs
SymmetricSecurityKey.cs
TokenReplayCache.cs
UserNameSecurityToken.cs
UserNameSecurityTokenHandler.cs
WSSecurityJan2004.cs
WSSecurityXXX2005.cs
WSTrust.cs
WindowsSecurityToken.cs
WindowsUserNameSecurityTokenHandler.cs
WrappedSaml2AssertionKeyIdentifierClause.cs
X509AsymmetricSecurityKey.cs
X509CertificateStoreTokenResolver.cs
X509DataSecurityKeyIdentifierClauseSerializer.cs
X509EncryptingCredentials.cs
X509IssuerSerialKeyIdentifierClause.cs
X509NTAuthChainTrustValidator.cs
X509RawDataKeyIdentifierClause.cs
X509SecurityToken.cs
X509SecurityTokenHandler.cs
X509SigningCredentials.cs
X509SubjectKeyIdentifierClause.cs
X509ThumbprintKeyIdentifierClause.cs
X509WindowsSecurityToken.cs
XmlDsigSep2000.cs
XmlEncApr2001.cs
Asn1IntegerConverter.cs
AsyncResult.cs
AsynchronousOperationException.cs
BadRequestException.cs
BoundedCache.cs
BufferManager.cs
BufferManagerOutputStream.cs
CanonicalFormWriter.cs
CanonicalizationDriver.cs
CipherDataElement.cs
CookieTransform.cs
CryptoApi.cs
CryptoHelper.cs
DateTimeFormats.cs
DateTimeUtil.cs
DeflateCookieTransform.cs
DelegatingXmlDictionaryReader.cs
DelegatingXmlDictionaryWriter.cs
DiagnosticUtilityExtensions.cs
DictionaryManager.cs
EncryptedDataElement.cs
EncryptedKeyElement.cs
EncryptedTypeElement.cs
EncryptionMethodElement.cs
EnvelopedSignatureReader.cs
EnvelopedSignatureTransform.cs
EnvelopedSignatureWriter.cs
ExclusiveCanonicalizationTransform.cs
ExtendedTransformFactory.cs
HashStream.cs
IPrefixGenerator.cs
ISecurityElement.cs
ISignatureValueSecurityElement.cs
IWrappedTokenKeyResolver.cs
IdentityModelDictionary.cs
IdentityModelStrings.cs
IdentityModelStringsVersion1.cs
IdentityModelWrappedXmlDictionaryReader.cs
ImmutableCollection.cs
KeyInfo.cs
LimitExceededException.cs
LocalAppContextSwitches.cs
MostlySingletonList.cs
NativeMethods.cs
OpenObject.cs
Pool.cs
PreDigestedSignedInfo.cs
Privilege.cs
ProductConstants.cs
ProtectedDataCookieTransform.cs
Psha1DerivedKeyGenerator.cs
RequestException.cs
RequestFailedException.cs
RijndaelCryptoServiceProvider.cs
RsaEncryptionCookieTransform.cs
RsaSignatureCookieTransform.cs
SafeCryptHandles.cs
SamlDelegatingWriter.cs
Scope.cs
SecurityMessageSerializationException.cs
SecurityTokenService.cs
SecurityUniqueId.cs
SecurityUtils.cs
SignatureResourcePool.cs
SignatureTargetIdManager.cs
SignatureVerificationFailedException.cs
SignedXml.cs
SspiContextFlags.cs
SspiHelper.cs
SspiSafeHandles.cs
SspiWrapper.cs
StandardTransformFactory.cs
StrTransform.cs
StringUtil.cs
Transform.cs
TransformFactory.cs
TypedAsyncResult.cs
UniqueId.cs
UnsupportedTokenTypeBadRequestException.cs
UriUtil.cs
WSAddressing10Constants.cs
WSAddressing200408Constants.cs
WSMetadataExchangeConstants.cs
WSSecureConversation13Constants.cs
WSSecureConversationFeb2005Constants.cs
WSSecurity10Constants.cs
WSSecurity11Constants.cs
WSSecurityUtilityConstants.cs
WSUtilityConstants.cs
WrappedReader.cs
WrappedXmlDictionaryReader.cs
X509CertificateValidatorEx.cs
X509Util.cs
XD.cs.REMOVED.git-id
XmlAttributeHolder.cs
XmlBuffer.cs
XmlEncryptionConstants.cs
XmlHelper.cs
XmlSignatureConstants.cs
XmlUtil.cs
ServiceModel
AppContextDefaultValues.cs
TD.Designer.cs
System.IdentityModel.Selectors
System.Net
System.Numerics
System.Runtime.Caching
System.Runtime.DurableInstancing
System.Runtime.Serialization
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Activities
System.ServiceModel.Channels
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.WasHosting
System.ServiceModel.Web
System.Web
System.Web.ApplicationServices
System.Web.DataVisualization
System.Web.DynamicData
System.Web.Entity
System.Web.Entity.Design
System.Web.Extensions
System.Web.Mobile
System.Web.Routing
System.Web.Services
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.WorkflowServices
System.Xaml.Hosting
System.Xml
System.Xml.Linq
XamlBuildTask
mscorlib
LICENSE.txt
PATENTS.TXT
README.Mono.md
README.md
test-helpers
LICENSE
Makefile
Open.snk
README
ecma.pub
mono.pub
mono.snk
msfinal.pub
reactive.pub
silverlight.pub
winfx.pub
winfx3.pub
docs
errors
ilasm
jay
mcs
nunit24
packages
tests
tools
AUTHORS
COPYING
INSTALL.txt
Makefile
MonoIcon.png
README
ScalableMonoIcon.svg
mkinstalldirs
mk
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
293 lines
12 KiB
C#
293 lines
12 KiB
C#
![]() |
//-----------------------------------------------------------------------------
|
||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||
|
//-----------------------------------------------------------------------------
|
||
|
|
||
|
namespace System.IdentityModel.Tokens
|
||
|
{
|
||
|
using System.Collections.Generic;
|
||
|
using System.Collections.ObjectModel;
|
||
|
using System.Globalization;
|
||
|
using System.IdentityModel;
|
||
|
using System.IdentityModel.Claims;
|
||
|
using System.IdentityModel.Selectors;
|
||
|
using System.Runtime.Serialization;
|
||
|
using System.Xml.Serialization;
|
||
|
using System.Xml;
|
||
|
|
||
|
public class SamlAuthenticationStatement : SamlSubjectStatement
|
||
|
{
|
||
|
DateTime authenticationInstant = DateTime.UtcNow.ToUniversalTime();
|
||
|
string authenticationMethod = XD.SamlDictionary.UnspecifiedAuthenticationMethod.Value;
|
||
|
readonly ImmutableCollection<SamlAuthorityBinding> authorityBindings = new ImmutableCollection<SamlAuthorityBinding>();
|
||
|
string dnsAddress;
|
||
|
string ipAddress;
|
||
|
bool isReadOnly = false;
|
||
|
|
||
|
public SamlAuthenticationStatement()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public SamlAuthenticationStatement(SamlSubject samlSubject,
|
||
|
string authenticationMethod,
|
||
|
DateTime authenticationInstant,
|
||
|
string dnsAddress,
|
||
|
string ipAddress,
|
||
|
IEnumerable<SamlAuthorityBinding> authorityBindings)
|
||
|
: base(samlSubject)
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(authenticationMethod))
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("authenticationMethod", SR.GetString(SR.SAMLAuthenticationStatementMissingAuthenticationMethod));
|
||
|
|
||
|
this.authenticationMethod = authenticationMethod;
|
||
|
this.authenticationInstant = authenticationInstant.ToUniversalTime();
|
||
|
this.dnsAddress = dnsAddress;
|
||
|
this.ipAddress = ipAddress;
|
||
|
|
||
|
if (authorityBindings != null)
|
||
|
{
|
||
|
foreach (SamlAuthorityBinding binding in authorityBindings)
|
||
|
{
|
||
|
if (binding == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.SAMLEntityCannotBeNullOrEmpty, XD.SamlDictionary.Assertion.Value));
|
||
|
|
||
|
this.authorityBindings.Add(binding);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
CheckObjectValidity();
|
||
|
}
|
||
|
|
||
|
public DateTime AuthenticationInstant
|
||
|
{
|
||
|
get { return this.authenticationInstant; }
|
||
|
set
|
||
|
{
|
||
|
if (isReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
|
||
|
this.authenticationInstant = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public string AuthenticationMethod
|
||
|
{
|
||
|
get { return this.authenticationMethod; }
|
||
|
set
|
||
|
{
|
||
|
if (isReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
|
||
|
if (string.IsNullOrEmpty(value))
|
||
|
this.authenticationMethod = XD.SamlDictionary.UnspecifiedAuthenticationMethod.Value;
|
||
|
else
|
||
|
this.authenticationMethod = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static string ClaimType
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return ClaimTypes.Authentication;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public IList<SamlAuthorityBinding> AuthorityBindings
|
||
|
{
|
||
|
get { return this.authorityBindings; }
|
||
|
}
|
||
|
|
||
|
public string DnsAddress
|
||
|
{
|
||
|
get { return this.dnsAddress; }
|
||
|
set
|
||
|
{
|
||
|
if (isReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
|
||
|
this.dnsAddress = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public string IPAddress
|
||
|
{
|
||
|
get { return this.ipAddress; }
|
||
|
set
|
||
|
{
|
||
|
if (isReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
|
||
|
this.ipAddress = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public override bool IsReadOnly
|
||
|
{
|
||
|
get { return this.isReadOnly; }
|
||
|
}
|
||
|
|
||
|
public override void MakeReadOnly()
|
||
|
{
|
||
|
if (!this.isReadOnly)
|
||
|
{
|
||
|
foreach (SamlAuthorityBinding binding in this.authorityBindings)
|
||
|
{
|
||
|
binding.MakeReadOnly();
|
||
|
}
|
||
|
|
||
|
this.authorityBindings.MakeReadOnly();
|
||
|
|
||
|
this.isReadOnly = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected override void AddClaimsToList(IList<Claim> claims)
|
||
|
{
|
||
|
if (claims == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("claims");
|
||
|
|
||
|
claims.Add(new Claim(ClaimTypes.Authentication, new SamlAuthenticationClaimResource(this.authenticationInstant, this.authenticationMethod, this.dnsAddress, this.ipAddress, this.authorityBindings), Rights.PossessProperty));
|
||
|
}
|
||
|
|
||
|
void CheckObjectValidity()
|
||
|
{
|
||
|
if (this.SamlSubject == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLSubjectStatementRequiresSubject)));
|
||
|
|
||
|
// Authenticaton instant is required. We will throw an exception if it is not present while
|
||
|
// deserializing a SAML Authentication statement. When creating a new Authentication statement
|
||
|
// we set this value to UtcNow.
|
||
|
|
||
|
if (string.IsNullOrEmpty(this.authenticationMethod))
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAuthenticationStatementMissingAuthenticationMethod)));
|
||
|
}
|
||
|
|
||
|
public override void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
|
||
|
{
|
||
|
if (reader == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));
|
||
|
|
||
|
if (samlSerializer == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));
|
||
|
|
||
|
#pragma warning suppress 56506 // samlSerializer.DictionaryManager is never null.
|
||
|
SamlDictionary dictionary = samlSerializer.DictionaryManager.SamlDictionary;
|
||
|
|
||
|
string authInstance = reader.GetAttribute(dictionary.AuthenticationInstant, null);
|
||
|
if (string.IsNullOrEmpty(authInstance))
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAuthenticationStatementMissingAuthenticationInstanceOnRead)));
|
||
|
this.authenticationInstant = DateTime.ParseExact(
|
||
|
authInstance, SamlConstants.AcceptedDateTimeFormats, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None).ToUniversalTime();
|
||
|
|
||
|
this.authenticationMethod = reader.GetAttribute(dictionary.AuthenticationMethod, null);
|
||
|
if (string.IsNullOrEmpty(this.authenticationMethod))
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAuthenticationStatementMissingAuthenticationMethodOnRead)));
|
||
|
|
||
|
reader.MoveToContent();
|
||
|
reader.Read();
|
||
|
|
||
|
if (reader.IsStartElement(dictionary.Subject, dictionary.Namespace))
|
||
|
{
|
||
|
SamlSubject subject = new SamlSubject();
|
||
|
subject.ReadXml(reader, samlSerializer, keyInfoSerializer, outOfBandTokenResolver);
|
||
|
base.SamlSubject = subject;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// Subject is a required element for a Authentication Statement clause.
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAuthenticationStatementMissingSubject)));
|
||
|
}
|
||
|
|
||
|
if (reader.IsStartElement(dictionary.SubjectLocality, dictionary.Namespace))
|
||
|
{
|
||
|
this.dnsAddress = reader.GetAttribute(dictionary.SubjectLocalityDNSAddress, null);
|
||
|
this.ipAddress = reader.GetAttribute(dictionary.SubjectLocalityIPAddress, null);
|
||
|
|
||
|
if (reader.IsEmptyElement)
|
||
|
{
|
||
|
reader.MoveToContent();
|
||
|
reader.Read();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
reader.MoveToContent();
|
||
|
reader.Read();
|
||
|
reader.ReadEndElement();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
while (reader.IsStartElement())
|
||
|
{
|
||
|
if (reader.IsStartElement(dictionary.AuthorityBinding, dictionary.Namespace))
|
||
|
{
|
||
|
SamlAuthorityBinding binding = new SamlAuthorityBinding();
|
||
|
binding.ReadXml(reader, samlSerializer, keyInfoSerializer, outOfBandTokenResolver);
|
||
|
this.authorityBindings.Add(binding);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// We do not understand this element.
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLBadSchema, dictionary.AuthenticationStatement)));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
reader.MoveToContent();
|
||
|
reader.ReadEndElement();
|
||
|
}
|
||
|
|
||
|
public override void WriteXml(XmlDictionaryWriter writer, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer)
|
||
|
{
|
||
|
CheckObjectValidity();
|
||
|
|
||
|
if (writer == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("writer"));
|
||
|
|
||
|
if (samlSerializer == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));
|
||
|
|
||
|
#pragma warning suppress 56506 // samlSerializer.DictionaryManager is never null.
|
||
|
SamlDictionary dictionary = samlSerializer.DictionaryManager.SamlDictionary;
|
||
|
|
||
|
writer.WriteStartElement(dictionary.PreferredPrefix.Value, dictionary.AuthenticationStatement, dictionary.Namespace);
|
||
|
|
||
|
writer.WriteStartAttribute(dictionary.AuthenticationMethod, null);
|
||
|
writer.WriteString(this.authenticationMethod);
|
||
|
writer.WriteEndAttribute();
|
||
|
writer.WriteStartAttribute(dictionary.AuthenticationInstant, null);
|
||
|
writer.WriteString(this.authenticationInstant.ToString(SamlConstants.GeneratedDateTimeFormat, CultureInfo.InvariantCulture));
|
||
|
writer.WriteEndAttribute();
|
||
|
|
||
|
this.SamlSubject.WriteXml(writer, samlSerializer, keyInfoSerializer);
|
||
|
|
||
|
if ((this.ipAddress != null) || (this.dnsAddress != null))
|
||
|
{
|
||
|
writer.WriteStartElement(dictionary.PreferredPrefix.Value, dictionary.SubjectLocality, dictionary.Namespace);
|
||
|
|
||
|
if (this.ipAddress != null)
|
||
|
{
|
||
|
writer.WriteStartAttribute(dictionary.SubjectLocalityIPAddress, null);
|
||
|
writer.WriteString(this.ipAddress);
|
||
|
writer.WriteEndAttribute();
|
||
|
}
|
||
|
|
||
|
if (this.dnsAddress != null)
|
||
|
{
|
||
|
writer.WriteStartAttribute(dictionary.SubjectLocalityDNSAddress, null);
|
||
|
writer.WriteString(this.dnsAddress);
|
||
|
writer.WriteEndAttribute();
|
||
|
}
|
||
|
|
||
|
writer.WriteEndElement();
|
||
|
}
|
||
|
|
||
|
for (int i = 0; i < this.authorityBindings.Count; i++)
|
||
|
{
|
||
|
this.authorityBindings[i].WriteXml(writer, samlSerializer, keyInfoSerializer);
|
||
|
}
|
||
|
|
||
|
writer.WriteEndElement();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|