Esempio n. 1
0
        public static int UserRegistration(ThisUser entity, string ipAddress, string type, string extra = "")
        {
            string server = UtilityManager.GetAppKeyValue("serverName", "");

            SiteActivity log = new SiteActivity();

            log.CreatedDate  = System.DateTime.Now;
            log.ActivityType = "Audit";
            log.Activity     = "Account";
            log.Event        = type;
            log.Comment      = string.Format("{0} ({1}) {4}. From IPAddress: {2}, on server: {3}. {5}", entity.FullName(), entity.Id, ipAddress, server, type, extra);
            //actor type - person, system
            log.ActionByUserId = entity.Id;
            log.TargetUserId   = entity.Id;
            log.SessionId      = ActivityManager.GetCurrentSessionId();
            try
            {
                return(new ActivityManager().SiteActivityAdd(log));
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".UserRegistrationFromPortal()");
                return(0);
            }
        }
        //TBD


        /// <summary>
        /// The actual validation will be via a call to the accounts api
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="statusMessage"></param>
        /// <returns></returns>
        public static bool ValidateRequest(RequestHelper helper, ref string statusMessage, bool isDeleteRequest = false)
        {
            bool   isValid          = true;
            string clientIdentifier = "";
            bool   isTokenRequired  = UtilityManager.GetAppKeyValue("requiringHeaderToken", true);

            if (isDeleteRequest)
            {
                isTokenRequired = true;
            }

            //api key will be passed in the header
            string apiToken = "";

            if (IsAuthTokenValid(isTokenRequired, ref apiToken, ref clientIdentifier, ref statusMessage) == false)
            {
                return(false);
            }
            helper.ApiKey           = apiToken;
            helper.ClientIdentifier = clientIdentifier ?? "";

            if (isTokenRequired &&
                (string.IsNullOrWhiteSpace(helper.OwnerCtid) ||
                 !helper.OwnerCtid.ToLower().StartsWith("ce-") ||
                 helper.OwnerCtid.Length != 39)
                )
            {
                if (clientIdentifier.ToLower().StartsWith("cerpublisher") == false)
                {
                    statusMessage = "Error - a valid CTID for the related organization must be provided.";
                    return(false);
                }
            }
            return(isValid);
        }
        public static void LoadCommonIndex(bool deletingIndexBeforeRebuild)
        {
            DisplayMessages("Starting LoadCommonIndex: " + UtilityManager.GetAppKeyValue("commonCollection", "missing commonCollection"));

            try
            {
                //int processed = 0;
                DateTime start = DateTime.Now;
                //do delete  for first one, but not second
                //DisplayMessages( "Starting Pathway" );
                //ElasticHelper.Pathway_BuildIndex( deletingIndexBeforeRebuild, true );
                //DateTime end = DateTime.Now;
                //var elasped = end.Subtract( start ).TotalSeconds;
                //DisplayMessages( string.Format( "___Completed LoadCommonIndex for pathway. Elapsed Seconds: {0}", elasped ) );
                //deletingIndexBeforeRebuild = false;
                //next
                //processed = 0;
                DisplayMessages("Starting Transfer Value Profile");
                start = DateTime.Now;
                ElasticHelper.General_BuildIndexForTVP(deletingIndexBeforeRebuild, true);
                //ElasticHelper.General_UpdateIndexForTVP( "", ref processed );
                DateTime end2       = DateTime.Now;
                var      tvpElasped = end2.Subtract(start).TotalSeconds;

                DisplayMessages(string.Format("___Completed LoadCommonIndex for transfer value. Elapsed Seconds: {0}", tvpElasped));
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, "LoadCommonIndex Failed", "ElasticIndex Build Exception");
            }
        }
        //	public static List<CodeItem> SearchAsCodeItem( string keyword, int startingPageNbr, int pageSize, ref int totalRows )
        //	{
        //		List<ThisEntity> list = Search( keyword, startingPageNbr, pageSize, ref totalRows );
        //		List<CodeItem> codes = new List<CodeItem>();
        //		foreach (ThisEntity item in list)
        //		{
        //			codes.Add(new CodeItem() {
        //				Id = item.Id,
        //				Name = item.Name,
        //				Description = item.Description
        //			});
        //		}
        //		return codes;
        //}
        public static List <object> Autocomplete(string keyword, int maxTerms = 25)
        {
            string where = "";
            int totalRows = 0;

            //SetKeywordFilter( keyword, true, ref where );
            string keywords = ServiceHelper.HandleApostrophes(keyword);

            if (keywords.IndexOf("%") == -1)
            {
                keywords = "%" + keywords.Trim() + "%";
            }
            where = string.Format(" (base.name like '{0}') ", keywords);


            if (UtilityManager.GetAppKeyValue("usingElasticAssessmentSearch", false))
            {
                return(ElasticServices.AssessmentAutoComplete(keyword, maxTerms, ref totalRows));
            }
            else
            {
                SetKeywordFilter(keyword, true, ref where);
                return(EntityMgr.Autocomplete(where, 1, maxTerms, ref totalRows));
            }
        }
        public static List <object> Autocomplete(string keyword = "", int maxTerms = 25, int widgetId = 0)
        {
            int userId = 0;

            string where = "";
            int     totalRows = 0;
            AppUser user      = AccountServices.GetCurrentUser();

            if (user != null && user.Id > 0)
            {
                userId = user.Id;
            }
            //SetAuthorizationFilter( user, ref where );


            if (UtilityManager.GetAppKeyValue("usingElasticOrganizationSearch", false))
            {
                return(ElasticHelper.OrganizationAutoComplete(keyword, maxTerms, ref totalRows));
            }
            else
            {
                SetKeywordFilter(keyword, true, ref where);
                //string keywords = ServiceHelper.HandleApostrophes( keyword );
                //if ( keywords.IndexOf( "%" ) == -1 )
                //	keywords = "%" + keywords.Trim() + "%";
                //where = string.Format( " (base.name like '{0}') ", keywords );

                return(EntityMgr.Autocomplete(where, 1, maxTerms, userId, ref totalRows));
            }
        }
