Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / Tokens / SamlAudienceRestrictionCondition.cs / 1 / SamlAudienceRestrictionCondition.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.IdentityModel.Tokens { using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; using System.IdentityModel; using System.IdentityModel.Selectors; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; public class SamlAudienceRestrictionCondition : SamlCondition { readonly ImmutableCollectionaudiences = new ImmutableCollection (); bool isReadOnly = false; public SamlAudienceRestrictionCondition(IEnumerable audiences) { if (audiences == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("audiences")); foreach (Uri audience in audiences) { if (audience == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.SAMLEntityCannotBeNullOrEmpty, XD.SamlDictionary.Audience.Value)); this.audiences.Add(audience); } CheckObjectValidity(); } public SamlAudienceRestrictionCondition() { } public IList Audiences { get {return this.audiences; } } public override bool IsReadOnly { get { return this.isReadOnly; } } public override void MakeReadOnly() { if (!this.isReadOnly) { this.audiences.MakeReadOnly(); this.isReadOnly = true; } } void CheckObjectValidity() { if (this.audiences.Count == 0) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAudienceRestrictionShouldHaveOneAudience))); } 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; reader.MoveToContent(); reader.Read(); while (reader.IsStartElement()) { if (reader.IsStartElement(dictionary.Audience, dictionary.Namespace)) { reader.MoveToContent(); string audience = reader.ReadString(); if (String.IsNullOrEmpty(audience)) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAudienceRestrictionInvalidAudienceValueOnRead))); this.audiences.Add(new Uri(audience)); reader.MoveToContent(); reader.ReadEndElement(); } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLBadSchema, dictionary.AudienceRestrictionCondition.Value))); } } if (this.audiences.Count == 0) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAudienceRestrictionShouldHaveOneAudienceOnRead))); 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.AudienceRestrictionCondition, dictionary.Namespace); for (int i = 0; i < this.audiences.Count; i++) { writer.WriteElementString(dictionary.Audience, dictionary.Namespace, this.audiences[i].AbsoluteUri); } writer.WriteEndElement(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridViewCellValidatingEventArgs.cs
- TagPrefixAttribute.cs
- remotingproxy.cs
- CroppedBitmap.cs
- EntityDataSourceReferenceGroup.cs
- ResourcesGenerator.cs
- CatalogPartChrome.cs
- Misc.cs
- MetadataArtifactLoaderFile.cs
- SqlTypesSchemaImporter.cs
- ChildrenQuery.cs
- IntranetCredentialPolicy.cs
- MarkupCompilePass2.cs
- HttpModulesSection.cs
- EditorBrowsableAttribute.cs
- DataControlCommands.cs
- PointHitTestResult.cs
- LeaseManager.cs
- WebPartManagerInternals.cs
- XmlNodeReader.cs
- Buffer.cs
- documentsequencetextpointer.cs
- ProcessingInstructionAction.cs
- SafeCloseHandleCritical.cs
- GeometryGroup.cs
- SoundPlayer.cs
- ExpressionLexer.cs
- EvidenceTypeDescriptor.cs
- sqlinternaltransaction.cs
- Matrix3DStack.cs
- CaseInsensitiveComparer.cs
- BindingExpressionBase.cs
- ChineseLunisolarCalendar.cs
- AppDomainInfo.cs
- CatalogPartCollection.cs
- SchemaElementLookUpTable.cs
- DrawingGroup.cs
- EntitySetDataBindingList.cs
- ResourceDictionary.cs
- SoapAttributeOverrides.cs
- QuadraticEase.cs
- DrawingCollection.cs
- GroupQuery.cs
- TimeManager.cs
- DbSourceParameterCollection.cs
- ReplyAdapterChannelListener.cs
- Part.cs
- XmlSignatureProperties.cs
- ProgressBarHighlightConverter.cs
- SpAudioStreamWrapper.cs
- TransformCryptoHandle.cs
- KnownTypesProvider.cs
- COM2PropertyPageUITypeConverter.cs
- SortQuery.cs
- StructuredTypeEmitter.cs
- _BasicClient.cs
- DmlSqlGenerator.cs
- InternalSafeNativeMethods.cs
- GeneralTransform3DTo2D.cs
- OpenFileDialog.cs
- PhysicalOps.cs
- OdbcStatementHandle.cs
- BaseTreeIterator.cs
- SystemWebCachingSectionGroup.cs
- peersecuritysettings.cs
- AnnotationComponentChooser.cs
- GridSplitterAutomationPeer.cs
- LazyTextWriterCreator.cs
- ModulesEntry.cs
- XamlReaderConstants.cs
- ProxyElement.cs
- DispatcherEventArgs.cs
- XmlAttributeProperties.cs
- GacUtil.cs
- DataList.cs
- AndCondition.cs
- DataBinding.cs
- AnalyzedTree.cs
- CaseStatementSlot.cs
- IsolationInterop.cs
- ZipIOFileItemStream.cs
- ManagedIStream.cs
- SoapSchemaMember.cs
- ObjectSpanRewriter.cs
- UseAttributeSetsAction.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- MergablePropertyAttribute.cs
- TypeListConverter.cs
- TextBreakpoint.cs
- DoWorkEventArgs.cs
- DataDocumentXPathNavigator.cs
- StringValidatorAttribute.cs
- RelationshipDetailsRow.cs
- StrongNamePublicKeyBlob.cs
- TemplateControlCodeDomTreeGenerator.cs
- SystemDiagnosticsSection.cs
- Latin1Encoding.cs
- DbMetaDataColumnNames.cs
- QueryRewriter.cs
- SystemKeyConverter.cs