Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- TemplateComponentConnector.cs
- ActivationServices.cs
- UserControlBuildProvider.cs
- MailHeaderInfo.cs
- PointUtil.cs
- ThreadExceptionEvent.cs
- EntitySqlException.cs
- SchemaNames.cs
- BamlRecords.cs
- SecurityHelper.cs
- BooleanFunctions.cs
- SR.Designer.cs
- DataGridViewCellCancelEventArgs.cs
- ClientConvert.cs
- LongSumAggregationOperator.cs
- BitmapEncoder.cs
- CompoundFileStreamReference.cs
- ViewStateModeByIdAttribute.cs
- EventToken.cs
- ExceptionHandlerDesigner.cs
- ApplicationFileCodeDomTreeGenerator.cs
- MergeFilterQuery.cs
- SpanIndex.cs
- ExpressionBuilder.cs
- AssemblyNameUtility.cs
- filewebresponse.cs
- DataGridViewRowEventArgs.cs
- SettingsPropertyValueCollection.cs
- DrawToolTipEventArgs.cs
- Pointer.cs
- SpeakInfo.cs
- PrintDialog.cs
- AttachedProperty.cs
- MultipartIdentifier.cs
- ExpressionNormalizer.cs
- SchemaTypeEmitter.cs
- XmlNavigatorStack.cs
- ItemList.cs
- WaitHandle.cs
- RawMouseInputReport.cs
- FloatSumAggregationOperator.cs
- ParseNumbers.cs
- MarshalDirectiveException.cs
- safelinkcollection.cs
- ConnectionsZone.cs
- WindowsGrip.cs
- SqlStream.cs
- InkCanvasSelectionAdorner.cs
- HttpWriter.cs
- XmlLoader.cs
- DataKeyCollection.cs
- ToolStripDropDownMenu.cs
- SystemException.cs
- BookmarkResumptionRecord.cs
- SHA1.cs
- ListViewContainer.cs
- OutputWindow.cs
- Material.cs
- CssTextWriter.cs
- FloaterParagraph.cs
- MinimizableAttributeTypeConverter.cs
- UriTemplateClientFormatter.cs
- ControlPropertyNameConverter.cs
- HtmlMeta.cs
- SRGSCompiler.cs
- MetadataCacheItem.cs
- Material.cs
- DefaultMergeHelper.cs
- JsonUriDataContract.cs
- ContainerUtilities.cs
- TextSelectionHighlightLayer.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- DataServiceRequestException.cs
- WindowsRegion.cs
- SqlServices.cs
- RewritingPass.cs
- ScalarOps.cs
- TaskFormBase.cs
- SspiSafeHandles.cs
- EncryptedReference.cs
- DataGridViewCheckBoxCell.cs
- ExpressionLexer.cs
- OutputCacheSettingsSection.cs
- Control.cs
- UTF7Encoding.cs
- QilCloneVisitor.cs
- ResourceExpressionBuilder.cs
- CacheEntry.cs
- ClientFormsAuthenticationMembershipProvider.cs
- TraceContextEventArgs.cs
- DragStartedEventArgs.cs
- CompilerResults.cs
- DesignerView.Commands.cs
- CorrelationActionMessageFilter.cs
- QilPatternVisitor.cs
- UpdateTranslator.cs
- SchemaEntity.cs
- LinqDataSourceView.cs
- BaseHashHelper.cs
- FloaterParaClient.cs