Esempio n. 6
0
        public static List <object> Autocomplete(string pFilter, int pageNumber, int pageSize, ref int pTotalRows)
        {
            bool          autocomplete   = true;
            List <object> results        = new List <object>();
            List <string> competencyList = new List <string>();
            //ref competencyList,
            List <ThisEntity> list = Search(pFilter, "", pageNumber, pageSize, ref pTotalRows, autocomplete);
            bool   appendingOrgNameToAutocomplete = UtilityManager.GetAppKeyValue("appendingOrgNameToAutocomplete", false);
            string prevName = "";

            foreach (OccupationProfile item in list)
            {
                //note excluding duplicates may have an impact on selected max terms
                if (string.IsNullOrWhiteSpace(item.OrganizationName) ||
                    !appendingOrgNameToAutocomplete)
                {
                    if (item.Name.ToLower() != prevName)
                    {
                        results.Add(item.Name);
                    }
                }
                else
                {
                    results.Add(item.Name + " ('" + item.OrganizationName + "')");
                }

                prevName = item.Name.ToLower();
            }
            return(results);
        }
        public bool ProcessEnvelope(ReadEnvelope item, SaveStatus status)
        {
            if (item == null || string.IsNullOrWhiteSpace(item.EnvelopeIdentifier))
            {
                status.AddError(thisClassName + " A valid ReadEnvelope must be provided.");
                return(false);
            }

            DateTime createDate         = new DateTime();
            DateTime envelopeUpdateDate = new DateTime();

            if (DateTime.TryParse(item.NodeHeaders.CreatedAt.Replace("UTC", "").Trim(), out createDate))
            {
                status.SetEnvelopeCreated(createDate);
            }
            if (DateTime.TryParse(item.NodeHeaders.UpdatedAt.Replace("UTC", "").Trim(), out envelopeUpdateDate))
            {
                status.SetEnvelopeUpdated(envelopeUpdateDate);
            }

            string payload            = item.DecodedResource.ToString();
            string envelopeIdentifier = item.EnvelopeIdentifier;
            string ctdlType           = RegistryServices.GetResourceType(payload);
            string envelopeUrl        = RegistryServices.GetEnvelopeUrl(envelopeIdentifier);

            LoggingHelper.DoTrace(5, "		envelopeUrl: "+ envelopeUrl);
            LoggingHelper.WriteLogFile(UtilityManager.GetAppKeyValue("logFileTraceLevel", 5), item.EnvelopeCetermsCtid + "_ConceptScheme", payload, "", false);

            //just store input for now
            return(Import(payload, envelopeIdentifier, status));

            //return true;
        } //
