Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / IssuedTokenServiceCredential.cs / 1 / IssuedTokenServiceCredential.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Security { using System.Collections.Generic; using System.IdentityModel.Selectors; using System.IdentityModel.Tokens; using System.ServiceModel; using System.Security.Cryptography.X509Certificates; public class IssuedTokenServiceCredential { internal const bool DefaultAllowUntrustedRsaIssuers = false; internal const AudienceUriMode DefaultAudienceUriMode = AudienceUriMode.BearerKeyOnly; internal const X509CertificateValidationMode DefaultCertificateValidationMode = X509CertificateValidationMode.ChainTrust; internal const X509RevocationMode DefaultRevocationMode = X509RevocationMode.Online; internal const StoreLocation DefaultTrustedStoreLocation = StoreLocation.LocalMachine; ListallowedAudienceUris; AudienceUriMode audienceUriMode = DefaultAudienceUriMode; List knownCertificates; SamlSerializer samlSerializer; X509CertificateValidationMode certificateValidationMode = DefaultCertificateValidationMode; X509RevocationMode revocationMode = DefaultRevocationMode; StoreLocation trustedStoreLocation = DefaultTrustedStoreLocation; X509CertificateValidator customCertificateValidator = null; bool allowUntrustedRsaIssuers = DefaultAllowUntrustedRsaIssuers; bool isReadOnly; internal IssuedTokenServiceCredential() { this.allowedAudienceUris = new List (); this.knownCertificates = new List (); } internal IssuedTokenServiceCredential(IssuedTokenServiceCredential other) { this.audienceUriMode = other.audienceUriMode; this.allowedAudienceUris = new List (other.allowedAudienceUris); this.samlSerializer = other.samlSerializer; this.knownCertificates = new List (other.knownCertificates); this.certificateValidationMode = other.certificateValidationMode; this.customCertificateValidator = other.customCertificateValidator; this.trustedStoreLocation = other.trustedStoreLocation; this.revocationMode = other.revocationMode; this.allowUntrustedRsaIssuers = other.allowUntrustedRsaIssuers; this.isReadOnly = other.isReadOnly; } public IList AllowedAudienceUris { get { if (this.isReadOnly) return this.allowedAudienceUris.AsReadOnly(); else return this.allowedAudienceUris; } } public AudienceUriMode AudienceUriMode { get { return this.audienceUriMode; } set { ThrowIfImmutable(); AudienceUriModeValidationHelper.Validate(audienceUriMode); this.audienceUriMode = value; } } public IList KnownCertificates { get { if (this.isReadOnly) return this.knownCertificates.AsReadOnly(); else return this.knownCertificates; } } public SamlSerializer SamlSerializer { get { return this.samlSerializer; } set { ThrowIfImmutable(); this.samlSerializer = value; } } 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; } } public bool AllowUntrustedRsaIssuers { get { return this.allowUntrustedRsaIssuers; } set { ThrowIfImmutable(); this.allowUntrustedRsaIssuers = value; } } internal X509CertificateValidator GetCertificateValidator() { if (this.certificateValidationMode == X509CertificateValidationMode.None) { return X509CertificateValidator.None; } else if (this.certificateValidationMode == X509CertificateValidationMode.PeerTrust) { return X509CertificateValidator.PeerTrust; } else if (this.certificateValidationMode == X509CertificateValidationMode.Custom) { if (this.customCertificateValidator == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MissingCustomCertificateValidator))); } return this.customCertificateValidator; } else { bool useMachineContext = this.trustedStoreLocation == StoreLocation.LocalMachine; X509ChainPolicy chainPolicy = new X509ChainPolicy(); chainPolicy.RevocationMode = this.revocationMode; if (this.certificateValidationMode == X509CertificateValidationMode.ChainTrust) { return X509CertificateValidator.CreateChainTrustValidator(useMachineContext, chainPolicy); } else { return X509CertificateValidator.CreatePeerOrChainTrustValidator(useMachineContext, chainPolicy); } } } 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
- AuthenticationException.cs
- MethodBuilderInstantiation.cs
- ReferenceEqualityComparer.cs
- EmissiveMaterial.cs
- StyleSheetRefUrlEditor.cs
- CompilerTypeWithParams.cs
- CurrentChangingEventManager.cs
- InternalTransaction.cs
- XPathAxisIterator.cs
- Compiler.cs
- DataGridViewTopLeftHeaderCell.cs
- MD5CryptoServiceProvider.cs
- ChildChangedEventArgs.cs
- DoubleLink.cs
- CodeExpressionRuleDeclaration.cs
- ResourceAttributes.cs
- SqlAliasesReferenced.cs
- SimpleLine.cs
- XmlSchemaSet.cs
- RtfControlWordInfo.cs
- TypeSystemHelpers.cs
- ValidatedControlConverter.cs
- WorkflowTraceTransfer.cs
- SvcFileManager.cs
- AppearanceEditorPart.cs
- ScriptingWebServicesSectionGroup.cs
- FormParameter.cs
- ViewgenGatekeeper.cs
- XmlWrappingReader.cs
- BrowserDefinitionCollection.cs
- dtdvalidator.cs
- RawTextInputReport.cs
- XPathChildIterator.cs
- ScrollPattern.cs
- Membership.cs
- UdpDiscoveryMessageFilter.cs
- PermissionSetTriple.cs
- TableRow.cs
- XPathDescendantIterator.cs
- UInt16.cs
- WindowsRichEditRange.cs
- DiagnosticsConfiguration.cs
- NativeMethods.cs
- ConfigurationStrings.cs
- StateChangeEvent.cs
- DesignerVerbCollection.cs
- ByteAnimationBase.cs
- WebPartZone.cs
- RegionInfo.cs
- DataContext.cs
- DynamicUpdateCommand.cs
- TakeQueryOptionExpression.cs
- DataTemplateSelector.cs
- SchemaTypeEmitter.cs
- AttachmentCollection.cs
- IQueryable.cs
- ContentTextAutomationPeer.cs
- DuplicateWaitObjectException.cs
- BamlResourceSerializer.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- ProtocolElement.cs
- SizeFConverter.cs
- CommonGetThemePartSize.cs
- DataSourceExpressionCollection.cs
- ToolStripHighContrastRenderer.cs
- IriParsingElement.cs
- Unit.cs
- SpecialFolderEnumConverter.cs
- ExtensionMethods.cs
- MsmqInputMessage.cs
- DetailsViewPageEventArgs.cs
- MetadataItemEmitter.cs
- ResourceManager.cs
- DetailsViewPageEventArgs.cs
- LightweightCodeGenerator.cs
- TreeNodeBinding.cs
- VectorConverter.cs
- SecurityDocument.cs
- EntityDataSource.cs
- RtfControlWordInfo.cs
- WebPartsPersonalization.cs
- EDesignUtil.cs
- PlainXmlDeserializer.cs
- UdpContractFilterBehavior.cs
- Transform3DGroup.cs
- ApplicationId.cs
- ComNativeDescriptor.cs
- TableChangeProcessor.cs
- XmlSerializationReader.cs
- SplineQuaternionKeyFrame.cs
- SecuritySessionSecurityTokenProvider.cs
- SaveRecipientRequest.cs
- WindowsAltTab.cs
- CompatibleIComparer.cs
- ReadOnlyDataSourceView.cs
- Roles.cs
- BitmapData.cs
- XmlNavigatorFilter.cs
- ControllableStoryboardAction.cs
- WebPartConnectionsDisconnectVerb.cs