Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / Messaging / CustomServiceCredentials.cs / 1 / CustomServiceCredentials.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // Override ServiceCredentials to provide a custom token authenticator using System; using System.Collections.Generic; using System.Diagnostics; using System.IdentityModel.Selectors; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.ServiceModel.Security; using System.ServiceModel.Security.Tokens; using System.Threading; using DiagnosticUtility = Microsoft.Transactions.Bridge.DiagnosticUtility; namespace Microsoft.Transactions.Wsat.Messaging { class SupportingTokenServiceCredentials : ServiceCredentials { SupportingTokenSecurityTokenResolver tokenResolver; SecurityContextSecurityTokenAuthenticator tokenAuthenticator; public SupportingTokenServiceCredentials() { this.tokenResolver = new SupportingTokenSecurityTokenResolver(); this.tokenAuthenticator = new SecurityContextSecurityTokenAuthenticator(); } SupportingTokenServiceCredentials(SupportingTokenServiceCredentials other) : base(other) { this.tokenResolver = other.tokenResolver; this.tokenAuthenticator = other.tokenAuthenticator; } public SupportingTokenSecurityTokenResolver TokenResolver { get { return this.tokenResolver; } } public override SecurityTokenManager CreateSecurityTokenManager() { return new SupportingTokenSecurityTokenManager(this); } protected override ServiceCredentials CloneCore() { return new SupportingTokenServiceCredentials(this); } class SupportingTokenSecurityTokenManager : ServiceCredentialsSecurityTokenManager { SupportingTokenServiceCredentials serverCreds; public SupportingTokenSecurityTokenManager(SupportingTokenServiceCredentials serverCreds) : base(serverCreds) { this.serverCreds = serverCreds; } public override SecurityTokenAuthenticator CreateSecurityTokenAuthenticator(SecurityTokenRequirement tokenRequirement, out SecurityTokenResolver outOfBandTokenResolver) { if (tokenRequirement == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("tokenRequirement"); } if (tokenRequirement.TokenType == ServiceModelSecurityTokenTypes.SecurityContext) { if (DebugTrace.Verbose) DebugTrace.Trace(TraceLevel.Verbose, "CreateSecurityTokenAuthenticator for SecurityContext"); outOfBandTokenResolver = this.serverCreds.tokenResolver; return this.serverCreds.tokenAuthenticator; } else { return base.CreateSecurityTokenAuthenticator(tokenRequirement, out outOfBandTokenResolver); } } // Transactions does not need an identity to be specified in the EPR. public override EndpointIdentity GetIdentityOfSelf(SecurityTokenRequirement tokenRequirement) { return null; } } } // ServiceCredentialsTokenManager defined in ServiceModel will default to // creating a X509CertificateIdentity when no endpoint identity is specified // but while a service certificate is specified. Transactions does not need // identity in the EPR. In order to avoid the performance hit in serializing // a Certificate in the EPR we are providing a custom token manager that // will return a null Identity from GetIdentityOfSelf. class DefaultServiceCredentials : ServiceCredentials { public DefaultServiceCredentials() : base() { } public DefaultServiceCredentials(DefaultServiceCredentials other) : base(other) { } public override SecurityTokenManager CreateSecurityTokenManager() { return new DefaultSecurityTokenManager(this); } protected override ServiceCredentials CloneCore() { return new DefaultServiceCredentials(this); } class DefaultSecurityTokenManager : ServiceCredentialsSecurityTokenManager { DefaultServiceCredentials serverCreds; public DefaultSecurityTokenManager(DefaultServiceCredentials serverCreds) : base(serverCreds) { this.serverCreds = serverCreds; } public override EndpointIdentity GetIdentityOfSelf(SecurityTokenRequirement tokenRequirement) { return null; } } } } // 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
- indexingfiltermarshaler.cs
- PageEventArgs.cs
- RequestDescription.cs
- SerializationStore.cs
- ValidatingReaderNodeData.cs
- ExtensionDataReader.cs
- InProcStateClientManager.cs
- DataSourceControl.cs
- DoubleMinMaxAggregationOperator.cs
- DataGridViewCellCollection.cs
- Binding.cs
- DynamicPropertyHolder.cs
- Expander.cs
- DocumentGridContextMenu.cs
- FontEmbeddingManager.cs
- DynamicRendererThreadManager.cs
- AssemblyResourceLoader.cs
- Soap.cs
- HttpBrowserCapabilitiesWrapper.cs
- StyleHelper.cs
- CatalogZoneBase.cs
- DynamicMethod.cs
- TearOffProxy.cs
- Configuration.cs
- OutputCacheSection.cs
- UpdateTranslator.cs
- HuffModule.cs
- RequestCachePolicyConverter.cs
- Tokenizer.cs
- XmlSchemaInfo.cs
- WebFaultClientMessageInspector.cs
- ContentFileHelper.cs
- AutoScrollHelper.cs
- XmlExpressionDumper.cs
- CryptoProvider.cs
- _TimerThread.cs
- Point4DConverter.cs
- DbConnectionPoolGroup.cs
- RealizationContext.cs
- TemplateControlCodeDomTreeGenerator.cs
- IndentTextWriter.cs
- PageClientProxyGenerator.cs
- XmlIgnoreAttribute.cs
- ItemsControlAutomationPeer.cs
- GridItem.cs
- WindowsTreeView.cs
- SystemIPGlobalProperties.cs
- CanExecuteRoutedEventArgs.cs
- DataPagerCommandEventArgs.cs
- FieldTemplateFactory.cs
- CallbackHandler.cs
- ProjectedSlot.cs
- AppDomainGrammarProxy.cs
- UserPersonalizationStateInfo.cs
- FixedTextBuilder.cs
- ErasingStroke.cs
- BasicExpressionVisitor.cs
- CategoryNameCollection.cs
- Single.cs
- EffectiveValueEntry.cs
- XXXInfos.cs
- ExceptionUtil.cs
- Throw.cs
- CodeTypeReferenceExpression.cs
- Command.cs
- ChannelDispatcher.cs
- Drawing.cs
- EnumerableRowCollectionExtensions.cs
- StandardBindingCollectionElement.cs
- securestring.cs
- NonPrimarySelectionGlyph.cs
- VisualBasicValue.cs
- ControlCachePolicy.cs
- PersonalizationProvider.cs
- TimersDescriptionAttribute.cs
- SchemaImporterExtensionsSection.cs
- DataSourceDescriptorCollection.cs
- Int16AnimationUsingKeyFrames.cs
- X509Certificate.cs
- InteropAutomationProvider.cs
- mactripleDES.cs
- InputReferenceExpression.cs
- WebPartConnectionsCloseVerb.cs
- ProfileParameter.cs
- IndexedString.cs
- COM2Properties.cs
- MsmqAuthenticationMode.cs
- UnhandledExceptionEventArgs.cs
- ToggleProviderWrapper.cs
- unitconverter.cs
- SystemIPInterfaceProperties.cs
- SqlXml.cs
- StrokeNode.cs
- CompositeDataBoundControl.cs
- ResourceKey.cs
- processwaithandle.cs
- externdll.cs
- OptionUsage.cs
- ClientProxyGenerator.cs
- ByteConverter.cs