Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / xsp / System / Web / Extensions / ClientServices / ClientFormsIdentity.cs / 2 / 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
- ForEachAction.cs
- DataGridViewComboBoxCell.cs
- DefaultTraceListener.cs
- DecoderFallback.cs
- _RegBlobWebProxyDataBuilder.cs
- RuntimeCompatibilityAttribute.cs
- QueryExecutionOption.cs
- StringAttributeCollection.cs
- ChtmlPhoneCallAdapter.cs
- TimeSpanConverter.cs
- WebPartConnection.cs
- WebPartConnectionsConfigureVerb.cs
- HwndProxyElementProvider.cs
- DoubleKeyFrameCollection.cs
- WinInet.cs
- IgnoreSectionHandler.cs
- ListViewCancelEventArgs.cs
- DeclarativeExpressionConditionDeclaration.cs
- ToolStripDropDownClosingEventArgs.cs
- PasswordTextNavigator.cs
- CapabilitiesRule.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- _UncName.cs
- CodeCompiler.cs
- XamlToRtfParser.cs
- UshortList2.cs
- FixedSchema.cs
- SplitContainer.cs
- DbSource.cs
- TypeBuilderInstantiation.cs
- PermissionSet.cs
- CodeNamespaceCollection.cs
- MruCache.cs
- PathSegmentCollection.cs
- WebConfigurationManager.cs
- WebPartTransformerCollection.cs
- Input.cs
- WorkflowInstanceExtensionCollection.cs
- EdmComplexPropertyAttribute.cs
- Triplet.cs
- SqlNotificationRequest.cs
- WorkflowView.cs
- SafeEventHandle.cs
- WindowsListViewGroup.cs
- TypeElement.cs
- PersonalizationProviderCollection.cs
- AmbientValueAttribute.cs
- MobileControlsSectionHelper.cs
- InternalsVisibleToAttribute.cs
- ContentElement.cs
- SettingsPropertyCollection.cs
- WindowsListViewScroll.cs
- WindowsGraphicsCacheManager.cs
- IntPtr.cs
- ArrayList.cs
- OneOfTypeConst.cs
- IDQuery.cs
- WebPartDisplayModeCollection.cs
- RouteParametersHelper.cs
- ConnectorRouter.cs
- NullableFloatMinMaxAggregationOperator.cs
- DesignerSelectionListAdapter.cs
- SafeCancelMibChangeNotify.cs
- RowCache.cs
- IProvider.cs
- SmtpTransport.cs
- DetailsViewRowCollection.cs
- ViewGenerator.cs
- DateTimeSerializationSection.cs
- BitmapEffectDrawing.cs
- DataGridCellsPanel.cs
- TextUtf8RawTextWriter.cs
- SerialPinChanges.cs
- UidManager.cs
- DataSourceCollectionBase.cs
- Exception.cs
- TemplatedWizardStep.cs
- Cursors.cs
- ModulesEntry.cs
- Gdiplus.cs
- JumpItem.cs
- BinaryObjectInfo.cs
- PropertyGrid.cs
- LazyTextWriterCreator.cs
- DataGridViewRowHeaderCell.cs
- QueryCacheEntry.cs
- EntryPointNotFoundException.cs
- Brush.cs
- ProcessModelInfo.cs
- FieldCollectionEditor.cs
- RangeValueProviderWrapper.cs
- EllipseGeometry.cs
- SyndicationSerializer.cs
- FlowLayoutPanelDesigner.cs
- DataGridPreparingCellForEditEventArgs.cs
- ApplicationSecurityInfo.cs
- EncodingTable.cs
- DefaultTraceListener.cs
- XmlSerializableServices.cs
- CryptoStream.cs