Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Net / System / Net / Mail / SmtpNtlmAuthenticationModule.cs / 2 / 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
- MessageSecurityOverMsmq.cs
- XmlSerializerNamespaces.cs
- Geometry.cs
- SchemaInfo.cs
- xmlsaver.cs
- COM2FontConverter.cs
- PhysicalAddress.cs
- XmlWriter.cs
- DataGridViewCellValidatingEventArgs.cs
- ChildDocumentBlock.cs
- PropertyValueChangedEvent.cs
- HtmlToClrEventProxy.cs
- FileSystemWatcher.cs
- SystemNetHelpers.cs
- ListViewInsertEventArgs.cs
- LocationUpdates.cs
- InvalidCastException.cs
- XPathBuilder.cs
- DesignRelation.cs
- PathGradientBrush.cs
- ComplexLine.cs
- BamlMapTable.cs
- Page.cs
- DurableDispatcherAddressingFault.cs
- CodeMethodReturnStatement.cs
- WizardStepBase.cs
- NameValueFileSectionHandler.cs
- HyperLinkColumn.cs
- ExpandCollapsePattern.cs
- OleStrCAMarshaler.cs
- TextRange.cs
- Axis.cs
- Size.cs
- Win32.cs
- TargetControlTypeCache.cs
- SynchronizedDispatch.cs
- SynchronizedInputProviderWrapper.cs
- PropertyGridDesigner.cs
- SessionPageStatePersister.cs
- DataConnectionHelper.cs
- DataGridViewSelectedColumnCollection.cs
- QilUnary.cs
- PrintEvent.cs
- IntegerValidatorAttribute.cs
- NavigationHelper.cs
- HeaderedItemsControl.cs
- SafeReversePInvokeHandle.cs
- MatrixTransform.cs
- VectorCollection.cs
- CacheForPrimitiveTypes.cs
- DataControlField.cs
- BlobPersonalizationState.cs
- BehaviorEditorPart.cs
- Line.cs
- TextTreeExtractElementUndoUnit.cs
- ResourceSetExpression.cs
- DbConnectionClosed.cs
- RouteData.cs
- Persist.cs
- elementinformation.cs
- ImageMapEventArgs.cs
- HybridDictionary.cs
- SoapAttributeOverrides.cs
- OdbcPermission.cs
- MetadataStore.cs
- AutoGeneratedFieldProperties.cs
- FormsAuthenticationCredentials.cs
- GraphicsPath.cs
- DataGridViewCellStyle.cs
- Semaphore.cs
- NamespaceQuery.cs
- CssClassPropertyAttribute.cs
- DbExpressionRules.cs
- AdornedElementPlaceholder.cs
- CompilationSection.cs
- PropertyChangingEventArgs.cs
- SafeNativeMethods.cs
- KeyMatchBuilder.cs
- Container.cs
- DataServiceCollectionOfT.cs
- ObjectItemAttributeAssemblyLoader.cs
- DataGridViewCheckBoxCell.cs
- NumericUpDownAccelerationCollection.cs
- WmlLabelAdapter.cs
- ToolStripDropDownButton.cs
- Match.cs
- Events.cs
- WasAdminWrapper.cs
- _ConnectOverlappedAsyncResult.cs
- DataGridAutoFormatDialog.cs
- TypeNameConverter.cs
- StreamedFramingRequestChannel.cs
- Send.cs
- CopyNodeSetAction.cs
- ValueUtilsSmi.cs
- ExceptionRoutedEventArgs.cs
- SecurityTokenResolver.cs
- NotificationContext.cs
- UIInitializationException.cs
- FormatterServicesNoSerializableCheck.cs