Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Net / System / Net / Mail / SmtpLoginAuthenticationModule.cs / 5 / SmtpLoginAuthenticationModule.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; #if MAKE_MAILCLIENT_PUBLIC internal #else internal #endif class SmtpLoginAuthenticationModule : ISmtpAuthenticationModule { Hashtable sessions = new Hashtable(); internal SmtpLoginAuthenticationModule() { } #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) { if(Logging.On)Logging.Enter(Logging.Web, this, "Authenticate", null); try { lock (this.sessions) { NetworkCredential cachedCredential = sessions[sessionCookie] as NetworkCredential; if (cachedCredential == null) { if (credential == null || credential is SystemNetworkCredential) { return null; } sessions[sessionCookie] = credential; string userName = credential.UserName; string domain = credential.Domain; if (domain!=null && domain.Length > 0) { userName = domain + "\\" + userName; } // return new Authorization(Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(userName)), false); } else { this.sessions.Remove(sessionCookie); // return new Authorization(Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(cachedCredential.Password)), true); } } } finally { if(Logging.On)Logging.Exit(Logging.Web, this, "Authenticate", null); } } public string AuthenticationType { get { return "login"; } } 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; #if MAKE_MAILCLIENT_PUBLIC internal #else internal #endif class SmtpLoginAuthenticationModule : ISmtpAuthenticationModule { Hashtable sessions = new Hashtable(); internal SmtpLoginAuthenticationModule() { } #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) { if(Logging.On)Logging.Enter(Logging.Web, this, "Authenticate", null); try { lock (this.sessions) { NetworkCredential cachedCredential = sessions[sessionCookie] as NetworkCredential; if (cachedCredential == null) { if (credential == null || credential is SystemNetworkCredential) { return null; } sessions[sessionCookie] = credential; string userName = credential.UserName; string domain = credential.Domain; if (domain!=null && domain.Length > 0) { userName = domain + "\\" + userName; } // return new Authorization(Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(userName)), false); } else { this.sessions.Remove(sessionCookie); // return new Authorization(Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(cachedCredential.Password)), true); } } } finally { if(Logging.On)Logging.Exit(Logging.Web, this, "Authenticate", null); } } public string AuthenticationType { get { return "login"; } } 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
- ThreadStartException.cs
- Animatable.cs
- wgx_render.cs
- StorageSetMapping.cs
- ApplyImportsAction.cs
- ThreadStaticAttribute.cs
- HttpRawResponse.cs
- DocumentPageView.cs
- PerformanceCountersElement.cs
- Token.cs
- SiteMapNodeItemEventArgs.cs
- HtmlForm.cs
- SchemaImporterExtension.cs
- FieldMetadata.cs
- ClientBuildManagerTypeDescriptionProviderBridge.cs
- ExtensionSurface.cs
- XmlSerializerOperationFormatter.cs
- WebPartConnectionsCancelVerb.cs
- SspiWrapper.cs
- InvalidMessageContractException.cs
- IPAddress.cs
- MultiBinding.cs
- ElementUtil.cs
- DataGridViewControlCollection.cs
- SqlConnectionString.cs
- XmlReturnWriter.cs
- PageAsyncTask.cs
- ToolStripHighContrastRenderer.cs
- ContentAlignmentEditor.cs
- DetailsViewPagerRow.cs
- Span.cs
- SolidColorBrush.cs
- Rijndael.cs
- StrokeIntersection.cs
- UdpChannelListener.cs
- MenuTracker.cs
- PageBuildProvider.cs
- CrossContextChannel.cs
- SelectionRangeConverter.cs
- Misc.cs
- PropertyPushdownHelper.cs
- CacheOutputQuery.cs
- ColumnHeader.cs
- CharacterMetrics.cs
- DrawListViewSubItemEventArgs.cs
- CounterCreationData.cs
- TextElementEditingBehaviorAttribute.cs
- PointAnimationUsingPath.cs
- FrameworkElement.cs
- DataControlFieldCell.cs
- OutputCacheProfileCollection.cs
- PageThemeParser.cs
- BinaryReader.cs
- Aggregates.cs
- ImageBrush.cs
- CodeNamespaceCollection.cs
- TimerElapsedEvenArgs.cs
- SqlConnectionPoolGroupProviderInfo.cs
- BitSet.cs
- NetTcpBindingCollectionElement.cs
- RuntimeConfig.cs
- PartitionedStream.cs
- querybuilder.cs
- RelationshipFixer.cs
- BypassElementCollection.cs
- TypeUsageBuilder.cs
- LicenseContext.cs
- DataServiceKeyAttribute.cs
- HttpWebRequestElement.cs
- X509UI.cs
- _PooledStream.cs
- ImageMetadata.cs
- ReferentialConstraint.cs
- TypeValidationEventArgs.cs
- UpdatePanel.cs
- CrossSiteScriptingValidation.cs
- FileLogRecord.cs
- MouseButton.cs
- DoubleLinkList.cs
- XPathCompileException.cs
- AudioDeviceOut.cs
- MessageBox.cs
- RawStylusActions.cs
- smtppermission.cs
- EditorPartCollection.cs
- RequestQueryProcessor.cs
- DataGridViewColumnDesigner.cs
- MultiAsyncResult.cs
- OutOfProcStateClientManager.cs
- TypeSystem.cs
- CategoryAttribute.cs
- ThousandthOfEmRealDoubles.cs
- DocumentationServerProtocol.cs
- ValueUtilsSmi.cs
- BitHelper.cs
- GridViewSortEventArgs.cs
- ComponentEditorPage.cs
- UiaCoreProviderApi.cs
- Metadata.cs
- CustomLineCap.cs