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 / SmtpLoginAuthenticationModule.cs / 2 / 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; using System.Security.Authentication.ExtendedProtection; #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, string spn, ChannelBinding channelBindingToken) { 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; using System.Security.Authentication.ExtendedProtection; #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, string spn, ChannelBinding channelBindingToken) { 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
- ListViewGroupConverter.cs
- CorrelationToken.cs
- MediaSystem.cs
- MimeParameter.cs
- IdentityVerifier.cs
- SQLBytes.cs
- PropertyGridEditorPart.cs
- HttpModuleAction.cs
- ResourcesGenerator.cs
- HtmlInputCheckBox.cs
- RotateTransform.cs
- ItemMap.cs
- ExceptionCollection.cs
- BreakRecordTable.cs
- SliderAutomationPeer.cs
- ThreadStartException.cs
- UnmanagedMarshal.cs
- Pair.cs
- IApplicationTrustManager.cs
- XmlSchemaExternal.cs
- XmlText.cs
- ScriptingJsonSerializationSection.cs
- RelatedPropertyManager.cs
- EntityDataSourceWrapper.cs
- Assert.cs
- SchemaCollectionPreprocessor.cs
- FrameworkElementFactory.cs
- RequestDescription.cs
- EntityDataSourceContextCreatedEventArgs.cs
- shaper.cs
- DropShadowEffect.cs
- Events.cs
- VoiceInfo.cs
- KeySpline.cs
- StylusPointCollection.cs
- Point3D.cs
- DataStorage.cs
- XPathDocumentIterator.cs
- ToolStripContentPanelRenderEventArgs.cs
- SerialStream.cs
- DeploymentSectionCache.cs
- WindowsEditBoxRange.cs
- OpenFileDialog.cs
- TypeResolvingOptions.cs
- DataGridViewColumnHeaderCell.cs
- WCFServiceClientProxyGenerator.cs
- KeyValueConfigurationCollection.cs
- DataGridViewAccessibleObject.cs
- LineBreakRecord.cs
- cookieexception.cs
- HttpHandlerActionCollection.cs
- StringOutput.cs
- DataServiceCollectionOfT.cs
- IncrementalReadDecoders.cs
- BitmapCacheBrush.cs
- ToolStripRenderEventArgs.cs
- DetailsViewCommandEventArgs.cs
- TrustLevel.cs
- SignatureDescription.cs
- HttpVersion.cs
- SqlTypesSchemaImporter.cs
- ContentWrapperAttribute.cs
- RoutedCommand.cs
- NegotiateStream.cs
- ViewgenGatekeeper.cs
- FrameDimension.cs
- ListViewItem.cs
- XmlILConstructAnalyzer.cs
- MsmqInputSessionChannelListener.cs
- SqlUnionizer.cs
- RoutedEventConverter.cs
- IISUnsafeMethods.cs
- SoapFormatExtensions.cs
- ControlUtil.cs
- WindowsListViewSubItem.cs
- Clipboard.cs
- assemblycache.cs
- ClickablePoint.cs
- GetParentChain.cs
- RegexGroup.cs
- DataFormats.cs
- IpcServerChannel.cs
- ParsedAttributeCollection.cs
- Int32CollectionValueSerializer.cs
- BatchParser.cs
- SoundPlayerAction.cs
- TreeViewAutomationPeer.cs
- Pair.cs
- ProviderUtil.cs
- PrintPreviewDialog.cs
- SessionKeyExpiredException.cs
- MimeXmlReflector.cs
- AnnotationHighlightLayer.cs
- CustomBinding.cs
- OdbcParameter.cs
- WebControl.cs
- MonthChangedEventArgs.cs
- XamlVector3DCollectionSerializer.cs
- Overlapped.cs
- CultureInfo.cs