Esempio n. 8
0
        //public void UpdateRoles( string aspNetUserId, string[] roles )
        //{
        //	AppUser user = GetCurrentUser();
        //	new AccountManager().UpdateRoles( aspNetUserId, roles );
        //}


        #endregion

        #region email methods
        /// <summary>
        /// Send reset password email
        /// </summary>
        /// <param name="subject"></param>
        /// <param name="toEmail"></param>
        /// <param name="url">Will be a formatted callback url</param>
        public static void SendEmail_ResetPassword(string toEmail, string url)
        {
            //should have a valid email at this point (if from identityConfig)
            AppUser user = GetUserByEmail(toEmail);

            bool isSecure = false;

            if (UtilityManager.GetAppKeyValue("usingSSL", false))
            {
                isSecure = true;
            }
            string bcc = UtilityManager.GetAppKeyValue("systemAdminEmail", "*****@*****.**");

            string fromEmail = UtilityManager.GetAppKeyValue("contactUsMailFrom", "*****@*****.**");
            string subject   = "Reset Password for your Credential Finder account";

            string email    = EmailManager.GetEmailText("ForgotPassword");
            string eMessage = "";

            try
            {
                //assign and substitute: 0-FirstName, 1-callback url from AccountController
                eMessage = string.Format(email, user.FirstName, url);


                EmailManager.SendEmail(toEmail, fromEmail, subject, eMessage, "", bcc);
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".SendEmail_ResetPassword()");
            }
        }
        /// <summary>
        /// Credential autocomplete
        /// Needs to check authorization level for credential
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="maxTerms"></param>
        /// <returns></returns>
        public static List <object> Autocomplete(string keyword, int maxTerms = 25)
        {
            int userId = 0;

            string where = "";
            int     pTotalRows = 0;
            AppUser user       = AccountServices.GetCurrentUser();

            if (user != null && user.Id > 0)
            {
                userId = user.Id;
            }
            SetAuthorizationFilter(user, ref where);

            SetKeywordFilter(keyword, true, ref where);

            if (UtilityManager.GetAppKeyValue("usingElasticCredentialSearch", false))
            {
                return(ElasticServices.CredentialAutoComplete(keyword, maxTerms, ref pTotalRows));
            }
            else
            {
                return(CredentialManager.Autocomplete(where, 1, maxTerms, ref pTotalRows));
            }
            // return new List<string>();
        }
        }        //

        public static List <CommonSearchSummary> PathwaySetSearch2(MainSearchInput data, ref int pTotalRows)
        {
            if (UtilityManager.GetAppKeyValue("usingElasticPathwaySetSearch", false))
            {
                return(ElasticHelper.PathwaySetSearch(data, ref pTotalRows));
            }
            else
            {
                List <CommonSearchSummary> results = new List <CommonSearchSummary>();
                var list = DoPathwaySetSearch(data, ref pTotalRows);
                foreach (var item in list)
                {
                    results.Add(new CommonSearchSummary()
                    {
                        Id                      = item.Id,
                        Name                    = item.Name,
                        Description             = item.Description,
                        SubjectWebpage          = item.SubjectWebpage,
                        PrimaryOrganizationName = item.PrimaryOrganizationName,
                        CTID                    = item.CTID,
                        EntityTypeId            = CodesManager.ENTITY_TYPE_PATHWAY_SET,
                        EntityType              = "PathwaySet"
                    });
                }
                return(results);
            }
        }        //
