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
- _BufferOffsetSize.cs
- ObjectStateManager.cs
- FontWeights.cs
- NamespaceTable.cs
- TabControlEvent.cs
- HTTPNotFoundHandler.cs
- InvalidComObjectException.cs
- userdatakeys.cs
- ThumbAutomationPeer.cs
- CLSCompliantAttribute.cs
- TextLine.cs
- activationcontext.cs
- BigInt.cs
- CacheEntry.cs
- JournalEntryStack.cs
- ByeOperation11AsyncResult.cs
- QilReplaceVisitor.cs
- CertificateReferenceElement.cs
- BigInt.cs
- CompilationSection.cs
- CellLabel.cs
- PropertyToken.cs
- CompilerInfo.cs
- RowToFieldTransformer.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- TitleStyle.cs
- RemoteCryptoRsaServiceProvider.cs
- SortQueryOperator.cs
- DocumentReference.cs
- SerializationObjectManager.cs
- AliasExpr.cs
- CommandBinding.cs
- XhtmlBasicLabelAdapter.cs
- CodeCastExpression.cs
- adornercollection.cs
- DeploymentSection.cs
- SqlDataReader.cs
- SafeSecurityHandles.cs
- LoadedOrUnloadedOperation.cs
- IUnknownConstantAttribute.cs
- Menu.cs
- BrowserDefinitionCollection.cs
- XmlUrlResolver.cs
- HttpProtocolImporter.cs
- Exceptions.cs
- ScriptResourceAttribute.cs
- BindingMemberInfo.cs
- SchemaNames.cs
- ExecutionEngineException.cs
- X509ThumbprintKeyIdentifierClause.cs
- DomNameTable.cs
- XXXInfos.cs
- ReadContentAsBinaryHelper.cs
- OverrideMode.cs
- MissingSatelliteAssemblyException.cs
- BmpBitmapDecoder.cs
- MetadataArtifactLoaderCompositeFile.cs
- HttpChannelHelpers.cs
- GraphicsPath.cs
- RequestQueryProcessor.cs
- ScriptResourceInfo.cs
- OleTxTransaction.cs
- FilteredXmlReader.cs
- SoapIncludeAttribute.cs
- CursorConverter.cs
- AutomationElementCollection.cs
- UInt32.cs
- MexTcpBindingElement.cs
- XPathQilFactory.cs
- ConsumerConnectionPoint.cs
- MDIWindowDialog.cs
- TextAnchor.cs
- TextElement.cs
- DrawItemEvent.cs
- followingsibling.cs
- PathFigure.cs
- OdbcEnvironment.cs
- DecimalAnimationBase.cs
- OleDbException.cs
- WebReferencesBuildProvider.cs
- Baml2006ReaderSettings.cs
- PermissionAttributes.cs
- CharConverter.cs
- GridViewEditEventArgs.cs
- LoginCancelEventArgs.cs
- ProtocolsConfigurationHandler.cs
- EntityProviderServices.cs
- WhereaboutsReader.cs
- DataServiceQueryContinuation.cs
- RedirectionProxy.cs
- EntityDataSourceViewSchema.cs
- TraceEventCache.cs
- BitmapPalette.cs
- DynamicValueConverter.cs
- Gdiplus.cs
- ImageSourceValueSerializer.cs
- SimpleLine.cs
- ContentTypeSettingDispatchMessageFormatter.cs
- DataGridPagerStyle.cs
- SaveFileDialog.cs