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
- ReadOnlyCollectionBase.cs
- Win32Exception.cs
- ZipIOExtraField.cs
- SoapInteropTypes.cs
- TargetConverter.cs
- HyperLink.cs
- followingquery.cs
- XmlMapping.cs
- WindowsStartMenu.cs
- Oid.cs
- basevalidator.cs
- WorkflowMarkupSerializationManager.cs
- DesignConnection.cs
- HtmlInputSubmit.cs
- ProgressiveCrcCalculatingStream.cs
- PaperSize.cs
- TableLayout.cs
- SqlResolver.cs
- FormViewRow.cs
- Clipboard.cs
- RoutedEventConverter.cs
- RequestCache.cs
- AccessDataSourceView.cs
- FunctionUpdateCommand.cs
- GridViewRow.cs
- ObjectPropertyMapping.cs
- GridToolTip.cs
- FixedSOMPageElement.cs
- PermissionSet.cs
- SystemNetHelpers.cs
- RelatedView.cs
- LicenseProviderAttribute.cs
- HttpCachePolicyElement.cs
- DelegateSerializationHolder.cs
- ArraySortHelper.cs
- cookiecontainer.cs
- XmlC14NWriter.cs
- RegistrationServices.cs
- XmlTextAttribute.cs
- M3DUtil.cs
- AppSettingsReader.cs
- ObjectAnimationBase.cs
- XamlClipboardData.cs
- XmlEntity.cs
- CodeThrowExceptionStatement.cs
- MdImport.cs
- ReflectionHelper.cs
- WasNotInstalledException.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- MatrixStack.cs
- DomNameTable.cs
- DropShadowBitmapEffect.cs
- ArgumentOutOfRangeException.cs
- CatalogZoneBase.cs
- ScriptControl.cs
- EditorZone.cs
- Visitors.cs
- LoginName.cs
- IsolatedStorageSecurityState.cs
- EventLogPermission.cs
- StrongName.cs
- AQNBuilder.cs
- CalculatedColumn.cs
- TextDecorationCollection.cs
- thaishape.cs
- FlowDocumentView.cs
- CqlErrorHelper.cs
- MessageSecurityOverTcp.cs
- NativeCppClassAttribute.cs
- RenameRuleObjectDialog.cs
- Drawing.cs
- TcpClientChannel.cs
- BinaryFormatterSinks.cs
- RawStylusActions.cs
- AnimationClockResource.cs
- DrawingVisualDrawingContext.cs
- WinEventHandler.cs
- CodeArrayCreateExpression.cs
- SelectionPatternIdentifiers.cs
- FixedFindEngine.cs
- ResourceExpressionBuilder.cs
- FileSecurity.cs
- CodeDelegateCreateExpression.cs
- CodeRegionDirective.cs
- WebEventCodes.cs
- XmlQueryType.cs
- URLString.cs
- NavigateEvent.cs
- CancellationTokenSource.cs
- MethodInfo.cs
- ProviderManager.cs
- LambdaValue.cs
- SecurityTokenRequirement.cs
- HttpDictionary.cs
- ActiveDocumentEvent.cs
- InternalSafeNativeMethods.cs
- wgx_commands.cs
- StandardBindingImporter.cs
- TemplatePropertyEntry.cs
- sitestring.cs