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
- FormatStringEditor.cs
- DependencyPropertyValueSerializer.cs
- SetMemberBinder.cs
- DiagnosticStrings.cs
- SponsorHelper.cs
- MustUnderstandBehavior.cs
- CustomErrorCollection.cs
- OleDbEnumerator.cs
- AsyncPostBackTrigger.cs
- StyleHelper.cs
- diagnosticsswitches.cs
- SQLConvert.cs
- WSDualHttpSecurityMode.cs
- AsyncStreamReader.cs
- ErrorsHelper.cs
- WindowsTokenRoleProvider.cs
- SettingsPropertyWrongTypeException.cs
- SqlDataSourceQuery.cs
- BitmapVisualManager.cs
- WSSecurityJan2004.cs
- CheckBox.cs
- DLinqColumnProvider.cs
- BaseServiceProvider.cs
- DataGridViewImageCell.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- ManifestResourceInfo.cs
- X509Utils.cs
- FileLogRecordEnumerator.cs
- BuildResult.cs
- COMException.cs
- GlobalizationSection.cs
- ProxyGenerationError.cs
- SerializationFieldInfo.cs
- XsdCachingReader.cs
- TextParaLineResult.cs
- SchemaCollectionPreprocessor.cs
- DataControlLinkButton.cs
- TextDecoration.cs
- HttpModulesSection.cs
- TreeWalkHelper.cs
- TrackingConditionCollection.cs
- LogWriteRestartAreaAsyncResult.cs
- Line.cs
- ComponentEditorForm.cs
- ImmComposition.cs
- SubpageParaClient.cs
- CounterSample.cs
- XPathArrayIterator.cs
- DecimalAnimation.cs
- SafeReadContext.cs
- RequestNavigateEventArgs.cs
- RegularExpressionValidator.cs
- IPCCacheManager.cs
- TypeUtils.cs
- RegexNode.cs
- MetadataItemEmitter.cs
- QuaternionConverter.cs
- DeploymentExceptionMapper.cs
- COM2ExtendedBrowsingHandler.cs
- SystemFonts.cs
- UrlPath.cs
- XmlAtomicValue.cs
- HostingEnvironmentSection.cs
- InstanceCreationEditor.cs
- StatusBarPanelClickEvent.cs
- DesignerSelectionListAdapter.cs
- UntypedNullExpression.cs
- XmlJsonReader.cs
- SequentialUshortCollection.cs
- TemplatePropertyEntry.cs
- ApplicationInterop.cs
- XmlSchemaElement.cs
- CodeDesigner.cs
- Keyboard.cs
- EventLogPermissionAttribute.cs
- XmlDataImplementation.cs
- PropertyChangingEventArgs.cs
- initElementDictionary.cs
- WindowsSolidBrush.cs
- RegisteredScript.cs
- KeyManager.cs
- WorkflowOwnerAsyncResult.cs
- Touch.cs
- GridErrorDlg.cs
- AssemblyHash.cs
- DataChangedEventManager.cs
- PropertyEntry.cs
- Matrix3DValueSerializer.cs
- ObjectResult.cs
- HtmlGenericControl.cs
- ConvertTextFrag.cs
- QuadraticEase.cs
- UnsafeNativeMethodsCLR.cs
- _NegoState.cs
- InternalTransaction.cs
- Visitor.cs
- VirtualDirectoryMapping.cs
- HandleExceptionArgs.cs
- wpf-etw.cs
- WebScriptServiceHostFactory.cs