Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Net / System / Net / Mail / SmtpLoginAuthenticationModule.cs / 5 / 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 } } // 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; #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 } } // 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
- InfoCardCryptoHelper.cs
- StringBlob.cs
- RegexFCD.cs
- Stacktrace.cs
- XmlSchemaComplexContent.cs
- BitmapEffectCollection.cs
- NameScopePropertyAttribute.cs
- TextReader.cs
- SamlDoNotCacheCondition.cs
- SQLMembershipProvider.cs
- CompositeScriptReferenceEventArgs.cs
- MetadataArtifactLoaderResource.cs
- XPathCompileException.cs
- PersistenceTypeAttribute.cs
- CodeDelegateInvokeExpression.cs
- SqlTypeSystemProvider.cs
- TrustLevelCollection.cs
- GeometryGroup.cs
- ListView.cs
- PointUtil.cs
- PerspectiveCamera.cs
- MessageDispatch.cs
- Scanner.cs
- CodeStatementCollection.cs
- WriteTimeStream.cs
- TextureBrush.cs
- EventLogStatus.cs
- HostedHttpContext.cs
- CurrentChangingEventArgs.cs
- CookieParameter.cs
- ContentPropertyAttribute.cs
- SqlProviderServices.cs
- ClosableStream.cs
- DataSvcMapFileSerializer.cs
- DataConnectionHelper.cs
- AuthorizationSection.cs
- ReadWriteObjectLock.cs
- C14NUtil.cs
- HelpInfo.cs
- TreeView.cs
- BindingOperations.cs
- Transform.cs
- Memoizer.cs
- EditBehavior.cs
- ChildrenQuery.cs
- ThicknessAnimation.cs
- ToolStripContainer.cs
- ModuleConfigurationInfo.cs
- XmlSchemaSequence.cs
- RadioButtonList.cs
- WebPartConnectionsConfigureVerb.cs
- DLinqAssociationProvider.cs
- TdsRecordBufferSetter.cs
- RelationshipEntry.cs
- CacheChildrenQuery.cs
- LogExtent.cs
- DATA_BLOB.cs
- BindingGroup.cs
- SamlAudienceRestrictionCondition.cs
- SelectionEditingBehavior.cs
- ErrorInfoXmlDocument.cs
- PtsCache.cs
- ConfigurationSchemaErrors.cs
- TextBoxBaseDesigner.cs
- GrammarBuilder.cs
- XmlSchemaDocumentation.cs
- GridViewRowPresenter.cs
- ErrorLog.cs
- SafeRightsManagementEnvironmentHandle.cs
- XmlArrayItemAttribute.cs
- QilTypeChecker.cs
- TypeElementCollection.cs
- KeyboardDevice.cs
- ObjectSecurity.cs
- X509LogoTypeExtension.cs
- HybridDictionary.cs
- __TransparentProxy.cs
- SafeNativeMethods.cs
- FigureHelper.cs
- FastPropertyAccessor.cs
- SystemIcmpV6Statistics.cs
- ScrollPattern.cs
- CaseStatement.cs
- ApplicationProxyInternal.cs
- DependencyPropertyChangedEventArgs.cs
- ValidatingPropertiesEventArgs.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- WebBrowserSiteBase.cs
- ControlAdapter.cs
- XmlSerializerAssemblyAttribute.cs
- FileAuthorizationModule.cs
- Assert.cs
- DoubleAnimationBase.cs
- WorkflowApplicationException.cs
- SystemTcpStatistics.cs
- GuidConverter.cs
- RefreshPropertiesAttribute.cs
- URL.cs
- NativeMethodsCLR.cs
- MdiWindowListItemConverter.cs