Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Mail / SmtpNtlmAuthenticationModule.cs / 1305376 / SmtpNtlmAuthenticationModule.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net.Mail { using System; using System.Collections; using System.IO; using System.Net; using System.Security.Permissions; using System.Security.Authentication.ExtendedProtection; // #if MAKE_MAILCLIENT_PUBLIC internal #else internal #endif class SmtpNtlmAuthenticationModule : ISmtpAuthenticationModule { Hashtable sessions = new Hashtable(); internal SmtpNtlmAuthenticationModule() { } #region ISmtpAuthenticationModule Members // Security this method will access NetworkCredential properties that demand UnmanagedCode and Environment Permission [EnvironmentPermission(SecurityAction.Assert, Unrestricted=true)] [SecurityPermission(SecurityAction.Assert, Flags=SecurityPermissionFlag.UnmanagedCode)] public Authorization Authenticate(string challenge, NetworkCredential credential, object sessionCookie, string spn, ChannelBinding channelBindingToken) { if(Logging.On)Logging.Enter(Logging.Web, this, "Authenticate", null); try { lock (this.sessions) { NTAuthentication clientContext = this.sessions[sessionCookie] as NTAuthentication; if (clientContext == null) { if(credential == null){ return null; } this.sessions[sessionCookie] = clientContext = new NTAuthentication(false, "Ntlm", credential, spn, ContextFlags.Connection, channelBindingToken); } string resp = clientContext.GetOutgoingBlob(challenge); if (!clientContext.IsCompleted) { return new Authorization(resp, false); } else { this.sessions.Remove(sessionCookie); return new Authorization(resp, true); } } } finally { if(Logging.On)Logging.Exit(Logging.Web, this, "Authenticate", null); } } public string AuthenticationType { get { return "ntlm"; } } public void CloseContext(object sessionCookie) { // This is a no-op since the context is not // kept open by this module beyond auth completion. } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net.Mail { using System; using System.Collections; using System.IO; using System.Net; using System.Security.Permissions; using System.Security.Authentication.ExtendedProtection; // #if MAKE_MAILCLIENT_PUBLIC internal #else internal #endif class SmtpNtlmAuthenticationModule : ISmtpAuthenticationModule { Hashtable sessions = new Hashtable(); internal SmtpNtlmAuthenticationModule() { } #region ISmtpAuthenticationModule Members // Security this method will access NetworkCredential properties that demand UnmanagedCode and Environment Permission [EnvironmentPermission(SecurityAction.Assert, Unrestricted=true)] [SecurityPermission(SecurityAction.Assert, Flags=SecurityPermissionFlag.UnmanagedCode)] public Authorization Authenticate(string challenge, NetworkCredential credential, object sessionCookie, string spn, ChannelBinding channelBindingToken) { if(Logging.On)Logging.Enter(Logging.Web, this, "Authenticate", null); try { lock (this.sessions) { NTAuthentication clientContext = this.sessions[sessionCookie] as NTAuthentication; if (clientContext == null) { if(credential == null){ return null; } this.sessions[sessionCookie] = clientContext = new NTAuthentication(false, "Ntlm", credential, spn, ContextFlags.Connection, channelBindingToken); } string resp = clientContext.GetOutgoingBlob(challenge); if (!clientContext.IsCompleted) { return new Authorization(resp, false); } else { this.sessions.Remove(sessionCookie); return new Authorization(resp, true); } } } finally { if(Logging.On)Logging.Exit(Logging.Web, this, "Authenticate", null); } } public string AuthenticationType { get { return "ntlm"; } } public void CloseContext(object sessionCookie) { // This is a no-op since the context is not // kept open by this module beyond auth completion. } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BinaryObjectReader.cs
- CultureInfoConverter.cs
- ProxyHwnd.cs
- FormConverter.cs
- ComPlusSynchronizationContext.cs
- DataServiceHost.cs
- BCryptNative.cs
- TreeNodeStyleCollection.cs
- FormatConvertedBitmap.cs
- ProviderMetadataCachedInformation.cs
- PenThread.cs
- Label.cs
- SafeNativeMethods.cs
- QilStrConcatenator.cs
- AuthStoreRoleProvider.cs
- VScrollBar.cs
- EmptyElement.cs
- ReflectionUtil.cs
- ProtocolElement.cs
- DesignerCalendarAdapter.cs
- RtType.cs
- Rules.cs
- InputBindingCollection.cs
- LocalizationComments.cs
- FixedPosition.cs
- SchemaHelper.cs
- VisualStyleElement.cs
- OnOperation.cs
- WindowsEditBoxRange.cs
- TaskExceptionHolder.cs
- TreeViewEvent.cs
- CriticalFinalizerObject.cs
- TableLayoutColumnStyleCollection.cs
- IndexingContentUnit.cs
- FacetDescription.cs
- TextBounds.cs
- XsdDuration.cs
- Nodes.cs
- OrderToken.cs
- ArraySortHelper.cs
- TypeDelegator.cs
- XsltContext.cs
- StorageBasedPackageProperties.cs
- Timer.cs
- RowsCopiedEventArgs.cs
- StrokeNodeData.cs
- InvalidateEvent.cs
- EdmToObjectNamespaceMap.cs
- FloatAverageAggregationOperator.cs
- ProxySimple.cs
- AsyncOperation.cs
- CompositeFontFamily.cs
- ForceCopyBuildProvider.cs
- SerialStream.cs
- XmlStreamStore.cs
- Rotation3DAnimation.cs
- MatrixAnimationBase.cs
- FilteredReadOnlyMetadataCollection.cs
- ObjectQueryState.cs
- SafeNativeHandle.cs
- WebScriptEnablingBehavior.cs
- MappingItemCollection.cs
- ObjectDataSource.cs
- TabletDeviceInfo.cs
- XmlPreloadedResolver.cs
- QueryResults.cs
- NextPreviousPagerField.cs
- SchemaImporterExtensionsSection.cs
- HtmlInputButton.cs
- Matrix3DValueSerializer.cs
- ToggleButtonAutomationPeer.cs
- TypeInfo.cs
- Rfc2898DeriveBytes.cs
- TextDocumentView.cs
- ArrangedElementCollection.cs
- ExpressionParser.cs
- ImageMap.cs
- Soap.cs
- InputBinding.cs
- PropertyTabChangedEvent.cs
- EventMemberCodeDomSerializer.cs
- UriExt.cs
- WindowAutomationPeer.cs
- DbExpressionVisitor.cs
- AdPostCacheSubstitution.cs
- RealizationDrawingContextWalker.cs
- SchemaName.cs
- ListCardsInFileRequest.cs
- DocumentViewerConstants.cs
- EntityDataSourceStatementEditorForm.cs
- InternalDispatchObject.cs
- InstanceStoreQueryResult.cs
- XappLauncher.cs
- SecurityAccessDeniedException.cs
- XmlSchemaComplexContentRestriction.cs
- MSAAEventDispatcher.cs
- TextModifierScope.cs
- RectangleGeometry.cs
- UIElement.cs
- BaseTemplateParser.cs