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
- UserControl.cs
- XmlEventCache.cs
- Identity.cs
- UnsafeMethods.cs
- XXXInfos.cs
- SelectionPatternIdentifiers.cs
- CodeSnippetTypeMember.cs
- NamespaceMapping.cs
- SmtpTransport.cs
- ActivityBuilderXamlWriter.cs
- TextServicesContext.cs
- ColorInterpolationModeValidation.cs
- ObjectDataProvider.cs
- TextMetrics.cs
- CaseStatement.cs
- HyperLinkStyle.cs
- SafeViewOfFileHandle.cs
- TextElementCollection.cs
- XamlTreeBuilder.cs
- ExpressionBindingCollection.cs
- HostingEnvironmentSection.cs
- ThicknessAnimationBase.cs
- ElementNotEnabledException.cs
- PaintEvent.cs
- XmlSchemaImport.cs
- HwndSource.cs
- RuleConditionDialog.cs
- Base64Stream.cs
- DataGridViewCheckBoxCell.cs
- DeviceContext.cs
- WebPartConnectionsCancelEventArgs.cs
- HttpContextWrapper.cs
- HuffmanTree.cs
- DataGridLinkButton.cs
- PropertyChangeTracker.cs
- XPathNodeIterator.cs
- ConfigurationSectionGroupCollection.cs
- DebuggerAttributes.cs
- SafeLocalMemHandle.cs
- HtmlCommandAdapter.cs
- DefaultProfileManager.cs
- JsonMessageEncoderFactory.cs
- MarkupExtensionParser.cs
- FormViewModeEventArgs.cs
- RemotingAttributes.cs
- OperationPerformanceCounters.cs
- LockCookie.cs
- DetailsView.cs
- loginstatus.cs
- Msec.cs
- VariableAction.cs
- TimeBoundedCache.cs
- TransactionException.cs
- IDispatchConstantAttribute.cs
- HealthMonitoringSectionHelper.cs
- ComponentEvent.cs
- TextRangeProviderWrapper.cs
- SqlUtil.cs
- DesignerGenericWebPart.cs
- DefaultValueTypeConverter.cs
- ColorEditor.cs
- SelectionItemProviderWrapper.cs
- ListViewDataItem.cs
- MenuItem.cs
- WorkflowMarkupSerializerMapping.cs
- ExpressionBuilder.cs
- SoapSchemaMember.cs
- StyleHelper.cs
- EnumConverter.cs
- ListContractAdapter.cs
- ContextMenuAutomationPeer.cs
- RadioButton.cs
- VariableQuery.cs
- SystemFonts.cs
- EventWaitHandleSecurity.cs
- ConfigsHelper.cs
- UrlMappingsModule.cs
- DataServiceRequestException.cs
- EventDescriptor.cs
- DataRelationCollection.cs
- RequestQueryProcessor.cs
- WriteTimeStream.cs
- OleDbInfoMessageEvent.cs
- DataGridViewRowEventArgs.cs
- DataServiceProcessingPipeline.cs
- ByteStack.cs
- WmiPutTraceRecord.cs
- TransformGroup.cs
- MarshalByValueComponent.cs
- InvalidPrinterException.cs
- TypeTypeConverter.cs
- AutoGeneratedField.cs
- InputElement.cs
- Point4DConverter.cs
- PermissionToken.cs
- CultureTableRecord.cs
- AttachedAnnotationChangedEventArgs.cs
- CustomCategoryAttribute.cs
- CompilerInfo.cs
- IntegerCollectionEditor.cs