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
- OrderByBuilder.cs
- Error.cs
- RowBinding.cs
- SizeValueSerializer.cs
- XPathDocumentIterator.cs
- XPathBuilder.cs
- RNGCryptoServiceProvider.cs
- MediaElementAutomationPeer.cs
- QuaternionRotation3D.cs
- TextBoxBaseDesigner.cs
- ScrollPattern.cs
- CodeIndexerExpression.cs
- EntityConnectionStringBuilder.cs
- HttpProfileBase.cs
- EntityContainerAssociationSet.cs
- Selector.cs
- OverlappedAsyncResult.cs
- OutOfMemoryException.cs
- ZipIOFileItemStream.cs
- ConnectionsZone.cs
- PolicyException.cs
- XNodeSchemaApplier.cs
- CustomErrorsSection.cs
- LookupBindingPropertiesAttribute.cs
- Visual.cs
- PagerSettings.cs
- DoubleUtil.cs
- BamlWriter.cs
- CollectionEditor.cs
- Graph.cs
- DataGridViewLinkColumn.cs
- SecurityException.cs
- BinHexEncoder.cs
- CoreSwitches.cs
- Point4DConverter.cs
- Quaternion.cs
- SemanticAnalyzer.cs
- MembershipSection.cs
- CharacterString.cs
- Inline.cs
- ContainerFilterService.cs
- DrawingContext.cs
- SchemaComplexType.cs
- NavigateEvent.cs
- PageAsyncTask.cs
- invalidudtexception.cs
- UIPermission.cs
- CompilerHelpers.cs
- XmlSchemaRedefine.cs
- TdsParserSessionPool.cs
- ThemeInfoAttribute.cs
- SqlUtils.cs
- ComponentEditorPage.cs
- SafeCryptoHandles.cs
- GroupQuery.cs
- SqlDataSourceQueryEditorForm.cs
- IResourceProvider.cs
- DataBoundControlAdapter.cs
- BuildProvider.cs
- MissingMemberException.cs
- JapaneseCalendar.cs
- SharedConnectionListener.cs
- ConfigurationConverterBase.cs
- Timer.cs
- MessageQueueInstaller.cs
- PermissionSetTriple.cs
- CharUnicodeInfo.cs
- XDeferredAxisSource.cs
- RelOps.cs
- webclient.cs
- MetafileHeader.cs
- XDRSchema.cs
- ViewGenResults.cs
- ErrorProvider.cs
- VsPropertyGrid.cs
- DbMetaDataColumnNames.cs
- Tablet.cs
- Certificate.cs
- DataTrigger.cs
- PrintDocument.cs
- QueryCacheKey.cs
- CreateRefExpr.cs
- ValueTable.cs
- ClientScriptManagerWrapper.cs
- XPathDescendantIterator.cs
- CustomGrammar.cs
- SingleResultAttribute.cs
- ParseChildrenAsPropertiesAttribute.cs
- XmlSecureResolver.cs
- RC2CryptoServiceProvider.cs
- ElementsClipboardData.cs
- OpCodes.cs
- HostingEnvironmentSection.cs
- GridViewCellAutomationPeer.cs
- DataObjectFieldAttribute.cs
- CfgParser.cs
- BuildProviderUtils.cs
- DropTarget.cs
- FixedPage.cs
- BasicExpandProvider.cs