Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / PeerTransportSecuritySettings.cs / 1 / PeerTransportSecuritySettings.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel
{
using System;
using System.ComponentModel;
using System.Net;
using System.Net.Security;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Security;
using System.Xml;
public sealed class PeerTransportSecuritySettings
{
internal const PeerTransportCredentialType DefaultCredentialType = PeerTransportCredentialType.Password;
PeerTransportCredentialType credentialType;
internal PeerTransportSecuritySettings()
{
this.credentialType = DefaultCredentialType;
}
internal PeerTransportSecuritySettings(PeerTransportSecuritySettings other)
{
this.credentialType = other.credentialType;
}
internal PeerTransportSecuritySettings(PeerTransportSecurityElement element)
{
credentialType = element.CredentialType;
}
public PeerTransportCredentialType CredentialType
{
get { return this.credentialType; }
set
{
if (!PeerTransportCredentialTypeHelper.IsDefined(value))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException("value", (int)value, typeof(PeerTransportCredentialType)));
}
this.credentialType = value;
}
}
internal void OnImportPolicy(MetadataImporter importer, PolicyConversionContext context)
{
XmlElement element = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(),
PeerTransportPolicyConstants.PeerTransportCredentialType,
TransportPolicyConstants.PeerTransportUri, true);
PeerTransportCredentialType credentialType = PeerTransportCredentialType.Password;
if (element != null)
{
switch (element.InnerText)
{
case PeerTransportPolicyConstants.PeerTransportCredentialTypePassword:
credentialType = PeerTransportCredentialType.Password;
break;
case PeerTransportPolicyConstants.PeerTransportCredentialTypeCertificate:
credentialType = PeerTransportCredentialType.Certificate;
break;
default:
break;
}
}
this.CredentialType = credentialType;
}
internal void OnExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
{
string assertion = "";
switch (this.CredentialType)
{
case PeerTransportCredentialType.Password:
assertion = PeerTransportPolicyConstants.PeerTransportCredentialTypePassword;
break;
case PeerTransportCredentialType.Certificate:
assertion = PeerTransportPolicyConstants.PeerTransportCredentialTypeCertificate;
break;
default:
DiagnosticUtility.DebugAssert("Unsupported value for PeerTransportSecuritySettings.CredentialType");
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
}
XmlDocument doc = new XmlDocument();
XmlElement element = doc.CreateElement(PeerTransportPolicyConstants.PeerTransportPrefix,
PeerTransportPolicyConstants.PeerTransportCredentialType,
TransportPolicyConstants.PeerTransportUri);
element.InnerText = assertion;
context.GetBindingAssertions().Add(element);
}
}
}
// 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
- SQLRoleProvider.cs
- ByteViewer.cs
- ResourceReader.cs
- Stacktrace.cs
- AssemblyAttributesGoHere.cs
- FormViewPagerRow.cs
- CommandConverter.cs
- DataGridViewAdvancedBorderStyle.cs
- HighContrastHelper.cs
- TransformerTypeCollection.cs
- EnumConverter.cs
- OutputCacheSection.cs
- SpoolingTaskBase.cs
- _ConnectStream.cs
- ObjectAnimationUsingKeyFrames.cs
- TrackingMemoryStream.cs
- RequestSecurityTokenResponse.cs
- TableCell.cs
- TransformerInfo.cs
- ClientRequest.cs
- ToolStripDropDownClosingEventArgs.cs
- SizeAnimationUsingKeyFrames.cs
- Rotation3D.cs
- PointAnimation.cs
- CmsUtils.cs
- RegistryConfigurationProvider.cs
- SafeReadContext.cs
- COM2TypeInfoProcessor.cs
- TaskFormBase.cs
- OleDbParameterCollection.cs
- DbProviderFactories.cs
- TextParaLineResult.cs
- TableItemPattern.cs
- ConfigsHelper.cs
- UpdateEventArgs.cs
- SamlAttribute.cs
- BindMarkupExtensionSerializer.cs
- Dynamic.cs
- SemanticAnalyzer.cs
- HyperLinkColumn.cs
- RelatedImageListAttribute.cs
- ObjectSecurity.cs
- UIntPtr.cs
- DataGridColumn.cs
- PackWebRequestFactory.cs
- ItemsChangedEventArgs.cs
- DiscoveryOperationContextExtension.cs
- UrlUtility.cs
- TimeoutValidationAttribute.cs
- SizeAnimation.cs
- PropertyFilter.cs
- ContextMenuAutomationPeer.cs
- WebPartMinimizeVerb.cs
- OuterGlowBitmapEffect.cs
- DataGridClipboardCellContent.cs
- StorageMappingItemCollection.cs
- ValidatedControlConverter.cs
- FontNamesConverter.cs
- xamlnodes.cs
- LinkLabelLinkClickedEvent.cs
- StateChangeEvent.cs
- InstanceCreationEditor.cs
- ResourceAssociationSetEnd.cs
- UriSection.cs
- HierarchicalDataBoundControlAdapter.cs
- EpmContentSerializer.cs
- GridViewCommandEventArgs.cs
- StoreItemCollection.cs
- Serializer.cs
- FontWeight.cs
- AppDomain.cs
- SizeChangedInfo.cs
- AvtEvent.cs
- WebPartConnectionsCancelEventArgs.cs
- WorkerProcess.cs
- AddInActivator.cs
- NavigatorOutput.cs
- PhoneCall.cs
- WpfKnownMember.cs
- ScrollEventArgs.cs
- BaseTemplateParser.cs
- ObjectDataSourceDisposingEventArgs.cs
- AsyncContentLoadedEventArgs.cs
- DataContractSerializerSection.cs
- ArraySortHelper.cs
- SecurityKeyIdentifierClause.cs
- DiscoveryMessageSequenceGenerator.cs
- ApplicationBuildProvider.cs
- ControlAdapter.cs
- AffineTransform3D.cs
- DatatypeImplementation.cs
- EndPoint.cs
- SessionState.cs
- StandardCommands.cs
- ArrayTypeMismatchException.cs
- WindowsStatusBar.cs
- SqlUserDefinedTypeAttribute.cs
- StrongTypingException.cs
- Models.cs
- _LoggingObject.cs