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
- IImplicitResourceProvider.cs
- ClientSponsor.cs
- UriTemplateTableMatchCandidate.cs
- SqlRemoveConstantOrderBy.cs
- GroupBox.cs
- Opcode.cs
- MergablePropertyAttribute.cs
- PathFigure.cs
- Duration.cs
- XmlnsCompatibleWithAttribute.cs
- MarkupExtensionParser.cs
- Label.cs
- BaseTemplateParser.cs
- InstallerTypeAttribute.cs
- IssuanceLicense.cs
- KeyFrames.cs
- ListViewGroupConverter.cs
- bindurihelper.cs
- QueryStoreStatusRequest.cs
- InvalidPrinterException.cs
- BulletChrome.cs
- LinqTreeNodeEvaluator.cs
- EntityClientCacheKey.cs
- ClearTypeHintValidation.cs
- ConfigXmlReader.cs
- XmlHelper.cs
- DesignerCategoryAttribute.cs
- _ListenerResponseStream.cs
- ControlBuilderAttribute.cs
- WebRequestModulesSection.cs
- SafeArrayTypeMismatchException.cs
- UIPropertyMetadata.cs
- PropertyGrid.cs
- GridViewDeletedEventArgs.cs
- RemotingAttributes.cs
- KoreanLunisolarCalendar.cs
- ComplexTypeEmitter.cs
- DrawingContextDrawingContextWalker.cs
- Crc32.cs
- TraceUtility.cs
- CallbackValidatorAttribute.cs
- DesignerHost.cs
- Empty.cs
- DynamicMetaObjectBinder.cs
- LayeredChannelFactory.cs
- ContextMenuService.cs
- BinaryObjectReader.cs
- DefaultParameterValueAttribute.cs
- KeyedHashAlgorithm.cs
- LeaseManager.cs
- Crypto.cs
- FlowPosition.cs
- Lazy.cs
- CodeArgumentReferenceExpression.cs
- Base64Stream.cs
- RelationshipFixer.cs
- AsymmetricSignatureDeformatter.cs
- ToolStripContentPanelRenderEventArgs.cs
- ExpressionBuilder.cs
- EditingCoordinator.cs
- DeviceContext.cs
- AttributeEmitter.cs
- ToolBarButton.cs
- ManagementException.cs
- SqlConnection.cs
- TypeLoadException.cs
- SecurityContextTokenValidationException.cs
- RightsManagementInformation.cs
- XmlSequenceWriter.cs
- QilVisitor.cs
- ComponentRenameEvent.cs
- TextEditorDragDrop.cs
- EntityContainer.cs
- webclient.cs
- BamlTreeMap.cs
- Tablet.cs
- Queue.cs
- X509ChainPolicy.cs
- TextProperties.cs
- SqlExpressionNullability.cs
- ReadContentAsBinaryHelper.cs
- XmlSerializerVersionAttribute.cs
- XPathDocumentBuilder.cs
- SqlSelectStatement.cs
- UIElement3DAutomationPeer.cs
- ListQueryResults.cs
- DataTemplateKey.cs
- MediaContext.cs
- PathSegment.cs
- IsolatedStorageSecurityState.cs
- EncoderFallback.cs
- _WinHttpWebProxyDataBuilder.cs
- ModelVisual3D.cs
- DeferredTextReference.cs
- SuppressMessageAttribute.cs
- SystemMulticastIPAddressInformation.cs
- ArgumentException.cs
- unitconverter.cs
- TextTreeRootNode.cs
- BaseTransportHeaders.cs