Esempio n. 11
0
        public static void AddConditionProfileToCache(ConditionProfile entity)
        {
            int cacheMinutes = UtilityManager.GetAppKeyValue("learningOppCacheMinutes", 0);

            string key = "ConditionProfile_" + entity.Id.ToString();

            if (cacheMinutes > 0)
            {
                var newCache = new CachedConditionProfile()
                {
                    Item        = entity,
                    lastUpdated = DateTime.Now
                };
                if (HttpContext.Current != null)
                {
                    if (HttpContext.Current.Cache[key] != null)
                    {
                        HttpRuntime.Cache.Remove(key);
                        HttpRuntime.Cache.Insert(key, newCache);

                        LoggingHelper.DoTrace(7, string.Format("===CacheManager.AddConditionProfileToCache $$$ Updating cached version of ConditionProfile, Id: {0}, {1}", entity.Id, entity.ProfileName));
                    }
                    else
                    {
                        LoggingHelper.DoTrace(7, string.Format("===CacheManager.AddConditionProfileToCache ****** Inserting new cached version of ConditionProfile, Id: {0}, {1}", entity.Id, entity.ProfileName));

                        System.Web.HttpRuntime.Cache.Insert(key, newCache, null, DateTime.Now.AddHours(cacheMinutes), TimeSpan.Zero);
                    }
                }
            }

            //return entity;
        }
