Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / X509ServiceCertificateAuthentication.cs / 1 / X509ServiceCertificateAuthentication.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Security { using System.IdentityModel.Selectors; using System.ServiceModel; using System.Security.Cryptography.X509Certificates; public class X509ServiceCertificateAuthentication { internal const X509CertificateValidationMode DefaultCertificateValidationMode = X509CertificateValidationMode.ChainTrust; internal const X509RevocationMode DefaultRevocationMode = X509RevocationMode.Online; internal const StoreLocation DefaultTrustedStoreLocation = StoreLocation.CurrentUser; static X509CertificateValidator defaultCertificateValidator; X509CertificateValidationMode certificateValidationMode = DefaultCertificateValidationMode; X509RevocationMode revocationMode = DefaultRevocationMode; StoreLocation trustedStoreLocation = DefaultTrustedStoreLocation; X509CertificateValidator customCertificateValidator = null; bool isReadOnly; internal X509ServiceCertificateAuthentication() { } internal X509ServiceCertificateAuthentication(X509ServiceCertificateAuthentication other) { this.certificateValidationMode = other.certificateValidationMode; this.customCertificateValidator = other.customCertificateValidator; this.revocationMode = other.revocationMode; this.trustedStoreLocation = other.trustedStoreLocation; this.isReadOnly = other.isReadOnly; } internal static X509CertificateValidator DefaultCertificateValidator { get { if (defaultCertificateValidator == null) { bool useMachineContext = DefaultTrustedStoreLocation == StoreLocation.LocalMachine; X509ChainPolicy chainPolicy = new X509ChainPolicy(); chainPolicy.RevocationMode = DefaultRevocationMode; defaultCertificateValidator = X509CertificateValidator.CreateChainTrustValidator(useMachineContext, chainPolicy); } return defaultCertificateValidator; } } public X509CertificateValidationMode CertificateValidationMode { get { return this.certificateValidationMode; } set { X509CertificateValidationModeHelper.Validate(value); ThrowIfImmutable(); this.certificateValidationMode = value; } } public X509RevocationMode RevocationMode { get { return this.revocationMode; } set { ThrowIfImmutable(); this.revocationMode = value; } } public StoreLocation TrustedStoreLocation { get { return this.trustedStoreLocation; } set { ThrowIfImmutable(); this.trustedStoreLocation = value; } } public X509CertificateValidator CustomCertificateValidator { get { return this.customCertificateValidator; } set { ThrowIfImmutable(); this.customCertificateValidator = value; } } internal bool TryGetCertificateValidator(out X509CertificateValidator validator) { validator = null; if (this.certificateValidationMode == X509CertificateValidationMode.None) { validator = X509CertificateValidator.None; } else if (this.certificateValidationMode == X509CertificateValidationMode.PeerTrust) { validator = X509CertificateValidator.PeerTrust; } else if (this.certificateValidationMode == X509CertificateValidationMode.Custom) { validator = this.customCertificateValidator; } else { bool useMachineContext = this.trustedStoreLocation == StoreLocation.LocalMachine; X509ChainPolicy chainPolicy = new X509ChainPolicy(); chainPolicy.RevocationMode = this.revocationMode; if (this.certificateValidationMode == X509CertificateValidationMode.ChainTrust) { validator = X509CertificateValidator.CreateChainTrustValidator(useMachineContext, chainPolicy); } else { validator = X509CertificateValidator.CreatePeerOrChainTrustValidator(useMachineContext, chainPolicy); } } return (validator != null); } internal X509CertificateValidator GetCertificateValidator() { X509CertificateValidator result; if (!TryGetCertificateValidator(out result)) { DiagnosticUtility.DebugAssert(this.customCertificateValidator == null, ""); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MissingCustomCertificateValidator))); } return result; } internal void MakeReadOnly() { this.isReadOnly = true; } 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
- Panel.cs
- ipaddressinformationcollection.cs
- Attribute.cs
- EdgeProfileValidation.cs
- LineSegment.cs
- Emitter.cs
- PrintDocument.cs
- RemotingClientProxy.cs
- RijndaelManaged.cs
- URL.cs
- FaultCode.cs
- CellParaClient.cs
- SwitchElementsCollection.cs
- ScriptControlDescriptor.cs
- FixedBufferAttribute.cs
- Rect.cs
- VerificationAttribute.cs
- Parser.cs
- DataTablePropertyDescriptor.cs
- BlurEffect.cs
- RequestValidator.cs
- ManualResetEvent.cs
- DrawingServices.cs
- MetadataArtifactLoaderComposite.cs
- XmlILAnnotation.cs
- XmlWellformedWriter.cs
- Container.cs
- TypeUnloadedException.cs
- SoapCodeExporter.cs
- DesignerValidatorAdapter.cs
- Roles.cs
- Expr.cs
- Point3DCollectionConverter.cs
- ThreadAbortException.cs
- MouseBinding.cs
- StorageFunctionMapping.cs
- SafeRegistryKey.cs
- _NegotiateClient.cs
- DataServiceQueryOfT.cs
- WorkflowMessageEventArgs.cs
- MatrixTransform3D.cs
- Vector3D.cs
- HttpCapabilitiesBase.cs
- DrawingContextWalker.cs
- MarkupProperty.cs
- BooleanProjectedSlot.cs
- TableHeaderCell.cs
- XmlAnyAttributeAttribute.cs
- filewebresponse.cs
- CheckBox.cs
- ViewManager.cs
- BrowserCapabilitiesCompiler.cs
- UTF8Encoding.cs
- DataKey.cs
- LedgerEntryCollection.cs
- FixedSOMTable.cs
- XPathNodeIterator.cs
- VisualTreeHelper.cs
- DesignBindingConverter.cs
- FieldNameLookup.cs
- DomainConstraint.cs
- RefType.cs
- StringAttributeCollection.cs
- FileDataSourceCache.cs
- AssociationEndMember.cs
- OutputCacheModule.cs
- AccessibilityApplicationManager.cs
- UnsafeNativeMethods.cs
- GeometryGroup.cs
- NonSerializedAttribute.cs
- TargetInvocationException.cs
- LoginView.cs
- TreeBuilderXamlTranslator.cs
- ToolStripSeparator.cs
- FormViewRow.cs
- NodeLabelEditEvent.cs
- AxHost.cs
- XmlSchemaAnnotated.cs
- HttpModulesSection.cs
- Simplifier.cs
- SoapCodeExporter.cs
- SqlCacheDependencyDatabase.cs
- ExternalFile.cs
- ServiceMemoryGates.cs
- SoapIgnoreAttribute.cs
- TypedColumnHandler.cs
- StaticContext.cs
- HttpStaticObjectsCollectionWrapper.cs
- Module.cs
- XmlSchemaSimpleTypeList.cs
- SignedInfo.cs
- ReadOnlyHierarchicalDataSourceView.cs
- Evidence.cs
- GAC.cs
- MenuItem.cs
- ContentPlaceHolderDesigner.cs
- SkipQueryOptionExpression.cs
- AstTree.cs
- DecimalSumAggregationOperator.cs
- XsdBuilder.cs