Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Configuration / IssuedTokenParametersElement.cs / 1 / IssuedTokenParametersElement.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Configuration { using System; using System.ServiceModel; using System.ServiceModel.Description; using System.Collections.ObjectModel; using System.ComponentModel; using System.Configuration; using System.IO; using System.ServiceModel.Security; using System.IdentityModel.Tokens; using System.ServiceModel.Channels; using System.ServiceModel.Security.Tokens; using System.Text; using System.Xml; public sealed partial class IssuedTokenParametersElement : ConfigurationElement { CollectionoptionalIssuedTokenParameters = null; public IssuedTokenParametersElement() { } [ConfigurationProperty(ConfigurationStrings.DefaultMessageSecurityVersion)] [TypeConverter(typeof(MessageSecurityVersionConverter))] public MessageSecurityVersion DefaultMessageSecurityVersion { get { return (MessageSecurityVersion)base[ConfigurationStrings.DefaultMessageSecurityVersion]; } set { base[ConfigurationStrings.DefaultMessageSecurityVersion] = value; } } [ConfigurationProperty(ConfigurationStrings.AdditionalRequestParameters)] public XmlElementElementCollection AdditionalRequestParameters { get {return (XmlElementElementCollection) base[ConfigurationStrings.AdditionalRequestParameters]; } } [ConfigurationProperty(ConfigurationStrings.ClaimTypeRequirements)] public ClaimTypeElementCollection ClaimTypeRequirements { get {return (ClaimTypeElementCollection) base[ConfigurationStrings.ClaimTypeRequirements]; } } [ConfigurationProperty(ConfigurationStrings.Issuer)] public IssuedTokenParametersEndpointAddressElement Issuer { get {return (IssuedTokenParametersEndpointAddressElement) base[ConfigurationStrings.Issuer]; } } [ConfigurationProperty(ConfigurationStrings.IssuerMetadata)] public EndpointAddressElementBase IssuerMetadata { get {return (EndpointAddressElementBase) base[ConfigurationStrings.IssuerMetadata]; } } [ConfigurationProperty(ConfigurationStrings.KeySize, DefaultValue = 0)] [IntegerValidator(MinValue = 0)] public int KeySize { get {return (int) base[ConfigurationStrings.KeySize]; } set {base[ConfigurationStrings.KeySize] = value; } } [ConfigurationProperty(ConfigurationStrings.KeyType, DefaultValue = IssuedSecurityTokenParameters.defaultKeyType)] [ServiceModelEnumValidator(typeof(System.IdentityModel.Tokens.SecurityKeyTypeHelper))] public SecurityKeyType KeyType { get {return (SecurityKeyType) base[ConfigurationStrings.KeyType]; } set {base[ConfigurationStrings.KeyType] = value; } } internal Collection OptionalIssuedTokenParameters { get { // OptionalIssuedTokenParameters built on assumption that configuration is writable. // This should be protected at the callers site. If assumption is invalid, then // configuration system is in an indeterminate state. Need to stop in a manner that // user code can not capture. if (this.IsReadOnly()) { DiagnosticUtility.DebugAssert("IssuedTokenParametersElement.OptionalIssuedTokenParameters should only be called by Admin APIs"); DiagnosticUtility.FailFast("IssuedTokenParametersElement.OptionalIssuedTokenParameters should only be called by Admin APIs"); } // No need to worry about a race condition here-- this method is not meant to be called by multi-threaded // apps. It is only supposed to be called by svcutil and single threaded equivalents. if (this.optionalIssuedTokenParameters == null) { this.optionalIssuedTokenParameters = new Collection (); } return this.optionalIssuedTokenParameters; } } [ConfigurationProperty(ConfigurationStrings.TokenType, DefaultValue = "")] [StringValidator(MinLength = 0)] public string TokenType { get {return (string) base[ConfigurationStrings.TokenType]; } set { if (String.IsNullOrEmpty(value)) { value = String.Empty; } base[ConfigurationStrings.TokenType] = value; } } internal void ApplyConfiguration(IssuedSecurityTokenParameters parameters) { if (parameters == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("parameters")); if (this.AdditionalRequestParameters != null) { foreach (XmlElementElement e in this.AdditionalRequestParameters) { parameters.AdditionalRequestParameters.Add(e.XmlElement); } } if (this.ClaimTypeRequirements != null) { foreach (ClaimTypeElement c in this.ClaimTypeRequirements) { parameters.ClaimTypeRequirements.Add(new ClaimTypeRequirement(c.ClaimType, c.IsOptional)); } } parameters.KeySize = this.KeySize; parameters.KeyType = this.KeyType; parameters.DefaultMessageSecurityVersion = this.DefaultMessageSecurityVersion; if (!string.IsNullOrEmpty(this.TokenType)) { parameters.TokenType = this.TokenType; } if (PropertyValueOrigin.Default != this.ElementInformation.Properties[ConfigurationStrings.Issuer].ValueOrigin) { this.Issuer.Validate(); parameters.IssuerAddress = ConfigLoader.LoadEndpointAddress(this.Issuer); if (!string.IsNullOrEmpty(this.Issuer.Binding)) { parameters.IssuerBinding = ConfigLoader.LookupBinding(this.Issuer.Binding, this.Issuer.BindingConfiguration, this.EvaluationContext); } } if (PropertyValueOrigin.Default != this.ElementInformation.Properties[ConfigurationStrings.IssuerMetadata].ValueOrigin) { parameters.IssuerMetadataAddress = ConfigLoader.LoadEndpointAddress(this.IssuerMetadata); } } internal void Copy(IssuedTokenParametersElement source) { if (this.IsReadOnly()) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigReadOnly))); } if (null == source) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("source"); } foreach (XmlElementElement xmlElement in source.AdditionalRequestParameters) { XmlElementElement newElement = new XmlElementElement(); newElement.Copy(xmlElement); this.AdditionalRequestParameters.Add(newElement); } foreach (ClaimTypeElement c in source.ClaimTypeRequirements) { this.ClaimTypeRequirements.Add(new ClaimTypeElement(c.ClaimType, c.IsOptional)); } this.KeySize = source.KeySize; this.KeyType = source.KeyType; this.TokenType = source.TokenType; this.DefaultMessageSecurityVersion = source.DefaultMessageSecurityVersion; if (PropertyValueOrigin.Default != source.ElementInformation.Properties[ConfigurationStrings.Issuer].ValueOrigin) { this.Issuer.Copy(source.Issuer); } if (PropertyValueOrigin.Default != source.ElementInformation.Properties[ConfigurationStrings.IssuerMetadata].ValueOrigin) { this.IssuerMetadata.Copy(source.IssuerMetadata); } } internal IssuedSecurityTokenParameters Create(bool createTemplateOnly, SecurityKeyType templateKeyType) { IssuedSecurityTokenParameters result = new IssuedSecurityTokenParameters(); if (!createTemplateOnly) { this.ApplyConfiguration(result); } else { result.KeyType = templateKeyType; } return result; } internal void InitializeFrom(IssuedSecurityTokenParameters source, bool initializeNestedBindings) { if (null == source) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("source"); this.KeyType = source.KeyType; if (source.KeySize > 0) { this.KeySize = source.KeySize; } this.TokenType = source.TokenType; if (source.IssuerAddress != null) this.Issuer.InitializeFrom(source.IssuerAddress); if (source.DefaultMessageSecurityVersion != null) this.DefaultMessageSecurityVersion = source.DefaultMessageSecurityVersion; if (source.IssuerBinding != null && initializeNestedBindings) { this.Issuer.BindingConfiguration = this.Issuer.Address.ToString(); string bindingSectionName; BindingsSection.TryAdd(this.Issuer.BindingConfiguration, source.IssuerBinding, out bindingSectionName); this.Issuer.Binding = bindingSectionName; } if (source.IssuerMetadataAddress != null) { this.IssuerMetadata.InitializeFrom(source.IssuerMetadataAddress); } foreach (XmlElement element in source.AdditionalRequestParameters) { this.AdditionalRequestParameters.Add(new XmlElementElement(element)); } foreach (ClaimTypeRequirement c in source.ClaimTypeRequirements) { this.ClaimTypeRequirements.Add(new ClaimTypeElement(c.ClaimType, c.IsOptional)); } foreach (IssuedSecurityTokenParameters.AlternativeIssuerEndpoint alternativeIssuer in source.AlternativeIssuerEndpoints) { IssuedTokenParametersElement element = new IssuedTokenParametersElement(); element.Issuer.InitializeFrom(alternativeIssuer.IssuerAddress); if (initializeNestedBindings) { element.Issuer.BindingConfiguration = element.Issuer.Address.ToString(); string bindingSectionName; BindingsSection.TryAdd(element.Issuer.BindingConfiguration, alternativeIssuer.IssuerBinding, out bindingSectionName); element.Issuer.Binding = bindingSectionName; } this.OptionalIssuedTokenParameters.Add(element); } } protected override bool SerializeToXmlElement(XmlWriter writer, String elementName) { bool writeMe = base.SerializeToXmlElement(writer, elementName); bool writeComment = this.OptionalIssuedTokenParameters.Count > 0; if (writeComment && writer != null) { MemoryStream memoryStream = new MemoryStream(); using (XmlTextWriter commentWriter = new XmlTextWriter(memoryStream, Encoding.UTF8)) { commentWriter.Formatting = Formatting.Indented; commentWriter.WriteStartElement(ConfigurationStrings.AlternativeIssuedTokenParameters); foreach (IssuedTokenParametersElement element in this.OptionalIssuedTokenParameters) { element.SerializeToXmlElement(commentWriter, ConfigurationStrings.IssuedTokenParameters); } commentWriter.WriteEndElement(); commentWriter.Flush(); string commentString = new UTF8Encoding().GetString(memoryStream.GetBuffer(), 0, (int) memoryStream.Length); writer.WriteComment(commentString.Substring(1, commentString.Length - 1)); commentWriter.Close(); } } return writeMe || writeComment; } protected override void Unmerge(ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode) { if (sourceElement is IssuedTokenParametersElement) { IssuedTokenParametersElement source = (IssuedTokenParametersElement)sourceElement; this.optionalIssuedTokenParameters = source.optionalIssuedTokenParameters; } base.Unmerge(sourceElement, parentElement, saveMode); } } } // 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
- EnvelopedSignatureTransform.cs
- oledbconnectionstring.cs
- NamespaceInfo.cs
- RowToParametersTransformer.cs
- UIEndRequest.cs
- Calendar.cs
- CodeMemberMethod.cs
- TypeViewSchema.cs
- OleDbDataAdapter.cs
- TransformCollection.cs
- JournalEntryStack.cs
- ObjectDisposedException.cs
- SiteMapDataSource.cs
- elementinformation.cs
- EncryptedPackage.cs
- XmlWriterTraceListener.cs
- TextDecoration.cs
- QilCloneVisitor.cs
- AsyncPostBackErrorEventArgs.cs
- DataControlFieldHeaderCell.cs
- BooleanSwitch.cs
- File.cs
- SqlTypesSchemaImporter.cs
- PublishLicense.cs
- OutputWindow.cs
- Knowncolors.cs
- WebConvert.cs
- DetailsViewCommandEventArgs.cs
- TdsValueSetter.cs
- DataControlButton.cs
- Permission.cs
- XPathDocumentIterator.cs
- SmiContext.cs
- FormViewUpdateEventArgs.cs
- EntityDataSourceValidationException.cs
- NonceToken.cs
- BoundPropertyEntry.cs
- EntityDataSourceChangedEventArgs.cs
- TileBrush.cs
- TemplateBindingExpressionConverter.cs
- TreeNodeCollection.cs
- InvalidDataException.cs
- XmlSchemaExternal.cs
- CultureData.cs
- GroupQuery.cs
- _SafeNetHandles.cs
- IIS7UserPrincipal.cs
- CodeComment.cs
- DesignerActionKeyboardBehavior.cs
- ObjectParameter.cs
- AnyReturnReader.cs
- ToolStripScrollButton.cs
- GZipDecoder.cs
- DataGridViewCellStyleChangedEventArgs.cs
- AddingNewEventArgs.cs
- UncommonField.cs
- PrintDialogException.cs
- Vertex.cs
- XmlMemberMapping.cs
- DispatcherExceptionFilterEventArgs.cs
- XmlDocumentSerializer.cs
- RecognizerInfo.cs
- SafeSecurityHandles.cs
- SchemaCollectionCompiler.cs
- SqlMethodTransformer.cs
- Point3DKeyFrameCollection.cs
- InputProviderSite.cs
- WebRequest.cs
- VirtualizedCellInfoCollection.cs
- FilteredDataSetHelper.cs
- NetworkInformationException.cs
- XPathDocumentNavigator.cs
- DBBindings.cs
- TraceListeners.cs
- WhiteSpaceTrimStringConverter.cs
- HwndProxyElementProvider.cs
- HtmlControlPersistable.cs
- Stroke2.cs
- Char.cs
- XDeferredAxisSource.cs
- MouseActionValueSerializer.cs
- _ConnectStream.cs
- CollectionChangeEventArgs.cs
- FormViewUpdateEventArgs.cs
- PageAsyncTaskManager.cs
- SuppressIldasmAttribute.cs
- ExpressionConverter.cs
- ClientBuildManager.cs
- FixedFindEngine.cs
- InertiaRotationBehavior.cs
- HotSpotCollection.cs
- ProcessInfo.cs
- EventWaitHandle.cs
- RecordManager.cs
- SecurityTokenValidationException.cs
- TextSchema.cs
- UnsafeNativeMethods.cs
- ItemCheckEvent.cs
- RadioButtonFlatAdapter.cs
- ipaddressinformationcollection.cs