Esempio n. 12
0
        public static bool IsConditionProfileAvailableFromCache(int id, ref ConditionProfile entity)
        {
            //use same as lopp for now
            int      cacheMinutes = UtilityManager.GetAppKeyValue("learningOppCacheMinutes", 0);
            DateTime maxTime      = DateTime.Now.AddMinutes(cacheMinutes * -1);

            string key = "ConditionProfile_" + id.ToString();

            if (HttpRuntime.Cache[key] != null && cacheMinutes > 0)
            {
                var cache = ( CachedConditionProfile )HttpRuntime.Cache[key];
                try
                {
                    if (cache.lastUpdated > maxTime)
                    {
                        LoggingHelper.DoTrace(7, string.Format("===CacheManager.IsConditionProfileAvailableFromCache === Using cached version of ConditionProfile, Id: {0}, {1}", cache.Item.Id, cache.Item.ProfileName));

                        //check if user can update the object
                        //string status = "";
                        //if ( !CanUserUpdateCredential( id, user, ref status ) )
                        //	cache.Item.CanEditRecord = false;

                        entity = cache.Item;
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    LoggingHelper.DoTrace(6, "===CacheManager.IsConditionProfileAvailableFromCache === exception " + ex.Message);
                }
            }

            return(false);
        }
Esempio n. 13
0
        public static void AddCredentialToCache(Credential entity, string key)
        {
            int cacheMinutes = UtilityManager.GetAppKeyValue("credentialCacheMinutes", 60);

            //string key = "credential_" + entity.Id.ToString();

            if (cacheMinutes > 0)
            {
                var newCache = new CachedCredential()
                {
                    Item        = entity,
                    lastUpdated = DateTime.Now
                };
                if (HttpContext.Current != null)
                {
                    if (HttpContext.Current.Cache[key] != null)
                    {
                        HttpRuntime.Cache.Remove(key);
                        HttpRuntime.Cache.Insert(key, newCache, null, DateTime.Now.AddHours(cacheMinutes), TimeSpan.Zero);

                        LoggingHelper.DoTrace(7, string.Format("===CacheManager.AddCredentialToCache $$$ Updating cached version of credential, Id: {0}, {1}, key: {2}", entity.Id, entity.Name, key));
                    }
                    else
                    {
                        LoggingHelper.DoTrace(7, string.Format("===CacheManager.AddCredentialToCache ****** Inserting new cached version of credential, Id: {0}, {1}, key: {2}", entity.Id, entity.Name, key));

                        System.Web.HttpRuntime.Cache.Insert(key, newCache, null, DateTime.Now.AddHours(cacheMinutes), TimeSpan.Zero);
                    }
                }
            }

            //return entity;
        }
Esempio n. 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="key">The key could vary if for detail, compare, etc</param>
        /// <param name="?"></param>
        /// <returns></returns>
        public static bool IsCredentialAvailableFromCache(int id, string key, ref Credential credential)
        {
            int      cacheMinutes = UtilityManager.GetAppKeyValue("credentialCacheMinutes", 60);
            DateTime maxTime      = DateTime.Now.AddMinutes(cacheMinutes * -1);

            //string key = "credential_" + id.ToString();

            if (HttpRuntime.Cache[key] != null && cacheMinutes > 0)
            {
                var cache = ( CachedCredential )HttpRuntime.Cache[key];
                try
                {
                    if (cache.lastUpdated > maxTime)
                    {
                        LoggingHelper.DoTrace(7, string.Format("===CacheManager.IsCredentialAvailableFromCache === Using cached version of Credential, Id: {0}, {1}, key: {2}", cache.Item.Id, cache.Item.Name, key));

                        //check if user can update the object
                        //or move these checks to the manager
                        //string status = "";
                        //if ( !CanUserUpdateCredential( id, user, ref status ) )
                        //	cache.Item.CanEditRecord = false;

                        credential = cache.Item;
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    LoggingHelper.DoTrace(6, "===CacheManager.IsCredentialAvailableFromCache === exception " + ex.Message);
                }
            }

            return(false);
        }
Esempio n. 15
0
        public static void SessionStartActivity(string comment, string sessionId, string ipAddress, string referrer, bool isBot)
        {
            SiteActivity log = new SiteActivity();
            //bool isBot = false;
            string server = UtilityManager.GetAppKeyValue("serverName", "");

            try
            {
                if (comment == null)
                {
                    comment = "";
                }

                log.CreatedDate  = System.DateTime.Now;
                log.ActivityType = "Audit";
                log.Activity     = "Session";
                log.Event        = "Start";
                log.Comment      = comment + string.Format(" (on server: {0})", server);
                //already have agent
                //log.Comment += GetUserAgent(ref isBot);

                log.SessionId = sessionId;
                log.IPAddress = ipAddress;
                log.Referrer  = referrer;

                new ActivityManager().SiteActivityAdd(log);
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".SessionStartActivity()");
                return;
            }
        }
Esempio n. 16
0
        //public static bool CanUserViewDetails( AppUser user, ref string status )
        //{
        //	//this method will not expect a status message
        //	status = "";
        //	if ( user == null || user.Id == 0 )
        //	{
        //		status = "You must be authenticated and authorized before being allowed to view any content.";
        //		return false;
        //	}

        //	if ( user.UserRoles.Contains( "Administrator" )
        //	  || user.UserRoles.Contains( "Site Manager" )
        //	  || user.UserRoles.Contains( "Site Staff" )
        //	  || user.UserRoles.Contains( "Site Partner" )
        //	  || user.UserRoles.Contains( "Site Reader" )
        //		)
        //		return true;


        //	return false;
        //}
        public static bool CanUserViewAllContent(AppUser user)
        {
            //this method will not expect a status message
            //status = "";
            if (user == null || user.Id == 0)
            {
                //status = "You must be authenticated and authorized before being allowed to view any content.";
                return(false);
            }

            if (user.UserRoles.Contains("Administrator") ||
                user.UserRoles.Contains("Site Manager") ||
                user.UserRoles.Contains("Site Staff") ||
                user.UserRoles.Contains("Site Partner") ||
                user.UserRoles.Contains("Site Reader")
                )
            {
                return(true);
            }

            bool canEditorsViewAll = UtilityManager.GetAppKeyValue("canEditorsViewAll", false);

            //if allowing anyone with edit for any org return true;
            //**if ( canEditorsViewAll && OrganizationServices.IsMemberOfAnOrganization( user.Id ) )
            //	return true;

            return(false);
        }
Esempio n. 17
0
        public static int UserRegistrationConfirmation(ThisUser entity, string type)
        {
            string server = UtilityManager.GetAppKeyValue("serverName", "");
            //EFDAL.IsleContentEntities ctx = new EFDAL.IsleContentEntities();
            SiteActivity log = new SiteActivity();

            try
            {
                log.CreatedDate  = System.DateTime.Now;
                log.ActivityType = "Audit";
                log.Activity     = "Account";
                log.Event        = "Confirmation";
                log.Comment      = string.Format("{0} ({1}) Registration Confirmation, on server: {2}, tyep: {3}", entity.FullName(), entity.Id, server, type);
                //actor type - person, system
                log.ActionByUserId = entity.Id;
                log.TargetUserId   = entity.Id;

                log.SessionId = ActivityManager.GetCurrentSessionId();

                return(new ActivityManager().SiteActivityAdd(log));
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".UserRegistrationConfirmation()");
                return(0);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Send email to confirm new account
        /// </summary>
        /// <param name="subject"></param>
        /// <param name="toEmail"></param>
        /// <param name="url">Will be a formatted callback url</param>
        public static void SendEmail_ConfirmAccount(string toEmail, string url)
        {
            //should have a valid email at this point (if from identityConfig)
            AppUser user = GetUserByEmail(toEmail);


            //string toEmail = user.Email;
            string bcc = UtilityManager.GetAppKeyValue("systemAdminEmail", "*****@*****.**");

            string fromEmail = UtilityManager.GetAppKeyValue("contactUsMailFrom", "*****@*****.**");
            string subject   = "Confirm Your Credential Finder Account";
            string email     = EmailManager.GetEmailText("ConfirmAccount");
            string eMessage  = "";

            try
            {
                //assign and substitute: 0-FirstName, 1-body from AccountController
                eMessage = string.Format(email, user.FirstName, url);

                EmailManager.SendEmail(toEmail, fromEmail, subject, eMessage, "", bcc);
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".SendEmail_ConfirmPassword()");
            }
        }
Esempio n. 19
0
 public static List <CommonSearchSummary> Search(MainSearchInput data, ref int pTotalRows)
 {
     if (UtilityManager.GetAppKeyValue("usingElasticTransferValueSearch", false))
     {
         //var results = ElasticHelper.GeneralSearch( CodesManager.ENTITY_TYPE_TRANSFER_VALUE_PROFILE, data, ref pTotalRows );
         return(ElasticHelper.GeneralSearch(CodesManager.ENTITY_TYPE_TRANSFER_VALUE_PROFILE, "TransferValue", data, ref pTotalRows));
     }
     else
     {
         List <CommonSearchSummary> results = new List <CommonSearchSummary>();
         var list = DoSearch(data, ref pTotalRows);
         foreach (var item in list)
         {
             results.Add(new CommonSearchSummary()
             {
                 Id                      = item.Id,
                 Name                    = item.Name,
                 Description             = item.Description,
                 SubjectWebpage          = item.SubjectWebpage,
                 PrimaryOrganizationName = item.PrimaryOrganizationName,
                 CTID                    = item.CTID,
                 EntityTypeId            = CodesManager.ENTITY_TYPE_TRANSFER_VALUE_PROFILE,
                 EntityType              = "TransferValueProfile"
             });
         }
         return(results);
     }
 }        //
Esempio n. 20
0
        /// <summary>
        /// Store an identity code
        /// </summary>
        /// <param name="proxyCode"></param>
        /// <param name="userId"></param>
        /// <param name="proxyType"></param>
        /// <returns></returns>
        public bool Proxies_StoreProxyCode(string proxyCode, int userId, string proxyType)
        {
            string statusMessage = "";

            int expiryDays = UtilityManager.GetAppKeyValue("forgotPasswordExpiryDays", 1);

            return(new AccountManager().Store_ProxyCode(proxyCode, userId, proxyType, expiryDays, ref statusMessage));
        }
Esempio n. 21
0
        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Configure the db context, user manager and signin manager to use a single instance per request
            app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext <ApplicationSignInManager>(ApplicationSignInManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            // Configure the sign in cookie
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Account/Login"),
                Provider           = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
            app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));

            // Enables the application to remember the second login verification factor such as phone or email.
            // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from.
            // This is similar to the RememberMe option when you log in.
            app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            var clientId = UtilityManager.GetAppKeyValue("goggleClientId");

            if (!string.IsNullOrWhiteSpace(clientId) && clientId.IndexOf("###") == -1)
            {
                app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
                {
                    ClientId     = UtilityManager.GetAppKeyValue("goggleClientId"),
                    ClientSecret = UtilityManager.GetAppKeyValue("goggleClientSecret")
                });
            }
        }
