Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Mail / SmtpLoginAuthenticationModule.cs / 1305376 / 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.UTF8.GetBytes(userName)), false); } else { this.sessions.Remove(sessionCookie); // return new Authorization(Convert.ToBase64String(System.Text.Encoding.UTF8.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
- RecognizedPhrase.cs
- ToolStripContextMenu.cs
- XmlReflectionImporter.cs
- DynamicActionMessageFilter.cs
- Exceptions.cs
- GridItemPattern.cs
- IriParsingElement.cs
- MemberHolder.cs
- MessageSmuggler.cs
- AppSettingsExpressionEditor.cs
- ExpressionPrefixAttribute.cs
- ProfileService.cs
- SafeFileMappingHandle.cs
- WebPart.cs
- PropertyValueUIItem.cs
- SystemInfo.cs
- ReachSerializationCacheItems.cs
- WmpBitmapEncoder.cs
- CustomWebEventKey.cs
- ObjectItemAttributeAssemblyLoader.cs
- FileDialog_Vista_Interop.cs
- XPathConvert.cs
- AlphabeticalEnumConverter.cs
- Separator.cs
- WebConfigurationFileMap.cs
- Variant.cs
- DocumentationServerProtocol.cs
- RuntimeArgumentHandle.cs
- DefinitionBase.cs
- SqlDelegatedTransaction.cs
- ObjectListGeneralPage.cs
- DataSourceCacheDurationConverter.cs
- StringReader.cs
- ColorConvertedBitmapExtension.cs
- XmlAttributeCollection.cs
- Point3DKeyFrameCollection.cs
- Transform.cs
- RequiredFieldValidator.cs
- ErasingStroke.cs
- TextElementEnumerator.cs
- AsymmetricSignatureFormatter.cs
- ListViewHitTestInfo.cs
- ServerValidateEventArgs.cs
- TextParagraphView.cs
- EntryPointNotFoundException.cs
- ToolStripItem.cs
- RijndaelManaged.cs
- CursorConverter.cs
- PassportAuthentication.cs
- ChannelProtectionRequirements.cs
- Parameter.cs
- PointAnimation.cs
- ResourcesBuildProvider.cs
- ConfigurationElementCollection.cs
- MemoryMappedViewAccessor.cs
- ViewManager.cs
- ConnectionInterfaceCollection.cs
- TypeBuilderInstantiation.cs
- HtmlSelect.cs
- StrokeNodeEnumerator.cs
- ProcessInputEventArgs.cs
- ValidationManager.cs
- TrackingServices.cs
- DataGridViewImageCell.cs
- DataGridViewRowsAddedEventArgs.cs
- XmlSchemaDocumentation.cs
- RuleInfoComparer.cs
- KernelTypeValidation.cs
- COAUTHIDENTITY.cs
- IdnElement.cs
- SimpleType.cs
- TreeNode.cs
- OverrideMode.cs
- Int16AnimationUsingKeyFrames.cs
- OleDbStruct.cs
- PersistChildrenAttribute.cs
- RoleManagerEventArgs.cs
- ToolStripSeparatorRenderEventArgs.cs
- TagMapCollection.cs
- StringFunctions.cs
- MailDefinition.cs
- LinkButton.cs
- PropertyChangedEventArgs.cs
- AttachedPropertyMethodSelector.cs
- DataServiceRequestException.cs
- SafePEFileHandle.cs
- SamlConditions.cs
- newinstructionaction.cs
- DataRowView.cs
- TabControlAutomationPeer.cs
- WindowsIPAddress.cs
- CompilerScopeManager.cs
- XmlTextWriter.cs
- ContainerParaClient.cs
- GroupItem.cs
- WebServiceEnumData.cs
- DeclarationUpdate.cs
- BufferedWebEventProvider.cs
- DispatchWrapper.cs
- DataTableReaderListener.cs