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; DictionaryscopedCertificates; 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
- UpdatePanelTrigger.cs
- CompilerScopeManager.cs
- GridProviderWrapper.cs
- LinqDataSourceDeleteEventArgs.cs
- DesignerToolStripControlHost.cs
- PnrpPermission.cs
- SQLInt32.cs
- CreateInstanceBinder.cs
- CodeAttachEventStatement.cs
- HandlerBase.cs
- CodeMemberMethod.cs
- AssemblyNameUtility.cs
- ExtenderHelpers.cs
- QuadraticBezierSegment.cs
- TrailingSpaceComparer.cs
- ListBoxAutomationPeer.cs
- KeyedPriorityQueue.cs
- IgnoreFileBuildProvider.cs
- BeginStoryboard.cs
- MessageBox.cs
- Size.cs
- MachineSettingsSection.cs
- WorkflowNamespace.cs
- MaskedTextProvider.cs
- HostingEnvironmentException.cs
- CharEnumerator.cs
- AlternateView.cs
- FocusManager.cs
- ColorTransformHelper.cs
- EditCommandColumn.cs
- PersonalizationStateInfoCollection.cs
- LocatorBase.cs
- ProjectionCamera.cs
- SessionParameter.cs
- SqlClientWrapperSmiStreamChars.cs
- ViewGenResults.cs
- PolyBezierSegment.cs
- PointIndependentAnimationStorage.cs
- CaseInsensitiveHashCodeProvider.cs
- AssemblyAttributesGoHere.cs
- Delegate.cs
- PeerNeighborManager.cs
- ProxyManager.cs
- FixedDocumentPaginator.cs
- UriTemplateTrieLocation.cs
- XmlConvert.cs
- PlatformCulture.cs
- SoapSchemaMember.cs
- CLRBindingWorker.cs
- EmissiveMaterial.cs
- GeneralTransform3DCollection.cs
- DataIdProcessor.cs
- InstanceCreationEditor.cs
- Pen.cs
- DataGridViewColumnEventArgs.cs
- GeneralTransform.cs
- Timer.cs
- TextEditorCharacters.cs
- OverflowException.cs
- XPathSelfQuery.cs
- Command.cs
- HttpContext.cs
- DataGridViewLinkCell.cs
- CodeTypeParameter.cs
- ToolStripPanel.cs
- SqlDataAdapter.cs
- MarkupCompiler.cs
- ZipFileInfo.cs
- Socket.cs
- WebPartMenuStyle.cs
- ProviderBase.cs
- HtmlString.cs
- StandardOleMarshalObject.cs
- XmlReflectionImporter.cs
- Selection.cs
- RouteTable.cs
- CharacterHit.cs
- ToolBarOverflowPanel.cs
- LinkedList.cs
- IDataContractSurrogate.cs
- SystemUnicastIPAddressInformation.cs
- Compiler.cs
- HttpClientCertificate.cs
- IdentifierService.cs
- MultiSelectRootGridEntry.cs
- LinqToSqlWrapper.cs
- TypeHelper.cs
- PathGeometry.cs
- TransactionManagerProxy.cs
- DnsPermission.cs
- PathParser.cs
- EffectiveValueEntry.cs
- SessionChannels.cs
- DynamicDataRoute.cs
- TransformerTypeCollection.cs
- RightsManagementPermission.cs
- SchemeSettingElementCollection.cs
- PrintDialog.cs
- wmiprovider.cs
- SiteMapPathDesigner.cs