Esempio n. 22
0
        //

        #endregion

        #region CASS

        public static string CurrentCassDomain()         //Should get this from web.config
        {
            string cassSearchUrl = UtilityManager.GetAppKeyValue("cassSearchUrl");

            return(cassSearchUrl);
            //return "https://dev.cassproject.org";
            //return "http://sandbox.service.cassproject.org";
            //return "http://cass.credentialfinder.net";
        }
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                //no need to get and cache if called from batch import - maybe during day, but likelihood of issues is small?
                if (UtilityManager.GetAppKeyValue("credentialCacheMinutes", 0) > 0)
                {
                    if (System.DateTime.Now.Hour > 7 && System.DateTime.Now.Hour < 18)
                    {
                        GetDetail(entity.Id);
                    }
                }
            }
            bool          isValid  = new EntityMgr().Save(entity, ref status);
            List <string> messages = new List <string>();

            if (entity.Id > 0)
            {
                if (UtilityManager.GetAppKeyValue("credentialCacheMinutes", 0) > 0)
                {
                    CacheManager.RemoveItemFromCache("credential", entity.Id);
                }

                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    ThreadPool.QueueUserWorkItem(UpdateCaches, entity);

                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
                else
                {
                    //only update elatic if has apparent relevent changes
                    if (status.UpdateElasticIndex)
                    {
                        new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_CREDENTIAL, entity.Id, 1, ref messages);
                    }
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    //check for embedded items
                    //has part
                    AddCredentialsToPendingReindex(entity.HasPartIds);
                    AddCredentialsToPendingReindex(entity.IsPartOfIds);

                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
            }

            return(isValid);
        }
