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
- ObjectDisposedException.cs
- ObjectAnimationBase.cs
- ExtendedPropertyInfo.cs
- ScriptBehaviorDescriptor.cs
- CollaborationHelperFunctions.cs
- PropertyTabAttribute.cs
- BitmapEffectRenderDataResource.cs
- ConstraintManager.cs
- PixelShader.cs
- WebPartDescription.cs
- SqlClientWrapperSmiStreamChars.cs
- ScriptModule.cs
- PolyBezierSegmentFigureLogic.cs
- DataColumnCollection.cs
- BuildDependencySet.cs
- ServiceBusyException.cs
- HasCopySemanticsAttribute.cs
- BuildResultCache.cs
- BlockCollection.cs
- EventProviderWriter.cs
- WindowsFormsHostAutomationPeer.cs
- SamlConstants.cs
- ToolStripHighContrastRenderer.cs
- XmlObjectSerializerReadContextComplexJson.cs
- ControlPropertyNameConverter.cs
- QueryCacheManager.cs
- BorderGapMaskConverter.cs
- DropTarget.cs
- DbProviderManifest.cs
- ComponentEditorPage.cs
- FontStyleConverter.cs
- ReadContentAsBinaryHelper.cs
- Container.cs
- ToolStripKeyboardHandlingService.cs
- GenericTextProperties.cs
- ComponentSerializationService.cs
- CommandID.cs
- HiddenField.cs
- CompressedStack.cs
- StylusPointPropertyId.cs
- OutKeywords.cs
- UDPClient.cs
- X509CertificateStore.cs
- CurrencyWrapper.cs
- XmlSchemaExternal.cs
- ByteKeyFrameCollection.cs
- DateTimeConstantAttribute.cs
- CapacityStreamGeometryContext.cs
- ClientSettingsProvider.cs
- HostingEnvironment.cs
- GridViewActionList.cs
- InputLangChangeRequestEvent.cs
- HtmlTableRow.cs
- AppDomainProtocolHandler.cs
- _OSSOCK.cs
- Attribute.cs
- ImageSourceConverter.cs
- InkCanvas.cs
- AdapterDictionary.cs
- ConnectionPoolRegistry.cs
- printdlgexmarshaler.cs
- WebPartChrome.cs
- ObjectStateEntry.cs
- TimeSpanConverter.cs
- InstanceKeyView.cs
- WebPartZone.cs
- GraphicsPath.cs
- RecognizedAudio.cs
- SponsorHelper.cs
- DataGridTextBoxColumn.cs
- ContainerControl.cs
- Directory.cs
- EventLogInformation.cs
- SecurityElement.cs
- StateWorkerRequest.cs
- COM2EnumConverter.cs
- DesignerAutoFormat.cs
- CookieParameter.cs
- XmlChildNodes.cs
- BitmapEncoder.cs
- ObjectCloneHelper.cs
- ReflectionTypeLoadException.cs
- PartialCachingAttribute.cs
- HtmlFormParameterWriter.cs
- RoutedEvent.cs
- GlobalizationAssembly.cs
- ChameleonKey.cs
- WorkflowApplicationAbortedException.cs
- AppSettingsReader.cs
- Model3DGroup.cs
- ConsoleCancelEventArgs.cs
- SynchronizationLockException.cs
- SqlExpressionNullability.cs
- TrackingAnnotationCollection.cs
- Utilities.cs
- ClientBuildManagerCallback.cs
- TraceHelpers.cs
- ScriptMethodAttribute.cs
- RectAnimationClockResource.cs
- PropertyManager.cs