using Codelyzer.Analysis;
using CTA.FeatureDetection.Common.Models.Features.Base;
namespace CTA.FeatureDetection.AuthType.CompiledFeatures
{
    public class WindowsImpersonationFeature : WebConfigFeature
    {
        /// 
        /// Determines if Windows Impersonation is being used in a given project based on
        /// Web.config settings.
        ///
        /// Qualifications:
        /// 1. Web.config uses windows impersonation:
        ///    
        ///      
        ///        
        ///        
        ///      
        ///    
        /// 
        /// 
        /// Source code analysis results
        /// Whether or not Windows Impersonation is used
        public override bool IsPresent(AnalyzerResult analyzerResult)
        {
            var config = LoadWebConfig(analyzerResult.ProjectResult.ProjectRootPath);
            return config.ContainsAttributeWithValue(Constants.IdentityElementPath, Constants.ImpersonateAttribute, true.ToString().ToLower());
        }
    }
}