Esempio n. 24
0
        //public static string GetRegistryEnvelopeUrl(string community)
        //{
        //	//the app key should be changed to be more meaningful!!
        //	string serviceUri = UtilityManager.GetAppKeyValue( "cerGetEnvelope" );
        //	serviceUri = string.Format( serviceUri, community );
        //	return serviceUri;
        //}
        public static string GetRegistryUrl(string appKey, string community)
        {
            //requires all urls to have a parameter?
            //or, check if the default community exists
            //also have to handle an absence community
            string serviceUri = UtilityManager.GetAppKeyValue(appKey);

            serviceUri = string.Format(serviceUri, community);
            return(serviceUri);
        }
        //public static List<ThisEntity> Search( string keywords, int pageNumber, int pageSize, ref int totalRows )
        //{
        //	string pOrderBy = "";
        //	string filter = "";
        //	int userId = 0;
        //	AppUser user = AccountServices.GetCurrentUser();
        //	if ( user != null && user.Id > 0 )
        //		userId = user.Id;

        //	SetKeywordFilter( keywords, true, ref filter );
        //	//SetAuthorizationFilter( user, ref filter );

        //	return EntityMgr.Search( filter, pOrderBy, pageNumber, pageSize, ref totalRows );
        //}

        public static List <ThisEntity> Search(MainSearchInput data, ref int pTotalRows)
        {
            if (UtilityManager.GetAppKeyValue("usingElasticAssessmentSearch", false))
            {
                return(ElasticHelper.AssessmentSearch(data, ref pTotalRows));
            }
            else
            {
                return(DoSearch(data, ref pTotalRows));
            }
        }
