Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / xsp / System / Web / Extensions / ClientServices / ClientFormsIdentity.cs / 1 / ClientFormsIdentity.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.ClientServices { using System; using System.Net; using System.Security.Principal; using System.Runtime.InteropServices; using System.Security; using System.Web.Security; using System.Diagnostics.CodeAnalysis; public class ClientFormsIdentity : IIdentity, IDisposable { public string Name { get { return _Name; }} public bool IsAuthenticated { get { return _IsAuthenticated; }} public string AuthenticationType { get { return _AuthenticationType; } } public CookieContainer AuthenticationCookies { get { return _AuthenticationCookies; } } public MembershipProvider Provider { get { return _Provider; } } public ClientFormsIdentity(string name, string password, MembershipProvider provider, string authenticationType, bool isAuthenticated, CookieContainer authenticationCookies) { _Name = name; _AuthenticationType = authenticationType; _IsAuthenticated = isAuthenticated; _AuthenticationCookies = authenticationCookies; _Password = GetSecureStringFromString(password); _Provider = provider; } public void RevalidateUser() { if (_Disposed) { throw new ObjectDisposedException(this.GetType().FullName); } _Provider.ValidateUser(_Name, GetStringFromSecureString(_Password)); } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (disposing) { if (_Password != null) { _Password.Dispose(); } } _Disposed = true; } private string _Name; private bool _IsAuthenticated; private string _AuthenticationType; private CookieContainer _AuthenticationCookies; private SecureString _Password; private MembershipProvider _Provider; private bool _Disposed; private static SecureString GetSecureStringFromString(string password) { char[] passwordChars = password.ToCharArray(); SecureString ss = new SecureString(); for (int iter = 0; iter < passwordChars.Length; iter++) ss.AppendChar(passwordChars[iter]); ss.MakeReadOnly(); return ss; } [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification="Reviewed and approved by feature crew")] private static string GetStringFromSecureString(SecureString securePass) { IntPtr bstr = IntPtr.Zero; try { bstr = Marshal.SecureStringToBSTR(securePass); return Marshal.PtrToStringBSTR(bstr); } finally { if (bstr != IntPtr.Zero) Marshal.FreeBSTR(bstr); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.ClientServices { using System; using System.Net; using System.Security.Principal; using System.Runtime.InteropServices; using System.Security; using System.Web.Security; using System.Diagnostics.CodeAnalysis; public class ClientFormsIdentity : IIdentity, IDisposable { public string Name { get { return _Name; }} public bool IsAuthenticated { get { return _IsAuthenticated; }} public string AuthenticationType { get { return _AuthenticationType; } } public CookieContainer AuthenticationCookies { get { return _AuthenticationCookies; } } public MembershipProvider Provider { get { return _Provider; } } public ClientFormsIdentity(string name, string password, MembershipProvider provider, string authenticationType, bool isAuthenticated, CookieContainer authenticationCookies) { _Name = name; _AuthenticationType = authenticationType; _IsAuthenticated = isAuthenticated; _AuthenticationCookies = authenticationCookies; _Password = GetSecureStringFromString(password); _Provider = provider; } public void RevalidateUser() { if (_Disposed) { throw new ObjectDisposedException(this.GetType().FullName); } _Provider.ValidateUser(_Name, GetStringFromSecureString(_Password)); } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (disposing) { if (_Password != null) { _Password.Dispose(); } } _Disposed = true; } private string _Name; private bool _IsAuthenticated; private string _AuthenticationType; private CookieContainer _AuthenticationCookies; private SecureString _Password; private MembershipProvider _Provider; private bool _Disposed; private static SecureString GetSecureStringFromString(string password) { char[] passwordChars = password.ToCharArray(); SecureString ss = new SecureString(); for (int iter = 0; iter < passwordChars.Length; iter++) ss.AppendChar(passwordChars[iter]); ss.MakeReadOnly(); return ss; } [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification="Reviewed and approved by feature crew")] private static string GetStringFromSecureString(SecureString securePass) { IntPtr bstr = IntPtr.Zero; try { bstr = Marshal.SecureStringToBSTR(securePass); return Marshal.PtrToStringBSTR(bstr); } finally { if (bstr != IntPtr.Zero) Marshal.FreeBSTR(bstr); } } } } // 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
- Utils.cs
- RootProfilePropertySettingsCollection.cs
- CLSCompliantAttribute.cs
- InternalMappingException.cs
- MenuCommand.cs
- Privilege.cs
- TraceHandlerErrorFormatter.cs
- GuidelineSet.cs
- SchemaCollectionCompiler.cs
- FileDataSourceCache.cs
- Helpers.cs
- WindowsRegion.cs
- ForceCopyBuildProvider.cs
- BasicHttpBinding.cs
- UInt32.cs
- WebPartDescription.cs
- CodeGenerationManager.cs
- DataTableMapping.cs
- XmlSchemas.cs
- WebServiceParameterData.cs
- ApplicationContext.cs
- RedistVersionInfo.cs
- ContextConfiguration.cs
- SiteMap.cs
- KeyInterop.cs
- MLangCodePageEncoding.cs
- TypeConverterValueSerializer.cs
- CngProperty.cs
- ObjectStorage.cs
- RequestResizeEvent.cs
- PopOutPanel.cs
- OpCodes.cs
- _NestedSingleAsyncResult.cs
- DesignerCalendarAdapter.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- ObjectView.cs
- PageContent.cs
- PrintController.cs
- Margins.cs
- ServiceRoute.cs
- VideoDrawing.cs
- ClientRuntimeConfig.cs
- SelectionListDesigner.cs
- ConnectionStringSettings.cs
- InvalidComObjectException.cs
- XmlSchemaAnyAttribute.cs
- InvalidOperationException.cs
- LineServices.cs
- Convert.cs
- glyphs.cs
- DSACryptoServiceProvider.cs
- AttachedPropertyBrowsableAttribute.cs
- AudioStateChangedEventArgs.cs
- ToolStripMenuItem.cs
- XmlAttributeHolder.cs
- ISAPIApplicationHost.cs
- SmtpNtlmAuthenticationModule.cs
- SmtpFailedRecipientException.cs
- DecimalFormatter.cs
- PinProtectionHelper.cs
- WindowsSlider.cs
- TypeInitializationException.cs
- SubMenuStyleCollection.cs
- XpsSerializerWriter.cs
- DbConnectionPoolCounters.cs
- ICollection.cs
- TableColumnCollectionInternal.cs
- DefaultTraceListener.cs
- DBBindings.cs
- Win32Exception.cs
- TreeNodeBindingDepthConverter.cs
- JsonWriter.cs
- TableCell.cs
- ClientTargetCollection.cs
- Message.cs
- LinearGradientBrush.cs
- QuaternionRotation3D.cs
- GridViewItemAutomationPeer.cs
- EntityTransaction.cs
- CookieHandler.cs
- DictionaryContent.cs
- FilterQuery.cs
- HttpFileCollection.cs
- ConfigXmlDocument.cs
- Variant.cs
- HostingMessageProperty.cs
- IsolatedStorageFilePermission.cs
- NativeMethods.cs
- EntityDataSourceSelectedEventArgs.cs
- DataGridViewCellEventArgs.cs
- GenericTypeParameterConverter.cs
- SafeNativeMethodsOther.cs
- TCPListener.cs
- IdentityHolder.cs
- WebHeaderCollection.cs
- WindowsScrollBarBits.cs
- CancelAsyncOperationRequest.cs
- Base64Stream.cs
- GroupItemAutomationPeer.cs
- DataRowIndexBuffer.cs