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
- XmlSchemaRedefine.cs
- AlphaSortedEnumConverter.cs
- AccessedThroughPropertyAttribute.cs
- EntityFunctions.cs
- EmptyStringExpandableObjectConverter.cs
- FlowPanelDesigner.cs
- SchemaCollectionPreprocessor.cs
- NotSupportedException.cs
- lengthconverter.cs
- FormViewModeEventArgs.cs
- BufferedGraphicsContext.cs
- CapabilitiesPattern.cs
- ToolboxItemCollection.cs
- ConvertTextFrag.cs
- EntityDataSourceDesignerHelper.cs
- SpecularMaterial.cs
- XPathDocumentNavigator.cs
- EncodingInfo.cs
- OpenFileDialog.cs
- ReflectionUtil.cs
- UnsafeNativeMethods.cs
- CachedBitmap.cs
- AppLevelCompilationSectionCache.cs
- QuaternionAnimation.cs
- Constraint.cs
- CodeMethodInvokeExpression.cs
- ExpressionBuilderContext.cs
- ResponseStream.cs
- ConfigXmlSignificantWhitespace.cs
- RedistVersionInfo.cs
- Track.cs
- TraceInternal.cs
- DelegatingChannelListener.cs
- HtmlInputRadioButton.cs
- FrameSecurityDescriptor.cs
- HostedHttpContext.cs
- Roles.cs
- RotationValidation.cs
- CodeTypeConstructor.cs
- SqlWebEventProvider.cs
- DataGridHeaderBorder.cs
- CompositeCollectionView.cs
- dataprotectionpermissionattribute.cs
- LazyTextWriterCreator.cs
- PropertyChangedEventManager.cs
- FontClient.cs
- WorkItem.cs
- NativeWindow.cs
- ControlSerializer.cs
- CodeCompileUnit.cs
- HtmlSelect.cs
- ContractComponent.cs
- SerializationInfoEnumerator.cs
- SystemIPGlobalStatistics.cs
- MultiByteCodec.cs
- QueryOperatorEnumerator.cs
- ChtmlSelectionListAdapter.cs
- XsltContext.cs
- ChannelRequirements.cs
- IOException.cs
- ObjectTypeMapping.cs
- MappingModelBuildProvider.cs
- DecoderExceptionFallback.cs
- _ListenerAsyncResult.cs
- RewritingSimplifier.cs
- DataGridSortCommandEventArgs.cs
- SingleSelectRootGridEntry.cs
- Collection.cs
- Parser.cs
- CellLabel.cs
- documentsequencetextcontainer.cs
- DataGridViewComboBoxCell.cs
- _NtlmClient.cs
- PropertyValidationContext.cs
- FocusWithinProperty.cs
- EdmProviderManifest.cs
- Style.cs
- BuildManagerHost.cs
- XmlSchemaComplexContent.cs
- SessionPageStateSection.cs
- CodeRegionDirective.cs
- ParserExtension.cs
- WindowsButton.cs
- DataMemberFieldConverter.cs
- OperationFormatUse.cs
- TabPageDesigner.cs
- ReferencedType.cs
- SynchronizationValidator.cs
- MenuAutomationPeer.cs
- HttpModulesSection.cs
- QuaternionAnimation.cs
- TextUtf8RawTextWriter.cs
- ListBoxItemWrapperAutomationPeer.cs
- ObjectStateFormatter.cs
- GeneratedCodeAttribute.cs
- __Error.cs
- ItemCheckedEvent.cs
- Logging.cs
- GetFileNameResult.cs
- ExecutedRoutedEventArgs.cs