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
- UnwrappedTypesXmlSerializerManager.cs
- SystemPens.cs
- TimerEventSubscriptionCollection.cs
- ResourceReferenceKeyNotFoundException.cs
- DebuggerAttributes.cs
- TagPrefixCollection.cs
- LogLogRecordEnumerator.cs
- DataGridToolTip.cs
- followingquery.cs
- ButtonFieldBase.cs
- RelationshipDetailsCollection.cs
- ReplacementText.cs
- NetTcpBinding.cs
- RectAnimationClockResource.cs
- Operators.cs
- ToolStripStatusLabel.cs
- UiaCoreTypesApi.cs
- FixedSOMLineCollection.cs
- BoundsDrawingContextWalker.cs
- DataGrid.cs
- XPathScanner.cs
- XmlSchemaProviderAttribute.cs
- HttpsHostedTransportConfiguration.cs
- DataError.cs
- EventHandlerList.cs
- FilterFactory.cs
- TypefaceMetricsCache.cs
- DbConnectionFactory.cs
- Screen.cs
- IISUnsafeMethods.cs
- IndexingContentUnit.cs
- EntityUtil.cs
- _SslState.cs
- TextEditorDragDrop.cs
- ProcessInfo.cs
- InputQueue.cs
- PackWebRequest.cs
- TextEffectCollection.cs
- DataMisalignedException.cs
- URL.cs
- UserPreferenceChangedEventArgs.cs
- DesignerSerializationOptionsAttribute.cs
- EndpointBehaviorElementCollection.cs
- CollectionBuilder.cs
- CommandDevice.cs
- ConstraintCollection.cs
- DataList.cs
- OdbcConnectionStringbuilder.cs
- HostedImpersonationContext.cs
- Perspective.cs
- CustomDictionarySources.cs
- TrackingMemoryStreamFactory.cs
- XslException.cs
- AllowedAudienceUriElementCollection.cs
- MachineKeySection.cs
- SimpleHandlerFactory.cs
- DynamicActivity.cs
- ForeignKeyFactory.cs
- MarkupCompilePass2.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- DependencyObjectType.cs
- DBProviderConfigurationHandler.cs
- SkewTransform.cs
- ProxyManager.cs
- securitycriticaldata.cs
- CommandLibraryHelper.cs
- Vector3DConverter.cs
- DrawingContextWalker.cs
- WsdlBuildProvider.cs
- ColorConvertedBitmapExtension.cs
- PolyLineSegment.cs
- AuthenticationSection.cs
- XsltInput.cs
- PathFigure.cs
- GifBitmapEncoder.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- InstanceData.cs
- OutputWindow.cs
- ComponentResourceKey.cs
- FormViewDeletedEventArgs.cs
- DataKeyCollection.cs
- ExpressionPrinter.cs
- XmlSerializerFactory.cs
- BindingOperations.cs
- OracleParameterCollection.cs
- PerformanceCounter.cs
- ZipIOExtraFieldZip64Element.cs
- SystemIcons.cs
- ViewKeyConstraint.cs
- RootNamespaceAttribute.cs
- MsmqNonTransactedPoisonHandler.cs
- RelatedPropertyManager.cs
- HtmlEmptyTagControlBuilder.cs
- FileDialogCustomPlace.cs
- GroupByQueryOperator.cs
- DataRecord.cs
- UrlAuthFailedErrorFormatter.cs
- ArgIterator.cs
- EventProviderBase.cs
- ViewSimplifier.cs