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
- WorkflowInstance.cs
- MouseGestureConverter.cs
- ExpressionBuilder.cs
- Transform3DGroup.cs
- DbConnectionPool.cs
- ObjectListGeneralPage.cs
- BitmapPalette.cs
- _LocalDataStoreMgr.cs
- HotSpot.cs
- WebPartDescription.cs
- HttpListenerContext.cs
- DataControlFieldCollection.cs
- RequiredFieldValidator.cs
- EventLogConfiguration.cs
- XmlSchemaSimpleContent.cs
- DesignerToolStripControlHost.cs
- TextContainer.cs
- IteratorFilter.cs
- RSAPKCS1SignatureDeformatter.cs
- MsmqIntegrationInputMessage.cs
- BooleanKeyFrameCollection.cs
- ValidationResults.cs
- Journaling.cs
- HitTestWithPointDrawingContextWalker.cs
- XPathNavigatorReader.cs
- TrustManagerMoreInformation.cs
- NamespaceExpr.cs
- DoubleConverter.cs
- TableCellCollection.cs
- UnsafeNativeMethods.cs
- CurrencyManager.cs
- SafeEventLogReadHandle.cs
- DataTableCollection.cs
- DaylightTime.cs
- AssemblyAttributesGoHere.cs
- UTF7Encoding.cs
- UriSectionData.cs
- NTAccount.cs
- NonParentingControl.cs
- UInt64Converter.cs
- PaperSource.cs
- WebServiceEndpoint.cs
- ArrayHelper.cs
- MsmqTransportSecurityElement.cs
- WebResponse.cs
- Gdiplus.cs
- UpdateCompiler.cs
- KeyConverter.cs
- SyndicationDeserializer.cs
- WebPartHeaderCloseVerb.cs
- QilList.cs
- InputReportEventArgs.cs
- QuaternionAnimation.cs
- ReflectionUtil.cs
- XDeferredAxisSource.cs
- EditorZone.cs
- SynchronizingStream.cs
- SecureUICommand.cs
- DtdParser.cs
- BindValidator.cs
- XmlSchemaSimpleTypeRestriction.cs
- RegexStringValidator.cs
- KnownColorTable.cs
- DbDataRecord.cs
- IRCollection.cs
- ComponentCodeDomSerializer.cs
- AuthStoreRoleProvider.cs
- PopupControlService.cs
- SuspendDesigner.cs
- ControlTemplate.cs
- IntegrationExceptionEventArgs.cs
- Decorator.cs
- ReliabilityContractAttribute.cs
- ResXResourceWriter.cs
- EditCommandColumn.cs
- MailMessageEventArgs.cs
- ScrollChrome.cs
- PackageRelationshipCollection.cs
- ApplicationTrust.cs
- mil_sdk_version.cs
- SigningCredentials.cs
- WebPartConnectionsCancelEventArgs.cs
- WebMethodAttribute.cs
- DecimalAnimation.cs
- AssociationEndMember.cs
- DataSet.cs
- AtomicFile.cs
- ArrayExtension.cs
- sitestring.cs
- Attributes.cs
- GridViewPageEventArgs.cs
- SiteMapNodeItemEventArgs.cs
- ConfigurationPropertyAttribute.cs
- CompilerErrorCollection.cs
- StrokeNodeData.cs
- IndentedWriter.cs
- ConfigXmlReader.cs
- FileSystemWatcher.cs
- ImageClickEventArgs.cs
- Container.cs