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 / SmtpDigestAuthenticationModule.cs / 2 / SmtpDigestAuthenticationModule.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 SmtpDigestAuthenticationModule : ISmtpAuthenticationModule { Hashtable sessions = new Hashtable(); internal SmtpDigestAuthenticationModule() { } #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) { lock (this.sessions) { NTAuthentication clientContext = this.sessions[sessionCookie] as NTAuthentication; if (clientContext == null) { if (credential == null){ return null; } // this.sessions[sessionCookie] = clientContext = new NTAuthentication(false, "WDigest", credential, spn, ContextFlags.Connection, channelBindingToken); } string resp = clientContext.GetOutgoingBlob(challenge); if (!clientContext.IsCompleted) { return new Authorization(resp, false); } else { this.sessions.Remove(sessionCookie); return new Authorization(resp, true); } } } public string AuthenticationType { get { return "WDigest"; } } 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 SmtpDigestAuthenticationModule : ISmtpAuthenticationModule { Hashtable sessions = new Hashtable(); internal SmtpDigestAuthenticationModule() { } #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) { lock (this.sessions) { NTAuthentication clientContext = this.sessions[sessionCookie] as NTAuthentication; if (clientContext == null) { if (credential == null){ return null; } // this.sessions[sessionCookie] = clientContext = new NTAuthentication(false, "WDigest", credential, spn, ContextFlags.Connection, channelBindingToken); } string resp = clientContext.GetOutgoingBlob(challenge); if (!clientContext.IsCompleted) { return new Authorization(resp, false); } else { this.sessions.Remove(sessionCookie); return new Authorization(resp, true); } } } public string AuthenticationType { get { return "WDigest"; } } 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
- DataRecordInternal.cs
- thaishape.cs
- PolyLineSegment.cs
- WindowsBrush.cs
- FunctionDescription.cs
- SplitContainer.cs
- FreezableDefaultValueFactory.cs
- DispatcherFrame.cs
- UrlMappingsModule.cs
- VirtualDirectoryMapping.cs
- Point.cs
- Merger.cs
- XPathSelfQuery.cs
- SettingsPropertyNotFoundException.cs
- Highlights.cs
- TextReader.cs
- SqlDataSourceFilteringEventArgs.cs
- ApplicationCommands.cs
- __Filters.cs
- WebPartCancelEventArgs.cs
- HttpCookiesSection.cs
- FontConverter.cs
- WebPartConnectionsCloseVerb.cs
- SuppressIldasmAttribute.cs
- WindowsHyperlink.cs
- PriorityQueue.cs
- ColorBuilder.cs
- InkCanvasInnerCanvas.cs
- HtmlLiteralTextAdapter.cs
- Compiler.cs
- MergeFailedEvent.cs
- FrameworkContextData.cs
- TextEditorMouse.cs
- WindowsListViewItem.cs
- Pen.cs
- LogSwitch.cs
- XmlSequenceWriter.cs
- DataSourceCacheDurationConverter.cs
- MouseGestureValueSerializer.cs
- PeerContact.cs
- HostingEnvironmentSection.cs
- ResourceExpression.cs
- LockedHandleGlyph.cs
- MouseActionValueSerializer.cs
- MappingItemCollection.cs
- ListBoxAutomationPeer.cs
- SemaphoreFullException.cs
- OptimisticConcurrencyException.cs
- DataGridViewCellCollection.cs
- SchemaDeclBase.cs
- DisplayMemberTemplateSelector.cs
- ObjRef.cs
- RectIndependentAnimationStorage.cs
- SqlServices.cs
- RectConverter.cs
- XmlSecureResolver.cs
- UnsafeNativeMethods.cs
- DataGridViewColumnDesigner.cs
- PersistencePipeline.cs
- MethodBuilder.cs
- ContentElementAutomationPeer.cs
- XmlSchemaSubstitutionGroup.cs
- SR.cs
- MetabaseServerConfig.cs
- GorillaCodec.cs
- SQLGuid.cs
- SymbolPair.cs
- DataRecordInternal.cs
- Pkcs9Attribute.cs
- HttpCookie.cs
- Pipe.cs
- CustomAttributeSerializer.cs
- SingleResultAttribute.cs
- securestring.cs
- ToolStripSplitButton.cs
- ClientApiGenerator.cs
- DesignerCatalogPartChrome.cs
- CommandLibraryHelper.cs
- RequestCachePolicyConverter.cs
- QuotedPrintableStream.cs
- ObjectResult.cs
- EventRouteFactory.cs
- QueryReaderSettings.cs
- AutomationTextAttribute.cs
- SQLInt32Storage.cs
- ParseHttpDate.cs
- ExternalDataExchangeClient.cs
- BinaryReader.cs
- XmlEnumAttribute.cs
- XD.cs
- PartitionResolver.cs
- PasswordTextNavigator.cs
- DocumentEventArgs.cs
- MSG.cs
- RuntimeIdentifierPropertyAttribute.cs
- Facet.cs
- ListDictionary.cs
- OptimizedTemplateContentHelper.cs
- SaveFileDialog.cs
- RadioButtonAutomationPeer.cs