Esempio n. 26
0
        public static string GetRegistrySearchUrl(string community = "")
        {
            if (string.IsNullOrWhiteSpace(community))
            {
                community = UtilityManager.GetAppKeyValue("defaultCommunity");
            }
            string serviceUri = UtilityManager.GetAppKeyValue("credentialRegistrySearch");

            serviceUri = string.Format(serviceUri, community);
            return(serviceUri);
        }
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                if (UtilityManager.GetAppKeyValue("organizationCacheMinutes", 0) > 0)
                {
                    if (System.DateTime.Now.Hour > 7 && System.DateTime.Now.Hour < 18)
                    {
                        GetDetail(entity.Id);
                    }
                }
            }
            bool          isValid  = new EntityMgr().Save(entity, ref status);
            List <string> messages = new List <string>();

            if (entity.Id > 0)
            {
                if (UtilityManager.GetAppKeyValue("organizationCacheMinutes", 0) > 0)
                {
                    CacheManager.RemoveItemFromCache("organization", entity.Id);
                }

                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    //update cache
                    ThreadPool.QueueUserWorkItem(UpdateCaches, entity);
                }
                else
                {
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.Id, 1, ref messages);
                    //add all credential in a verification profile
                    if (entity.VerificationServiceProfiles != null && entity.VerificationServiceProfiles.Count > 0)
                    {
                        foreach (var profile in entity.VerificationServiceProfiles)
                        {
                            if (profile.TargetCredential != null &&
                                profile.TargetCredential.Count > 0)
                            {
                                new CredentialServices().AddCredentialsToPendingReindex(profile.TargetCredential);
                            }
                        }
                    }
                    //20-11-20 mp re: QA performed
                    //				- may have to reindex all orgs etc that have QA performed by a QA org!!!
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
            }

            return(isValid);
        }
 public static List <OrganizationSummary> Search(MainSearchInput data, ref int pTotalRows)
 {
     if (UtilityManager.GetAppKeyValue("usingElasticOrganizationSearch", false))
     {
         return(ElasticHelper.OrganizationSearch(data, ref pTotalRows));
     }
     else
     {
         return(DoSearch(data, ref pTotalRows));
     }
 }
 /// <summary>
 /// Full credentials search
 /// </summary>
 /// <param name="data"></param>
 /// <param name="pTotalRows"></param>
 /// <returns></returns>
 public static List <ThisSearchEntity> Search(MainSearchInput data, ref int pTotalRows)
 {
     if (UtilityManager.GetAppKeyValue("usingElasticCredentialSearch", false) || data.Elastic)
     {
         return(ElasticHelper.Credential_Search(data, ref pTotalRows));
     }
     else
     {
         return(DoSearch(data, ref pTotalRows));
     }
 }
Esempio n. 30
0
        //public static List<ThisEntity> Search( string keywords, int pageNumber, int pageSize, ref int totalRows )
        //{
        //	string pOrderBy = "";
        //	string filter = "";
        //	int userId = 0;
        //	AppUser user = AccountServices.GetCurrentUser();
        //	if ( user != null && user.Id > 0 )
        //		userId = user.Id;

        //	SetKeywordFilter( keywords, true, ref filter );
        //	//SetAuthorizationFilter( user, ref filter );

        //	return EntityMgr.Search( filter, pOrderBy, pageNumber, pageSize, ref totalRows );
        //}

        public static List <ThisEntity> Search(MainSearchInput data, ref int pTotalRows)
        {
            if (UtilityManager.GetAppKeyValue("usingElasticLearningOppSearch", false))
            {
                return(ElasticServices.LearningOppSearch(data, ref pTotalRows));
            }
            else
            {
                return(DoSearch(data, ref pTotalRows));
            }
        }