Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / X509CertificateRecipientClientCredential.cs / 1 / X509CertificateRecipientClientCredential.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Security
{
using System.Collections.Generic;
using System.ServiceModel;
using System.IdentityModel.Selectors;
using System.Runtime.Serialization;
using System.Net;
using System.Security.Principal;
using System.ServiceModel.Security.Tokens;
using System.Security.Cryptography.X509Certificates;
using System.Web.Security;
public sealed class X509CertificateRecipientClientCredential
{
X509ServiceCertificateAuthentication authentication;
internal const StoreLocation DefaultStoreLocation = StoreLocation.CurrentUser;
internal const StoreName DefaultStoreName = StoreName.My;
internal const X509FindType DefaultFindType = X509FindType.FindBySubjectDistinguishedName;
X509Certificate2 defaultCertificate;
Dictionary scopedCertificates;
bool isReadOnly;
internal X509CertificateRecipientClientCredential()
{
this.authentication = new X509ServiceCertificateAuthentication();
this.scopedCertificates = new Dictionary();
}
internal X509CertificateRecipientClientCredential(X509CertificateRecipientClientCredential other)
{
this.authentication = new X509ServiceCertificateAuthentication(other.authentication);
this.defaultCertificate = other.defaultCertificate;
this.scopedCertificates = new Dictionary();
foreach (Uri uri in other.ScopedCertificates.Keys)
{
this.scopedCertificates.Add(uri, other.ScopedCertificates[uri]);
}
this.isReadOnly = other.isReadOnly;
}
public X509Certificate2 DefaultCertificate
{
get
{
return this.defaultCertificate;
}
set
{
ThrowIfImmutable();
this.defaultCertificate = value;
}
}
public Dictionary ScopedCertificates
{
get
{
return this.scopedCertificates;
}
}
public X509ServiceCertificateAuthentication Authentication
{
get
{
return this.authentication;
}
}
public void SetDefaultCertificate(string subjectName, StoreLocation storeLocation, StoreName storeName)
{
if (subjectName == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("subjectName");
}
SetDefaultCertificate(storeLocation, storeName, DefaultFindType, subjectName);
}
public void SetDefaultCertificate(StoreLocation storeLocation, StoreName storeName, X509FindType findType, object findValue)
{
if (findValue == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("findValue");
}
ThrowIfImmutable();
this.defaultCertificate = SecurityUtils.GetCertificateFromStore(storeName, storeLocation, findType, findValue, null);
}
public void SetScopedCertificate(string subjectName, StoreLocation storeLocation, StoreName storeName, Uri targetService)
{
if (subjectName == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("subjectName");
}
SetScopedCertificate(DefaultStoreLocation, DefaultStoreName, DefaultFindType, subjectName, targetService);
}
public void SetScopedCertificate(StoreLocation storeLocation, StoreName storeName, X509FindType findType, object findValue, Uri targetService)
{
if (findValue == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("findValue");
}
if (targetService == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("targetService");
}
ThrowIfImmutable();
X509Certificate2 certificate = SecurityUtils.GetCertificateFromStore(storeName, storeLocation, findType, findValue, null);
ScopedCertificates[targetService] = certificate;
}
internal void MakeReadOnly()
{
this.isReadOnly = true;
this.Authentication.MakeReadOnly();
}
void ThrowIfImmutable()
{
if (this.isReadOnly)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
}
}
}
}
// 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
- PageBuildProvider.cs
- HttpClientProtocol.cs
- StandardCommands.cs
- FormViewDeletedEventArgs.cs
- XmlSchemaElement.cs
- AuthenticationConfig.cs
- DBBindings.cs
- ZipIOLocalFileBlock.cs
- SecurityVersion.cs
- GraphicsContainer.cs
- SynthesizerStateChangedEventArgs.cs
- ParameterBuilder.cs
- FileVersion.cs
- ToolStripDropDownButton.cs
- IssuerInformation.cs
- StringUtil.cs
- AvTrace.cs
- AlgoModule.cs
- XmlSchemaAnyAttribute.cs
- Queue.cs
- StandardToolWindows.cs
- NumberFunctions.cs
- StaticExtension.cs
- DataGridViewHeaderCell.cs
- DataGridCommandEventArgs.cs
- EdmComplexPropertyAttribute.cs
- EntityDataSourceContextCreatingEventArgs.cs
- DisposableCollectionWrapper.cs
- RadioButtonStandardAdapter.cs
- BindingManagerDataErrorEventArgs.cs
- UIElement3DAutomationPeer.cs
- RSACryptoServiceProvider.cs
- DurableInstance.cs
- DataSourceControl.cs
- PropertyChangingEventArgs.cs
- StackSpiller.cs
- MonthChangedEventArgs.cs
- HitTestResult.cs
- VisualBasicHelper.cs
- TraceSource.cs
- MarshalDirectiveException.cs
- DefaultTextStore.cs
- CancelEventArgs.cs
- MergeFilterQuery.cs
- Process.cs
- DataGridViewColumnTypeEditor.cs
- DesignerPainter.cs
- XmlQueryOutput.cs
- InternalRelationshipCollection.cs
- WSDualHttpSecurity.cs
- AbstractDataSvcMapFileLoader.cs
- SiteMapDataSourceView.cs
- EntitySetBaseCollection.cs
- EditingCommands.cs
- ObjectConverter.cs
- ToolStripCodeDomSerializer.cs
- XmlSchemaSimpleTypeRestriction.cs
- ErrorWebPart.cs
- NativeMethods.cs
- ListItemConverter.cs
- LogReserveAndAppendState.cs
- AssociatedControlConverter.cs
- Matrix.cs
- NativeWindow.cs
- _LazyAsyncResult.cs
- SoapAttributes.cs
- TextSpan.cs
- DocumentReferenceCollection.cs
- oledbmetadatacolumnnames.cs
- DataBoundControl.cs
- Image.cs
- CustomWebEventKey.cs
- RegisteredExpandoAttribute.cs
- AnimatedTypeHelpers.cs
- SetStoryboardSpeedRatio.cs
- MimeFormImporter.cs
- PermissionSetTriple.cs
- ListMarkerSourceInfo.cs
- HasActivatableWorkflowEvent.cs
- HierarchicalDataSourceControl.cs
- Italic.cs
- MoveSizeWinEventHandler.cs
- HttpRuntimeSection.cs
- Color.cs
- ConfigXmlText.cs
- X509CertificateEndpointIdentity.cs
- ConnectionsZoneDesigner.cs
- InputMethodStateTypeInfo.cs
- ConfigurationStrings.cs
- StylusEventArgs.cs
- FormView.cs
- TemplateEditingVerb.cs
- LabelLiteral.cs
- SyntaxCheck.cs
- XmlSchemaSimpleTypeList.cs
- XmlWriterTraceListener.cs
- ToggleButton.cs
- DataGridItemEventArgs.cs
- PolicyVersion.cs
- MultiViewDesigner.cs