Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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; #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 } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FilterEventArgs.cs
- NavigationEventArgs.cs
- EmptyElement.cs
- WindowInteractionStateTracker.cs
- Evidence.cs
- CodeMemberProperty.cs
- AutomationElementIdentifiers.cs
- ControlAdapter.cs
- SqlTopReducer.cs
- WindowsSecurityToken.cs
- Adorner.cs
- RolePrincipal.cs
- DetailsViewAutoFormat.cs
- XmlDigitalSignatureProcessor.cs
- PathSegment.cs
- DoubleUtil.cs
- DesignObjectWrapper.cs
- SignedXml.cs
- CrossAppDomainChannel.cs
- SafeNativeMethodsCLR.cs
- RemotingException.cs
- XmlSignificantWhitespace.cs
- InvalidWMPVersionException.cs
- CellLabel.cs
- ParsedRoute.cs
- WebEvents.cs
- ConfigurationFileMap.cs
- CacheVirtualItemsEvent.cs
- Padding.cs
- PixelShader.cs
- Font.cs
- CodeDomLoader.cs
- CodeDomConfigurationHandler.cs
- InternalPolicyElement.cs
- Converter.cs
- BuildProviderAppliesToAttribute.cs
- SmiGettersStream.cs
- StreamInfo.cs
- DoubleCollectionConverter.cs
- WindowsGraphics2.cs
- XamlStream.cs
- StreamProxy.cs
- InfoCardX509Validator.cs
- DictionaryContent.cs
- TreeViewItem.cs
- HttpModuleAction.cs
- AdornerHitTestResult.cs
- XmlSchemaComplexContentRestriction.cs
- StrokeDescriptor.cs
- XmlImplementation.cs
- HtmlShim.cs
- DesignerForm.cs
- PropertySourceInfo.cs
- TypeDescriptionProvider.cs
- PictureBox.cs
- InheritedPropertyChangedEventArgs.cs
- EncodingConverter.cs
- DiscoveryRequestHandler.cs
- Win32MouseDevice.cs
- MiniMapControl.xaml.cs
- BindingCompleteEventArgs.cs
- DetailsViewInsertEventArgs.cs
- AvTraceFormat.cs
- XslVisitor.cs
- COMException.cs
- HttpHandlerActionCollection.cs
- UIServiceHelper.cs
- SplayTreeNode.cs
- HashLookup.cs
- HtmlForm.cs
- DragCompletedEventArgs.cs
- MetadataCache.cs
- SqlMethodAttribute.cs
- RegexGroupCollection.cs
- MetafileHeaderEmf.cs
- TableItemPatternIdentifiers.cs
- FileDialog_Vista.cs
- OdbcDataAdapter.cs
- QueryableDataSourceHelper.cs
- ClientUrlResolverWrapper.cs
- ReadOnlyDictionary.cs
- AppDomainProtocolHandler.cs
- HttpServerChannel.cs
- MetaForeignKeyColumn.cs
- ConnectionPointCookie.cs
- OpCodes.cs
- ListItemConverter.cs
- CatalogZoneBase.cs
- CacheEntry.cs
- LowerCaseStringConverter.cs
- XmlCountingReader.cs
- odbcmetadatacolumnnames.cs
- RawStylusInputCustomDataList.cs
- SimpleTableProvider.cs
- WebServicesDescriptionAttribute.cs
- SafeRightsManagementEnvironmentHandle.cs
- WorkerRequest.cs
- ValueExpressions.cs
- IResourceProvider.cs
- PlainXmlWriter.cs