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
- BaseHashHelper.cs
- __ComObject.cs
- HotSpotCollection.cs
- SimpleRecyclingCache.cs
- LinkLabelLinkClickedEvent.cs
- DbParameterCollectionHelper.cs
- DesignerAutoFormatStyle.cs
- XmlIlVisitor.cs
- UrlMappingCollection.cs
- CustomErrorsSection.cs
- DbDataRecord.cs
- EdmItemCollection.OcAssemblyCache.cs
- BasicExpandProvider.cs
- ActivationServices.cs
- PictureBox.cs
- BoundColumn.cs
- NumberFormatInfo.cs
- ClickablePoint.cs
- MethodBuilderInstantiation.cs
- BufferedGraphicsManager.cs
- RoleManagerModule.cs
- Assembly.cs
- ConvertersCollection.cs
- typedescriptorpermission.cs
- ParagraphVisual.cs
- PenCursorManager.cs
- HttpWrapper.cs
- XPathParser.cs
- UnmanagedMemoryStreamWrapper.cs
- StringComparer.cs
- OracleCommand.cs
- OracleString.cs
- PermissionAttributes.cs
- Transform.cs
- DataGridViewRowHeaderCell.cs
- HtmlInputHidden.cs
- MatrixTransform3D.cs
- IPipelineRuntime.cs
- XmlWriterTraceListener.cs
- TextParaClient.cs
- MainMenu.cs
- BasicKeyConstraint.cs
- SoapIncludeAttribute.cs
- C14NUtil.cs
- TransformerTypeCollection.cs
- Utils.cs
- BufferedStream.cs
- CodePageUtils.cs
- DataObject.cs
- CodeAssignStatement.cs
- ConfigUtil.cs
- LightweightEntityWrapper.cs
- TTSVoice.cs
- ToolStripRenderEventArgs.cs
- BaseTemplateParser.cs
- DesignerVerb.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- IconHelper.cs
- FormDocumentDesigner.cs
- RequestQueryProcessor.cs
- QuaternionRotation3D.cs
- DataGridViewTextBoxCell.cs
- WindowCollection.cs
- Misc.cs
- EnumerableRowCollectionExtensions.cs
- PopOutPanel.cs
- PolicyManager.cs
- XmlSchemaValidationException.cs
- LambdaCompiler.cs
- TextTreeTextElementNode.cs
- FlowDocumentReaderAutomationPeer.cs
- RangeContentEnumerator.cs
- Activator.cs
- BitmapEffectInput.cs
- RegexWriter.cs
- NativeMethods.cs
- LicenseContext.cs
- DBCSCodePageEncoding.cs
- OdbcException.cs
- WebControlToolBoxItem.cs
- XmlUrlResolver.cs
- ListItemDetailViewAttribute.cs
- CellParagraph.cs
- Model3DCollection.cs
- CatalogPartDesigner.cs
- StatusStrip.cs
- HtmlTable.cs
- Encoder.cs
- TypeBuilderInstantiation.cs
- XmlProcessingInstruction.cs
- ReliableSessionElement.cs
- DataGridViewCellValidatingEventArgs.cs
- PerfCounterSection.cs
- UpdatePanelControlTrigger.cs
- CodeAttributeArgument.cs
- VectorKeyFrameCollection.cs
- DataPointer.cs
- QilValidationVisitor.cs
- Int32KeyFrameCollection.cs
- SortDescription.cs