using System.Collections.Generic;

namespace HRD.LDAPService.JWT
{
    public static class JwtTokenConfig
    {
        private static string secret;

        public static int ExpirationInMin { get; set; }
        public static string Secret { get; set; }
        public static string Issuer { get; internal set; }
        public static string Audience { get; internal set; }

#warning use internal setter
        public static List<JwtRole> JwtRoleList { get; set; } = new List<JwtRole>();
        public static List<string> AuthorizationFilterWhitelistPath { get; set; }
        public static List<string> AuthorizationFilterBlacklistPath { get; set; }
        public static bool AktivateAuthorizationFilter { get; set; }
        public static bool DeaktivateLDAP { get; set; }

        public static bool IsInWhiteList(string path)
        {
            if (string.IsNullOrEmpty(path)) { return false; }
            foreach (var item in JwtTokenConfig.AuthorizationFilterWhitelistPath)
            {
                if (path.Contains(item, System.StringComparison.InvariantCultureIgnoreCase))
                {
                    return true;
                }
            }

            return false;
        }

        public static bool IsInBlackList(string path)
        {
            if (string.IsNullOrEmpty(path)) { return false; }
            foreach (var item in JwtTokenConfig.AuthorizationFilterBlacklistPath)
            {
                if (path.Contains(item, System.StringComparison.InvariantCultureIgnoreCase))
                {
                    return true;
                }
            }

            return false;
        }
    }
}